33template <MInt nDim,
class SysEqn>
35 : m_sysEqn(&solver->m_sysEqn),
36 m_cells(solver->m_cells),
37 m_surfaces(solver->m_surfaces),
38 m_solverId(solver->m_solverId),
43 m_minLevel(solver->minLevel()),
44 m_maxLevel(solver->maxLevel()),
45 m_createSpongeBoundary(solver->m_createSpongeBoundary),
46 m_cellsInsideSpongeLayer(solver->m_cellsInsideSpongeLayer),
47 m_noCellsInsideSpongeLayer(solver->m_noCellsInsideSpongeLayer),
48 m_spongeBndryCndIds(solver->m_spongeBndryCndIds),
49 m_spongeFactor(solver->m_spongeFactor),
50 m_spongeDirections(solver->m_spongeDirections),
51 m_sigmaSpongeBndryId(solver->m_sigmaSpongeBndryId),
52 m_sigmaEndSpongeBndryId(solver->m_sigmaEndSpongeBndryId),
53 m_spongeLayerThickness(solver->m_spongeLayerThickness),
54 m_spongeLayerLayout(solver->m_spongeLayerLayout),
55 m_spongeTimeDep(solver->m_spongeTimeDep),
56 m_spongeStartIteration(solver->m_spongeStartIteration),
57 m_spongeEndIteration(solver->m_spongeEndIteration),
58 m_spongeTimeDependent(solver->m_spongeTimeDependent),
59 m_noSpongeBndryCndIds(solver->m_noSpongeBndryCndIds),
60 m_noMaxSpongeBndryCells(solver->m_noMaxSpongeBndryCells),
61 m_spongeBeta(solver->m_spongeBeta),
62 m_spongeCoord(solver->m_spongeCoord),
63 m_radiusFlameTube(solver->m_radiusFlameTube),
64 m_radiusVelFlameTube(solver->m_radiusVelFlameTube),
65 m_shearLayerThickness(solver->m_shearLayerThickness),
66 m_jetHeight(solver->m_jetHeight),
67 m_primaryJetRadius(solver->m_primaryJetRadius),
68 m_secondaryJetRadius(solver->m_secondaryJetRadius),
69 m_targetVelocityFactor(solver->m_targetVelocityFactor),
70 m_momentumThickness(solver->m_momentumThickness),
71 m_shearLayerStrength(solver->m_shearLayerStrength),
73 m_noSpecies(solver->m_noSpecies),
74 m_noRansEquations(solver->m_noRansEquations),
75 m_combustion(solver->m_combustion),
76 m_isEEGas(solver->m_isEEGas) {
92 for(
MInt i = 1; i < nDim; i++) {
95 m_noLevelSetsUsedForMb = 1;
96 m_complexBoundaryMB =
false;
97 m_cellCoordinatesCorrected =
false;
99 if(m_solver->m_levelSetMb) {
109 m_complexBoundaryMB =
110 Context::getSolverProperty<MBool>(
"complexBoundaryForMb", m_solverId, AT_, &m_complexBoundaryMB);
111 if(m_complexBoundaryMB)
112 m_noLevelSetsUsedForMb =
113 Context::getSolverProperty<MInt>(
"maxNoLevelSets", m_solverId, AT_, &m_noLevelSetsUsedForMb);
117 m_gridCutTest =
"SAT";
118 m_gridCutTest = Context::getSolverProperty<MString>(
"gridCutTest", m_solverId, AT_, &m_gridCutTest);
130 m_Bc3011WallTemperature = sysEqn().temperature_IR(m_Ma);
131 m_Bc3011WallTemperature =
132 Context::getSolverProperty<MFloat>(
"Bc3011WallTemperature", m_solverId, AT_, &m_Bc3011WallTemperature);
137 m_createBoundaryAtCutoff =
false;
138 m_volumeLimitWall = F1B2;
139 m_volumeLimitOther = F1B4;
153 m_sigmaNonRefl = Context::getSolverProperty<MFloat>(
"sigmaNonRefl", m_solverId, AT_, &m_sigmaNonRefl);
166 m_sigmaNonReflInflow = F1;
167 m_sigmaNonReflInflow =
168 Context::getSolverProperty<MFloat>(
"sigmaNonReflInflow", m_solverId, AT_, &m_sigmaNonReflInflow);
180 m_createBoundaryAtCutoff =
181 Context::getSolverProperty<MBool>(
"createBoundaryAtCutoff", m_solverId, AT_, &m_createBoundaryAtCutoff);
182 m_volumeLimitOther = Context::getSolverProperty<MFloat>(
"volumeLimitOther", m_solverId, AT_, &m_volumeLimitOther);
195 m_volumeLimitWall = Context::getSolverProperty<MFloat>(
"volumeLimitWall", m_solverId, AT_, &m_volumeLimitWall);
206 m_smallCellRHSCorrection =
false;
207 m_smallCellRHSCorrection =
208 Context::getSolverProperty<MBool>(
"smallCellRHSCorrection", m_solverId, AT_, &m_smallCellRHSCorrection);
210 if(m_createBoundaryAtCutoff) {
211 m_changeAdiabBCToTemp =
false;
212 m_changeAdiabBCToTemp =
213 Context::getSolverProperty<MBool>(
"changeAdiabBCToTemp", m_solverId, AT_, &m_changeAdiabBCToTemp);
230 m_multipleGhostCells = 0;
231 m_multipleGhostCells = Context::getSolverProperty<MInt>(
"multipleGhostCells", m_solverId, AT_, &m_multipleGhostCells);
233 m_ipVariableIterative = 0;
234 m_noImagePointIterations = 0;
235 m_surfaceGhostCell = 0;
236 m_outputIGPoints = 0;
238 if(m_multipleGhostCells != 0) {
253 m_ipVariableIterative =
254 Context::getSolverProperty<MInt>(
"ipVariableIterative", m_solverId, AT_, &m_ipVariableIterative);
255 if(m_ipVariableIterative != 0) {
265 m_noImagePointIterations = 10;
266 m_noImagePointIterations =
267 Context::getSolverProperty<MInt>(
"noImagePointIterations", m_solverId, AT_, &m_noImagePointIterations);
281 m_surfaceGhostCell = Context::getSolverProperty<MInt>(
"surfaceGhostCell", m_solverId, AT_, &m_surfaceGhostCell);
293 m_outputIGPoints = Context::getSolverProperty<MBool>(
"outputIGPoints", m_solverId, AT_, &m_outputIGPoints);
306 m_maxNoBndryCells = Context::getSolverProperty<MInt>(
"maxNoBndryCells", m_solverId, AT_);
308 if(m_multipleGhostCells || m_solver->m_useCreateCutFaceMGC || (m_complexBoundaryMB && m_noLevelSetsUsedForMb == 1))
309 mAlloc(m_bndryCells, m_maxNoBndryCells, nDim, m_noSpecies, m_noRansEquations, 3, 0,
"m_bndryCells_3",
311 else if(m_complexBoundaryMB)
312 mAlloc(m_bndryCells, m_maxNoBndryCells, nDim, m_noSpecies, m_noRansEquations, 12, 0,
"m_bndryCells_12",
315 mAlloc(m_bndryCells, m_maxNoBndryCells, nDim, m_noSpecies, m_noRansEquations, 1, 0,
"m_bndryCells_1",
319 m_bndryCell = m_bndryCells->a;
322 mAlloc(m_smallBndryCells, m_maxNoBndryCells,
"m_smallBndryCells", -1, AT_);
323 mAlloc(m_sortedBndryCells, m_maxNoBndryCells,
"m_sortedBndryCells", -1, AT_);
324 mAlloc(m_sortedSpongeBndryCells,
mMax(1, m_noMaxSpongeBndryCells),
"m_sortedSpongeBndryCells", -1, AT_);
326 "m_boundarySurfaces", -1, AT_);
327 if(m_multipleGhostCells || m_solver->m_useCreateCutFaceMGC) {
328 mAlloc(m_bndryNghbrs, m_maxNoBndryCells * m_noDirs * 2,
"m_bndryNghbrs", -1, AT_);
342 m_maxNoBndryCndIds = Context::getSolverProperty<MInt>(
"maxNoBndryCndIds", m_solverId, AT_);
344 m_cellMerging =
false;
353 m_cellMerging = Context::getSolverProperty<MBool>(
"cellMerging", m_solverId, AT_, &m_cellMerging);
355 m_secondOrderRec =
true;
363 m_secondOrderRec = Context::getSolverProperty<MBool>(
"secondOrderRec", m_solverId, AT_, &m_secondOrderRec);
372 m_noFluxRedistributionLayers = 2;
373 m_noFluxRedistributionLayers =
374 Context::getSolverProperty<MInt>(
"noFluxRedistributionLayers", m_solverId, AT_, &m_noFluxRedistributionLayers);
375 if(noDomains() > 1 && !m_cellMerging && (m_noFluxRedistributionLayers > m_solver->noHaloLayers())) {
376 cerr <<
"Warning: noHalo layers smaller than flux redistribution layers!" << endl;
378 m_nearBoundaryWindowCells =
nullptr;
379 m_nearBoundaryHaloCells =
nullptr;
381 if(m_solver->noNeighborDomains() > 0) {
382 mAlloc(m_nearBoundaryWindowCells, m_solver->noNeighborDomains(),
"m_nearBoundaryWindowCells", AT_);
383 mAlloc(m_nearBoundaryHaloCells, m_solver->noNeighborDomains(),
"m_nearBoundaryHaloCells", AT_);
388 mAlloc(m_reconstructionNghbrs, m_maxNoBndryCells, m_cells.noRecNghbrs(),
"m_reconstructionNghbrs", -1, AT_);
389 mAlloc(m_reconstructionConstants, m_maxNoBndryCells, nDim * m_cells.noRecNghbrs(),
"m_reconstructionConstants_BND",
394 m_noCutOffBndryCndIds = 0;
396 bndryCndHandlerVariables = 0;
397 bndryCndHandlerCutOffVariables = 0;
398 bndryCndHandlerCutOffInit = 0;
399 bndryCndHandlerSpongeVariables = 0;
401 nonReflectingCutOffBoundaryCondition = 0;
402 nonReflectingBoundaryConditionAfterTreatmentCutOff = 0;
403 bndryCndHandlerSlopesInviscid = 0;
404 bndryCndHandlerCutOffSlopesInviscid = 0;
405 bndryViscousSlopes = 0;
406 bndryCutOffViscousSlopes = 0;
407 bndryCndHandlerNeumann = 0;
408 bndryCndHandlerInit = 0;
424 mAlloc(m_bndryCndIds, m_maxNoBndryCndIds,
"m_bndryCndIds", 0, AT_);
425 mAlloc(m_cutOffBndryCndIds, m_maxNoBndryCndIds,
"m_cutOffBndryCndIds", 0, AT_);
426 mAlloc(m_bndryCndCells, m_maxNoBndryCndIds + 1,
"m_bndryCndCells", 0, AT_);
427 mAlloc(m_spongeBndryCells, m_maxNoBndryCndIds + 1,
"m_spongeBndryCells", 0, AT_);
437 m_jetInletTurbulence =
false;
438 m_jetInletTurbulence =
439 Context::getSolverProperty<MBool>(
"jetInletTurbulence", m_solverId, AT_, &m_jetInletTurbulence);
441 m_cutCandidates.clear();
448template <MInt nDim,
class SysEqn>
473template <MInt nDim,
class SysEqn>
479 MInt noBndryCells = m_bndryCells->size();
480 MBool append =
false;
483 m_bndryCndCells[m_noBndryCndIds] = noBndryCells;
484 m_sortedBndryCells->setSize(0);
486 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
487 m_bndryCndCells[bcId] = size;
488 bc = m_bndryCndIds[bcId];
489 for(
MInt id = 0;
id < noBndryCells;
id++) {
491 for(
MInt srfc = 0; srfc < m_bndryCells->a[
id].m_noSrfcs; srfc++) {
492 if(m_bndryCells->a[
id].m_srfcs[srfc]->m_bndryCndId == bc) {
498 m_sortedBndryCells->append();
499 m_sortedBndryCells->a[size] =
id;
508 m_bndryCndCells[m_noBndryCndIds] = size;
516template <MInt nDim,
class SysEqn>
520 MInt noCells = m_bndryCells->size();
523 for(
MInt id = 0;
id < noCells;
id++) {
524 for(
MInt i = 0; i < nDim; i++) {
525 m_solver->a_coordinate(m_bndryCells->a[
id].m_cellId, i) += m_bndryCells->a[
id].m_coordinates[i];
528 ASSERT(!m_cellCoordinatesCorrected,
"Irregular sequence of cell-coordinate correction!");
529 m_cellCoordinatesCorrected =
true;
537template <MInt nDim,
class SysEqn>
543 MInt noCells = m_bndryCells->size();
544 MInt noSmallCells = m_smallBndryCells->size();
547 for(
MInt id = 0;
id < noCells;
id++) {
548 for(
MInt i = 0; i < nDim; i++) {
549 m_solver->a_coordinate(m_bndryCells->a[
id].m_cellId, i) -= m_bndryCells->a[
id].m_coordinates[i];
553 for(
MInt smallId = 0; smallId < noSmallCells; smallId++) {
554 smallCell = m_smallBndryCells->a[smallId];
555 masterId = m_bndryCells->a[smallCell].m_linkedCellId;
556 if(m_solver->a_bndryId(masterId) == -1) {
557 for(
MInt i = 0; i < nDim; i++) {
558 m_solver->a_coordinate(masterId, i) = m_bndryCells->a[smallCell].m_masterCoordinates[i];
562 ASSERT(m_cellCoordinatesCorrected,
"Irregular sequence of cell-coordinate correction!");
563 m_cellCoordinatesCorrected =
false;
567template <MInt nDim,
class SysEqn>
571 const MInt noCells = m_bndryCells->size();
572 const MInt noSmallCells = m_smallBndryCells->size();
575 for(
MInt id = 0;
id < noCells;
id++) {
576 for(
MInt i = 0; i < nDim; i++) {
577 m_solver->a_coordinate(m_bndryCells->a[
id].m_cellId, i) += m_bndryCells->a[
id].m_coordinates[i];
581 for(
MInt smallId = 0; smallId < noSmallCells; smallId++) {
582 const MInt smallCell = m_smallBndryCells->a[smallId];
583 const MInt smallCellId = m_bndryCells->a[smallCell].m_cellId;
584 const MInt masterId = m_bndryCells->a[smallCell].m_linkedCellId;
585 if(m_solver->a_bndryId(masterId) == -1) {
586 for(
MInt i = 0; i < nDim; i++) {
587 m_solver->a_coordinate(masterId, i) = m_solver->a_coordinate(smallCellId, i);
591 ASSERT(!m_cellCoordinatesCorrected,
"Irregular sequence of cell-coordinate correction!");
592 m_cellCoordinatesCorrected =
true;
605template <MInt nDim,
class SysEqn>
610 for(
MInt id = 0;
id < m_solver->a_noCells();
id++) {
611 m_solver->a_bndryId(
id) = -1;
615 for(
MInt bndryId = 0; bndryId < m_bndryCells->size(); bndryId++) {
616 m_solver->a_bndryId(m_bndryCells->a[bndryId].m_cellId) = bndryId;
624template <MInt nDim,
class SysEqn>
627 m_solver->m_associatedInternalCells.clear();
628 m_solver->m_totalnoghostcells = 0;
631 for(
MInt bndryId = 0; bndryId < m_bndryCells->size(); bndryId++) {
632 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
635 m_solver->m_totalnoghostcells++;
636 const MInt ghostCellId = m_solver->a_noCells() - 1;
637 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId = ghostCellId;
639#ifdef mirroredGhostCell
644 for(
MInt i = 0; i < nDim; i++) {
645 connectionVctr[i] = m_solver->a_coordinate(m_bndryCells->a[bndryId].m_cellId, i)
646 - m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i];
652 for(
MInt i = 0; i < nDim; i++) {
653 distance += connectionVctr[i] * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
655 distance = fabs(distance);
660 for(
MInt i = 0; i < nDim; i++) {
661 m_solver->a_coordinate(ghostCellId, i) =
662 m_solver->a_coordinate(m_bndryCells->a[bndryId].m_cellId, i)
663 - 2.0 * distance * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
667 for(
MInt i = 0; i < nDim; i++) {
668 m_solver->a_coordinate(ghostCellId, i) = F2 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i]
669 - m_solver->a_coordinate(m_bndryCells->a[bndryId].m_cellId, i);
674 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
675 const MFloat cellHalfLength = F1B2 * m_solver->c_cellLengthAtCell(cellId);
677 for(
MInt i = 0; i < nDim; i++) {
678 dn += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]
679 * (m_solver->a_coordinate(cellId, i) - m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i]);
681 for(
MInt i = 0; i < nDim; i++) {
684 m_solver->a_coordinate(ghostCellId, i) =
685 m_solver->a_coordinate(cellId, i)
686 -
mMax(F2 * dn, dn + cellHalfLength) * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
690 m_solver->a_noReconstructionNeighbors(ghostCellId) = 0;
691 m_solver->a_level(ghostCellId) = m_solver->a_level(m_bndryCells->a[bndryId].m_cellId);
703 m_solver->m_associatedInternalCells.push_back(m_bndryCells->a[bndryId].m_cellId);
706 m_solver->a_bndryId(ghostCellId) = -2;
707 m_solver->a_isBndryGhostCell(ghostCellId) =
true;
709 ASSERT(m_solver->a_level(ghostCellId) == m_solver->a_level(m_solver->getAssociatedInternalCell(ghostCellId)),
"");
728template <MInt nDim,
class SysEqn>
735 if(m_outputIGPoints) {
736 const MChar* filename =
"imagePoints_";
737 stringstream filename2;
738 filename2 << filename << domainId() <<
".vtk";
739 ofl.open((filename2.str()).c_str(), ofstream::trunc);
740 const MChar* filename3 =
"ghostPoints";
741 stringstream filename4;
742 filename4 << filename3 << domainId() <<
".vtk";
743 ofl2.open((filename4.str()).c_str(), ofstream::trunc);
746 MInt noImagePoints = 0;
749 m_solver->m_associatedInternalCells.clear();
750 m_solver->m_totalnoghostcells = 0;
752 for(
MInt bndryId = 0; bndryId < m_bndryCells->size(); bndryId++) {
753 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
756 m_solver->m_totalnoghostcells++;
759 m_solver->a_bndryId(m_solver->a_noCells() - 1) = -2;
761 const MInt ghostCellId = m_solver->a_noCells() - 1;
763 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId = ghostCellId;
766 if(m_solver->a_hasProperty(m_bndryCells->a[bndryId].m_cellId, SolverCell::IsOnCurrentMGLevel)) {
768 MInt gridcellId = m_bndryCells->a[bndryId].m_cellId;
769 if(m_solver->a_hasProperty(gridcellId, SolverCell::IsSplitClone)) {
770 gridcellId = m_solver->m_splitChildToSplitCell.find(gridcellId)->second;
772 if(m_solver->c_noChildren(gridcellId) == 0) noImagePoints++;
779 for(
MInt i = 0; i < nDim; i++) {
780 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[i] =
781 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i];
782 m_solver->a_coordinate(ghostCellId, i) = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i];
784 dist += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]
785 * (m_solver->a_coordinate(m_bndryCells->a[bndryId].m_cellId, i)
786 - m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i]);
789 if(m_surfaceGhostCell != 0) {
790 for(
MInt i = 0; i < nDim; i++) {
791 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[i] +=
792 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i] *
dist;
795 for(
MInt i = 0; i < nDim; i++) {
796 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[i] +=
797 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i] *
dist;
798 m_solver->a_coordinate(ghostCellId, i) -= m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i] *
dist;
803 m_solver->a_noReconstructionNeighbors(ghostCellId) = 0;
804 m_solver->a_level(ghostCellId) = m_solver->a_level(m_bndryCells->a[bndryId].m_cellId);
807 m_solver->m_associatedInternalCells.push_back(m_bndryCells->a[bndryId].m_cellId);
808 m_solver->a_isBndryGhostCell(ghostCellId) =
true;
813 if(m_outputIGPoints) {
815 ofl.setf(ios::fixed);
817 ofl2.setf(ios::fixed);
820 ofl <<
"# vtk DataFile Version 3.0" << endl
821 <<
"MAIAD imagePoints file" << endl
823 <<
"DATASET POLYDATA" << endl
824 <<
"POINTS " << noImagePoints <<
" float" << endl;
826 ofl2 <<
"# vtk DataFile Version 3.0" << endl
827 <<
"MAIAD ghostPoints file" << endl
829 <<
"DATASET POLYDATA" << endl
830 <<
"POINTS " << noImagePoints <<
" float" << endl;
832 for(
MInt bndryId = 0; bndryId < m_bndryCells->size(); bndryId++) {
833 if(!m_solver->a_hasProperty(m_bndryCells->a[bndryId].m_cellId, SolverCell::IsOnCurrentMGLevel))
continue;
836 if(m_solver->c_noChildren(m_bndryCells->a[bndryId].m_cellId) > 0)
continue;
837 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
838 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
840 ofl << m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[i] <<
" ";
841 ofl2 << m_solver->a_coordinate(ghostCellId, i) <<
" ";
848 ofl <<
"VERTICES " << noImagePoints <<
" " << noImagePoints * 2 << endl;
849 ofl2 <<
"VERTICES " << noImagePoints <<
" " << noImagePoints * 2 << endl;
850 for(
MInt i = 0; i < noImagePoints; i++) {
851 ofl <<
"1 " << i << endl;
852 ofl2 <<
"1 " << i << endl;
907template <MInt nDim,
class SysEqn>
914 for(
MInt i = 0; i < nDim; i++) {
915 x[i] = m_solver->a_coordinate(m_bndryCells->a[bndryId].m_cellId, i)
916 - m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[i];
919 for(
MInt i = 0; i < nDim; i++) {
920 distance += x[i] * m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i];
922 distance = fabs(distance);
923 for(
MInt i = 0; i < nDim; i++) {
924 x[i] = m_solver->a_coordinate(m_bndryCells->a[bndryId].m_cellId, i)
925 - F2 * distance * m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i];
932template <MInt nDim,
class SysEqn>
939 for(
MInt i = 0; i < nDim; i++) {
940 x[i] = m_solver->a_coordinate(m_bndryCells->a[bndryId].m_cellId, i)
941 - m_bndryCells->a[bndryId].m_srfcs[srfcId]->m_coordinates[i];
944 for(
MInt i = 0; i < nDim; i++) {
945 distance += x[i] * m_bndryCells->a[bndryId].m_srfcs[srfcId]->m_normalVector[i];
947 distance = fabs(distance);
948 for(
MInt i = 0; i < nDim; i++) {
949 x[i] = m_solver->a_coordinate(m_bndryCells->a[bndryId].m_cellId, i)
950 - F2 * distance * m_bndryCells->a[bndryId].m_srfcs[srfcId]->m_normalVector[i];
962template <MInt nDim,
class SysEqn>
966 MBool cellOk =
false;
967 MInt cellId, ghostCellId;
968 MInt noCells = m_bndryCells->size();
970 MFloat epsilon = pow(10.0, -13.0);
973 m_noBoundarySurfaces = 0;
975 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
978 for(
MInt srfc = 0; srfc < FvBndryCell<nDim, SysEqn>::m_maxNoSurfaces; srfc++) {
979 for(
MInt i = 0; i < nDim; i++)
980 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_srfcId[i] = -1;
985 if(m_solver->a_isHalo(m_bndryCells->a[bndryId].m_cellId)) {
986 if(m_bndryCells->a[bndryId].m_linkedCellId > -1) {
987 if(m_solver->a_bndryId(m_bndryCells->a[bndryId].m_linkedCellId) == -1
988 && !m_solver->a_isHalo(m_bndryCells->a[bndryId].m_linkedCellId))
992 if(m_bndryCells->a[bndryId].m_linkedCellId == -1) {
995 if(m_solver->a_bndryId(m_bndryCells->a[bndryId].m_linkedCellId) == -1) {
1002 ASSERT(m_bndryCells->a[bndryId].m_noSrfcs == 1,
"noSrfc: " << m_bndryCells->a[bndryId].m_noSrfcs
1003 <<
" bndryId: " << bndryId <<
" noCutPoints "
1004 << m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints);
1005 cellId = m_bndryCells->a[bndryId].m_cellId;
1006 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
1007 if((m_solver->c_noChildren(cellId) == 0 && m_solver->a_level(cellId) <= m_solver->maxRefinementLevel())
1008 || (m_solver->c_noChildren(cellId) > 0 && m_solver->a_level(cellId) == m_solver->maxRefinementLevel())) {
1010 for(
MInt i = 0; i < nDim; i++) {
1013 if(fabs(m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i]) > epsilon) {
1014 m_surfaces.append();
1015 srfcId = m_solver->a_noSurfaces() - 1;
1018 m_boundarySurfaces[m_noBoundarySurfaces] = srfcId;
1019 m_noBoundarySurfaces++;
1022 m_solver->a_surfaceBndryCndId(srfcId) = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
1025 for(
MInt j = 0; j < nDim; j++) {
1026 m_solver->a_surfaceCoordinate(srfcId, j) = m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[j];
1030 m_solver->a_surfaceArea(srfcId) = m_bndryCells->a[bndryId].m_srfcs[0]->m_area
1031 * fabs(m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i]);
1034 m_solver->a_surfaceOrientation(srfcId) = i;
1036 ASSERT(ghostCellId > -1,
"");
1039 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i] > F0) {
1040 m_solver->a_surfaceNghbrCellId(srfcId, 0) = ghostCellId;
1041 m_solver->a_surfaceNghbrCellId(srfcId, 1) = cellId;
1043 m_solver->a_surfaceNghbrCellId(srfcId, 1) = ghostCellId;
1044 m_solver->a_surfaceNghbrCellId(srfcId, 0) = cellId;
1048 m_bndryCells->a[bndryId].m_srfcVariables[0]->m_srfcId[i] = srfcId;
1067template <MInt nDim,
class SysEqn>
1072 MInt cellId, ghostCellId;
1073 MInt noCells = m_bndryCells->size();
1075 MFloat epsilon = pow(10.0, -20.0);
1078 m_noBoundarySurfaces = 0;
1080 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
1083 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
1084 for(
MInt i = 0; i < nDim; i++) {
1085 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_srfcId[i] = -1;
1089 if(m_solver->a_hasProperty(m_bndryCells->a[bndryId].m_cellId, SolverCell::IsInvalid))
continue;
1092 if(m_solver->a_isHalo(m_bndryCells->a[bndryId].m_cellId)) {
1093 if(m_bndryCells->a[bndryId].m_linkedCellId > -1) {
1094 if(!m_solver->a_isHalo(m_bndryCells->a[bndryId].m_linkedCellId)) cellOk =
true;
1101 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
1102 cellId = m_bndryCells->a[bndryId].m_cellId;
1103 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
1104 MInt gridcellId = cellId;
1105 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitClone)) {
1106 gridcellId = m_solver->m_splitChildToSplitCell.find(cellId)->second;
1108 if((m_solver->c_noChildren(gridcellId) == 0 && m_solver->a_level(cellId) <= m_solver->maxRefinementLevel())
1109 || (m_solver->c_noChildren(gridcellId) > 0 && m_solver->a_level(cellId) == m_solver->maxRefinementLevel())) {
1111 for(
MInt i = 0; i < nDim; i++) {
1114 if(fabs(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]) > epsilon) {
1115 m_surfaces.append();
1116 srfcId = m_solver->a_noSurfaces() - 1;
1119 m_boundarySurfaces[m_noBoundarySurfaces] = srfcId;
1120 m_noBoundarySurfaces++;
1123 m_solver->a_surfaceBndryCndId(srfcId) = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId;
1126 for(
MInt j = 0; j < nDim; j++) {
1127 m_solver->a_surfaceCoordinate(srfcId, j) = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[j];
1131 m_solver->a_surfaceArea(srfcId) = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
1132 * fabs(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]);
1135 m_solver->a_surfaceOrientation(srfcId) = i;
1138 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i] > F0) {
1139 m_solver->a_surfaceNghbrCellId(srfcId, 0) = ghostCellId;
1140 m_solver->a_surfaceNghbrCellId(srfcId, 1) = cellId;
1142 m_solver->a_surfaceNghbrCellId(srfcId, 1) = ghostCellId;
1143 m_solver->a_surfaceNghbrCellId(srfcId, 0) = cellId;
1147 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_srfcId[i] = srfcId;
1170template <MInt nDim,
class SysEqn>
1174 const MInt noBndrySurfaces = m_noBoundarySurfaces;
1175 const MInt noVars = CV->noVariables;
1176 const MInt surfaceVarMemory = m_solver->m_surfaceVarMemory;
1177 MFloat* surfaceVar = (
MFloat*)(&(m_solver->a_surfaceVariable(0, 0, 0)));
1178 MInt nghbr0, nghbr1, bndryId, ghostSurf;
1182#pragma omp parallel for
1184 for(
MInt bs = 0; bs < noBndrySurfaces; bs++) {
1185 nghbr0 = m_solver->a_surfaceNghbrCellId(m_boundarySurfaces[bs], 0);
1186 nghbr1 = m_solver->a_surfaceNghbrCellId(m_boundarySurfaces[bs], 1);
1187 if(m_solver->a_isBndryGhostCell(nghbr0)) {
1188 bndryId = m_solver->a_bndryId(m_solver->getAssociatedInternalCell(nghbr0));
1190 for(
MInt srfcId = 0; srfcId < m_bndryCells->a[bndryId].m_noSrfcs; srfcId++) {
1191 if(m_bndryCells->a[bndryId].m_srfcVariables[srfcId]->m_ghostCellId == nghbr0) {
1204 for(
MInt var = 0; var < noVars; var++) {
1205 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + var] =
1207 * (m_solver->a_pvariable(nghbr0, var)
1208 + m_bndryCells->a[bndryId].m_srfcVariables[ghostSurf]->m_imageVariables[var]);
1209 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + noVars + var] =
1210 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + var];
1212 }
else if(m_solver->a_isBndryGhostCell(nghbr1)) {
1213 bndryId = m_solver->a_bndryId(m_solver->getAssociatedInternalCell(nghbr1));
1215 for(
MInt srfcId = 0; srfcId < m_bndryCells->a[bndryId].m_noSrfcs; srfcId++) {
1216 if(m_bndryCells->a[bndryId].m_srfcVariables[srfcId]->m_ghostCellId == nghbr1) {
1229 for(
MInt var = 0; var < noVars; var++) {
1230 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + var] =
1232 * (m_solver->a_pvariable(nghbr1, var)
1233 + m_bndryCells->a[bndryId].m_srfcVariables[ghostSurf]->m_imageVariables[var]);
1234 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + noVars + var] =
1235 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + var];
1238 cerr <<
"[ " << domainId() <<
" ]"
1239 <<
" Error in FvBndryCndXD::correctBoundarySurfaceVariablesMGC; This case should not occur! "
1240 <<
" surface " << m_boundarySurfaces[bs] <<
" has no ghost cell neighbor! "
1241 <<
"neighbors: " << nghbr0 <<
" " << nghbr1 << endl;
1257template <MInt nDim,
class SysEqn>
1261 const MInt noBndrySurfaces = m_noBoundarySurfaces;
1262 const MInt noVars = CV->noVariables;
1263 const MInt surfaceVarMemory = m_solver->m_surfaceVarMemory;
1264 MFloat* surfaceVar = (
MFloat*)(&(m_solver->a_surfaceVariable(0, 0, 0)));
1265 MInt nghbr0, nghbr1;
1269#pragma omp parallel for
1271 for(
MInt bs = 0; bs < noBndrySurfaces; bs++) {
1272 nghbr0 = m_solver->a_surfaceNghbrCellId(m_boundarySurfaces[bs], 0);
1273 nghbr1 = m_solver->a_surfaceNghbrCellId(m_boundarySurfaces[bs], 1);
1274 if(m_solver->a_isBndryGhostCell(nghbr0)) {
1275 for(
MInt var = 0; var < noVars; var++) {
1276 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + var] = m_solver->a_pvariable(nghbr0, var);
1277 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + noVars + var] = m_solver->a_pvariable(nghbr0, var);
1279 }
else if(m_solver->a_isBndryGhostCell(nghbr1)) {
1280 for(
MInt var = 0; var < noVars; var++) {
1281 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + var] = m_solver->a_pvariable(nghbr1, var);
1282 surfaceVar[m_boundarySurfaces[bs] * surfaceVarMemory + noVars + var] = m_solver->a_pvariable(nghbr1, var);
1285 cerr <<
"[ " << domainId() <<
" ]"
1286 <<
" Error in FvBndryCndXD::correctBoundarySurfaceVariablesMGCSurface; This case should not occur! "
1287 <<
" surface " << m_boundarySurfaces[bs] <<
" has no ghost cell neighbor! "
1288 <<
"neighbors: " << nghbr0 <<
" " << nghbr1 << endl;
1296template <MInt nDim,
class SysEqn>
1301 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
1302 (this->*bndryCndHandlerNeumann[bcId])(bcId);
1305 copySlopesToSmallCells();
1307 if(!m_cellMerging) storeBoundaryVariables();
1312template <MInt nDim,
class SysEqn>
1316 const MInt noBndryCells = m_bndryCells->size();
1317 const MInt noPVars = PV->noVariables;
1319 MInt nanCounter = 0;
1320 const MInt nanCounterMax = 5 * noPVars;
1324#pragma omp parallel for
1326 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
1327 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
1328 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitCell))
continue;
1329 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient))
continue;
1330 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
1331 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
1332 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
1333 for(
MInt v = 0; v < noPVars; v++) {
1334 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v] =
1335 F1B2 * (m_solver->a_pvariable(ghostCellId, v) + m_solver->a_pvariable(cellId, v));
1337 if(std::isnan(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v]) && nanCounter < nanCounterMax) {
1338 cerr << domainId() <<
": nan detected in boundary surface var " << v <<
" " << cellId <<
" ("
1339 << m_solver->c_globalId(cellId) <<
") " << ghostCellId <<
" halo:" << m_solver->a_isHalo(cellId)
1340 <<
" (" << m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient) <<
")"
1341 <<
" /vars " << m_solver->a_pvariable(ghostCellId, v) <<
" " << m_solver->a_pvariable(cellId, v) <<
" "
1342 << m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v] <<
" ("
1343 << &m_solver->a_pvariable(cellId, v) <<
")"
1344 <<
" /coords " << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 1) <<
" "
1345 << m_solver->a_coordinate(cellId, 2) <<
" /bndCnd " << m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId
1346 <<
" /lvl " << m_solver->a_level(cellId) <<
" /halo " << m_solver->a_isHalo(cellId) << endl;
1348 if(nanCounter == nanCounterMax) {
1349 cerr << domainId() <<
": nan detected in boundary surface ... skipping further output" << std::endl;
1355 ASSERT((
approx(sysEqn().temperature_ES(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO],
1356 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P]),
1357 m_Bc3011WallTemperature, F5 * MFloatEps))
1358 || (m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId != 3011 || isDetChem<SysEqn>),
1359 "isothermal wall 3011 fail");
1365 MFloatScratchSpace dummyPvariables(m_bndryCells->a[bndryId].m_noSrfcs, PV->noVariables, AT_,
"dummyPvariables");
1366 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
1368 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
1369 MFloat normal[3] = {F0, F0, F0};
1370 for(
MInt i = 0; i < nDim; i++) {
1371 normal[i] = m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVectorCentroid[i];
1382 for(
MInt v = 0; v < noPVars; v++) {
1383 if(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[v] ==
BC_DIRICHLET) {
1385 s <
mMin((
signed)m_bndryCell[bndryId].m_recNghbrIds.size(), m_bndryCells->a[bndryId].m_noSrfcs);
1387 dummyPvariables(s, v) = m_bndryCell[bndryId].m_srfcVariables[s]->m_primVars[v];
1390 for(
MInt n = 0; n < (signed)m_bndryCell[bndryId].m_recNghbrIds.size(); n++) {
1391 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[n];
1392 const MFloat nghbrPvariable = (n < m_bndryCells->a[bndryId].m_noSrfcs)
1393 ? dummyPvariables(n, v)
1394 : m_solver->a_pvariable(nghbrId, v);
1396 || m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.size()
1397 != m_bndryCell[bndryId].m_recNghbrIds.size()) {
1398 cerr << nghbrId <<
" " << m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.
size()
1399 <<
" " << m_bndryCell[bndryId].m_recNghbrIds.size() << endl;
1402 && m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.size()
1403 == m_bndryCell[bndryId].m_recNghbrIds.size(),
1405 imageVar += m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst[n] * nghbrPvariable;
1410 m_solver->a_pvariable(ghostCellId, v) =
1411 F2 * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v] - imageVar;
1412 }
else if(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[v] ==
BC_NEUMANN) {
1413 MFloat dn0 = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance;
1416 for(
MInt i = 0; i < nDim; i++) {
1419 dn += (m_solver->a_coordinate(cellId, i) - m_solver->a_coordinate(ghostCellId, i)) * normal[i];
1421 m_solver->a_pvariable(ghostCellId, v) =
1422 m_solver->a_pvariable(cellId, v) - dn * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[v];
1423 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v] =
1424 m_solver->a_pvariable(cellId, v) - dn0 * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[v];
1425 }
else if(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[v] ==
BC_ROBIN) {
1426 MFloat phi = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance;
1428 for(
MInt i = 0; i < nDim; i++) {
1429 phi += (m_solver->a_coordinate(cellId, i) - m_bndryCell[bndryId].m_srfcs[srfc]->m_coordinates[i])
1433 dn += (m_solver->a_coordinate(cellId, i) - m_solver->a_coordinate(ghostCellId, i)) * normal[i];
1435 dn -= m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance;
1436 if(dn + phi < 1e-8) {
1437 cerr << domainId() <<
": warning very small distance " << m_solver->c_globalId(cellId) <<
" " << phi
1438 <<
" " << dn <<
" " << normal[0] <<
" " << normal[1] <<
" " << normal[2] << endl;
1440 const MFloat beta = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_robinFactor;
1441 const MFloat delta = m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[v];
1443 const MFloat fac = (F1 + F1B2 * beta * (dn + phi)) / (F1 - F1B2 * beta * (dn + phi));
1445 const MFloat fac2 = (dn + phi) / (F1 - F1B2 * beta * (dn + phi));
1446 m_solver->a_pvariable(ghostCellId, v) = fac * m_solver->a_pvariable(cellId, v) - fac2 * delta;
1447 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v] =
1448 (dn * m_solver->a_pvariable(cellId, v) + phi * m_solver->a_pvariable(ghostCellId, v)) / (dn + phi);
1450 if(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId == 3007) {
1453 s <
mMin((
signed)m_bndryCell[bndryId].m_recNghbrIds.size(), m_bndryCells->a[bndryId].m_noSrfcs);
1455 dummyPvariables(s, v) = m_solver->a_pvariable(cellId, v);
1457 for(
MInt n = 0; n < (signed)m_bndryCell[bndryId].m_recNghbrIds.size(); n++) {
1458 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[n];
1459 const MFloat nghbrPvariable = (n < m_bndryCells->a[bndryId].m_noSrfcs)
1460 ? dummyPvariables(n, v)
1461 : m_solver->a_pvariable(nghbrId, v);
1462 imageVar += m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst[n] * nghbrPvariable;
1465 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[v] =
1468 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v] = imageVar;
1473 }
else if(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[v] ==
BC_ISOTHERMAL) {
1477 "Unknown BC type: " + to_string(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId) +
"/"
1478 + to_string(v) +
"/" + to_string(m_bndryCells->a[bndryId].m_noSrfcs) +
"/"
1479 + to_string(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[v]) +
" "
1480 + to_string(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area) +
" "
1481 + to_string(m_solver->a_hasProperty(cellId, SolverCell::IsCutOff)));
1484 if(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->RHO] ==
BC_ISOTHERMAL) {
1486 const MFloat Ts = sysEqn().temperature_ES(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO],
1487 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P]);
1490 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO] =
1491 sysEqn().density_ES(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P], Ts);
1493 s <
mMin((
signed)m_bndryCell[bndryId].m_recNghbrIds.size(), m_bndryCells->a[bndryId].m_noSrfcs);
1495 for(
MInt vv = 0; vv < noPVars; vv++) {
1496 dummyPvariables(s, vv) = m_bndryCell[bndryId].m_srfcVariables[s]->m_primVars[vv];
1500 MFloat dn00 = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance;
1504 for(
MInt i = 0; i < nDim; i++) {
1507 dn += (m_solver->a_coordinate(cellId, i) - m_solver->a_coordinate(ghostCellId, i)) * normal[i];
1515 for(
MInt n = 0; n < (signed)m_bndryCell[bndryId].m_recNghbrIds.size(); n++) {
1516 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[n];
1517 const MFloat nghbrPvariableP = (n < m_bndryCells->a[bndryId].m_noSrfcs)
1518 ? dummyPvariables(n, PV->P)
1519 : m_solver->a_pvariable(nghbrId, PV->P);
1520 imageVar += m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst[n] * nghbrPvariableP;
1522 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P] = m_solver->a_pvariable(cellId, PV->P);
1523 m_solver->a_pvariable(ghostCellId, PV->P) =
1524 F2 * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P] - imageVar;
1525 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[PV->P] =
1526 (imageVar - m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P]) / dn0;
1528 for(
MInt n = 0; n < (signed)m_bndryCell[bndryId].m_recNghbrIds.size(); n++) {
1529 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[n];
1530 const MInt noSrfcs = m_bndryCells->a[bndryId].m_noSrfcs;
1531 const MFloat nghbrPvariableP =
1532 (n < noSrfcs) ? dummyPvariables(n, PV->P) : m_solver->a_pvariable(nghbrId, PV->P);
1533 const MFloat nghbrPvariableRho =
1534 (n < noSrfcs) ? dummyPvariables(n, PV->RHO) : m_solver->a_pvariable(nghbrId, PV->RHO);
1536 || m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.size()
1537 != m_bndryCell[bndryId].m_recNghbrIds.size()) {
1538 cerr << nghbrId <<
" " << m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.
size() <<
" "
1539 << m_bndryCell[bndryId].m_recNghbrIds.size() << endl;
1542 && m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.size()
1543 == m_bndryCell[bndryId].m_recNghbrIds.size(),
1545 imageVar += m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst[n]
1546 * sysEqn().temperature_ES(nghbrPvariableRho, nghbrPvariableP);
1549 MFloat dTdn = (imageVar - Ts) / dn0;
1551 const MInt noNghbrIds = m_solver->a_noReconstructionNeighbors(cellId);
1556 while(iter < maxIter && res > 1e-8) {
1557 MFloat pg = m_solver->a_pvariable(ghostCellId, PV->P);
1558 MFloat ps = m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P];
1559 for(
MInt i = 0; i < nDim; i++) {
1560 m_solver->a_slope(cellId, PV->P, i) = F0;
1561 for(
MInt nghbr = 0; nghbr < noNghbrIds; nghbr++) {
1562 const MInt nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
1563 const MInt offset0 = m_solver->a_reconstructionData(cellId) + nghbr;
1564 m_solver->a_slope(cellId, PV->P, i) +=
1565 m_solver->m_reconstructionConstants[nDim * offset0 + i]
1566 * (m_solver->a_pvariable(nghbrId, PV->P) - m_solver->a_pvariable(cellId, PV->P));
1569 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
1570 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P] = m_solver->a_pvariable(cellId, PV->P);
1571 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[PV->P] = F0;
1572 for(
MInt i = 0; i < nDim; i++) {
1573 m_solver->a_pvariable(ghostCellId, PV->P) +=
1574 (m_solver->a_coordinate(ghostCellId, i) - m_solver->a_coordinate(cellId, i))
1575 * m_solver->a_slope(cellId, PV->P, i);
1576 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P] +=
1577 (m_bndryCell[bndryId].m_srfcs[srfc]->m_coordinates[i] - m_solver->a_coordinate(cellId, i))
1578 * m_solver->a_slope(cellId, PV->P, i);
1579 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[PV->P] +=
1580 m_solver->a_slope(cellId, PV->P, i) * normal[i];
1582 m_solver->a_pvariable(ghostCellId, PV->P) =
1583 m_solver->a_pvariable(cellId, PV->P)
1584 - dn * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[PV->P];
1585 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P] =
1586 m_solver->a_pvariable(cellId, PV->P)
1587 - dn00 * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[PV->P];
1589 res =
mMax(fabs(m_solver->a_pvariable(ghostCellId, PV->P) - pg),
1590 fabs(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P] - ps));
1594 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO] =
1595 sysEqn().density_ES(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P], Ts);
1597 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[PV->RHO] =
1598 sysEqn().density_ES(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[PV->P], Ts)
1599 - (m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO] * dTdn) / Ts;
1601 m_solver->a_pvariable(ghostCellId, PV->RHO) =
1602 m_solver->a_pvariable(cellId, PV->RHO)
1603 - dn * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[PV->RHO];
1617template <MInt nDim,
class SysEqn>
1620 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
1621 (this->*bndryCndHandlerVariables[bcId])(bcId);
1629template <MInt nDim,
class SysEqn>
1633 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++)
1634 (this->*bndryCndHandlerCutOffVariables[bcId])(bcId);
1638template <MInt nDim,
class SysEqn>
1643 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++) {
1644 (this->*(bndryCndHandlerCutOffInit[bcId]))(bcId);
1650template <MInt nDim,
class SysEqn>
1654 MInt noCells = m_solver->noInternalCells();
1655 std::set<std::tuple<MInt, MInt, MInt, MBool>> cutOffBndryDirections;
1659 "createBoundaryAtCutoff is set but no cutOff boundary condition is set in cutOffBndryIds or "
1660 "cutOffInterface, fix your property file");
1686 if(noCutOffDirections != noCutOffBndryIds)
1688 "Wrong number of cut off directions. Must be identical to number of cut off bndryIds! Please check!");
1689 std::set<MInt> diffBcs;
1690 for(
MInt i = 0; i < noCutOffBndryIds; i++) {
1691 MInt cutOffBndryIdTmp = Context::getSolverProperty<MInt>(
"cutOffBndryIds", m_solverId, AT_, i);
1692 MInt cutOffDirectionTmp = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, i);
1693 if(m_solver->m_cutOffInterface.find(cutOffBndryIdTmp) != m_solver->m_cutOffInterface.end()) {
1694 mTerm(1, AT_,
"same cut off bc in cutOffBndryIds and cutOffInterface");
1697 MInt cutOffInside = 0;
1699 cutOffInside = Context::getSolverProperty<MBool>(
"cutOffInside", m_solverId, AT_, i);
1701 cutOffBndryDirections.insert(make_tuple(cutOffBndryIdTmp, cutOffDirectionTmp, i, cutOffInside));
1702 diffBcs.insert(cutOffBndryIdTmp);
1718 m_clusterCutOffBcs =
false;
1719 m_clusterCutOffBcs = Context::getSolverProperty<MBool>(
"clusterCutOffBcs", m_solverId, AT_, &m_clusterCutOffBcs);
1720 if(m_clusterCutOffBcs)
1721 m_noCutOffBndryCndIds = diffBcs.size();
1723 m_noCutOffBndryCndIds = noCutOffBndryIds;
1726 m_noCutOffBndryCndIds += m_solver->m_cutOffInterface.size();
1728 allocateCutOffMemory();
1733 for(
MInt d = 0; d < 2 * nDim; d++) {
1734 cutOffInsideBox[d] = Context::getSolverProperty<MFloat>(
"cutOffInsideBox", m_solverId, AT_, d);
1737 cutOffInsideBox.fill(F0);
1740 m_log <<
"*************************" << endl;
1741 m_log <<
"Creating cut-off boundary" << endl;
1742 m_log <<
"*************************" << endl;
1746 for(
auto it = cutOffBndryDirections.begin(); it != cutOffBndryDirections.end(); it++) {
1747 MInt bcId = get<0>(*it);
1748 MInt direction = get<1>(*it);
1749 MBool cutOffInside = get<3>(*it);
1753 if(m_solver->a_isHalo(cellId))
continue;
1754 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
1755 if(m_solver->a_hasNeighbor(cellId, direction,
false) != 0)
continue;
1756 if(m_solver->a_bndryId(cellId) > -1 && m_bndryCells->a[m_solver->a_bndryId(cellId)].m_externalFaces[direction])
1758 if(m_solver->c_parentId(cellId) > -1) {
1759 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId), direction,
false) != 0) {
1764 if(m_solver->m_engineSetup && m_solver->m_noGapRegions > 2) {
1765 if(bcId == 209199 && m_solver->a_coordinate(cellId, 2) > 0)
continue;
1766 if(bcId == 309199 && m_solver->a_coordinate(cellId, 2) < 0)
continue;
1769 m_solver->a_hasProperty(cellId, SolverCell::IsCutOff) =
true;
1772 MBool insideCutOffBox =
true;
1773 for(
MInt d = 0; d < nDim; d++) {
1774 if(m_solver->c_coordinate(cellId, d) < cutOffInsideBox[d]
1775 || m_solver->c_coordinate(cellId, d) > cutOffInsideBox[nDim + d]) {
1776 insideCutOffBox =
false;
1780 if(insideCutOffBox != cutOffInside)
continue;
1782 m_sortedCutOffCells[bc]->a[m_sortedCutOffCells[bc]->size()] =
cellId;
1783 m_sortedCutOffCells[bc]->append();
1785 if(!m_clusterCutOffBcs || std::next(it) == cutOffBndryDirections.end() || bcId != get<0>(*(std::next(it)))) {
1786 m_cutOffBndryCndIds[bc] = bcId;
1787 m_log << bc <<
": " << m_cutOffBndryCndIds[bc] <<
" is cutOffDirection boundary condition" << endl;
1790 m_cbcBndryCndIds[bc] = get<2>(*it);
1797 for(
auto it = m_solver->m_cutOffInterface.begin(); it != m_solver->m_cutOffInterface.end(); it++, bc++) {
1798 m_cutOffBndryCndIds[bc] = *it;
1799 m_log << bc <<
": " << m_cutOffBndryCndIds[bc] <<
" is cutOffInterface boundary condition" << endl;
1801 if(m_solver->a_hasProperty(cellId, SolverCell::IsCutOff))
continue;
1802 if(!m_solver->a_isInterface(cellId))
continue;
1803 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
1804 if(m_solver->a_isHalo(cellId))
continue;
1805 if(m_cutOffBndryCndIds[bc] != isCutOffInterface(cellId))
continue;
1807 m_solver->a_hasProperty(cellId, SolverCell::IsCutOff) =
true;
1808 m_sortedCutOffCells[bc]->a[m_sortedCutOffCells[bc]->size()] =
cellId;
1809 m_sortedCutOffCells[bc]->append();
1813 exchangeCutOffBoundaryCells();
1822template <MInt nDim,
class SysEqn>
1825 if(m_createBoundaryAtCutoff) {
1827 if(m_noCutOffBndryCndIds == 0) TERMM(1,
"cut off is on, but no boundary conditions are available! ");
1829 if(m_noCutOffBndryCndIds >= m_maxNoBndryCndIds) TERMM(1,
"too many cut off bndryIds! ");
1832 for(
auto& i : m_sortedCutOffCells) {
1835 m_sortedCutOffCells.clear();
1837 m_log <<
"no cut off bcs " << m_noCutOffBndryCndIds << endl;
1838 for(
MInt n = 0; n < m_noCutOffBndryCndIds; n++) {
1839 auto* sortedList =
new List<MInt>(m_maxNoBndryCells);
1840 sortedList->setSize(0);
1841 m_sortedCutOffCells.push_back(sortedList);
1844 m_cbcCutOff =
false;
1845 m_cbcCutOff = Context::getSolverProperty<MBool>(
"cutOffcbc", m_solverId, AT_, &m_cbcCutOff);
1847 m_cbcSmallCellCorrection =
false;
1848 m_cbcSmallCellCorrection =
1849 Context::getSolverProperty<MBool>(
"cbcSmallCellCorrection", m_solverId, AT_, &m_cbcSmallCellCorrection);
1852 m_cbcDir.resize(m_noCutOffBndryCndIds);
1853 m_cbcRelax.resize(m_noCutOffBndryCndIds);
1854 m_cbcLref.resize(m_noCutOffBndryCndIds);
1855 m_cbcInflowArea.resize(m_noCutOffBndryCndIds);
1856 m_cbcReferencePoint.resize(m_noCutOffBndryCndIds);
1857 m_dirNormal.resize(m_noCutOffBndryCndIds);
1858 m_dirTangent.resize(m_noCutOffBndryCndIds);
1859 m_cbcDomainMin.resize(m_noCutOffBndryCndIds);
1860 m_cbcBndryCndIds.resize(m_noCutOffBndryCndIds, -1);
1872template <MInt nDim,
class SysEqn>
1876 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++) {
1877 MInt bcIdNr = m_cutOffBndryCndIds[bcId];
1878 MInt noInternalCutOffCells = m_sortedCutOffCells[bcId]->size();
1879 m_log <<
"processing bcIdNr " << bcIdNr <<
" with " << noInternalCutOffCells <<
" internal cut off cells...";
1880 MIntScratchSpace intSendRecBuffers(m_solver->a_noCells(), AT_,
"intSendRecBuffers");
1881 intSendRecBuffers.
fill(0);
1884 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
1885 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
1886 intSendRecBuffers[cellId] = m_solver->a_hasProperty(cellId, SolverCell::IsCutOff);
1887 if(intSendRecBuffers[cellId] > 0 && m_solver->a_isWindow(cellId)) cnt++;
1889 m_log <<
"... " << cnt <<
" window cut off cells to exchange to all domains ... ";
1891 m_solver->exchangeData(intSendRecBuffers.
getPointer(), 1);
1893 for(
MInt i = 0; i < m_solver->noNeighborDomains(); i++) {
1894 for(
MInt j = 0; j < m_solver->noHaloCells(i); j++) {
1895 MInt thishaloCellId = m_solver->haloCellId(i, j);
1896 if(!m_solver->a_hasProperty(thishaloCellId, SolverCell::IsOnCurrentMGLevel))
continue;
1897 if(m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff))
continue;
1898 m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff) = intSendRecBuffers[thishaloCellId];
1899 if(m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff)) {
1900 m_sortedCutOffCells[bcId]->a[m_sortedCutOffCells[bcId]->size()] = thishaloCellId;
1901 m_sortedCutOffCells[bcId]->append();
1907 if(m_solver->grid().azimuthalPeriodicity()) {
1908 MInt axDir = m_solver->grid().raw().m_azimuthalAxialDir;
1910 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
1911 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
1912 if(m_solver->a_hasProperty(cellId, SolverCell::IsCutOff)) {
1913 if(m_solver->c_parentId(cellId) > -1) {
1914 intSendRecBuffers[m_solver->c_parentId(cellId)] =
true;
1918 m_solver->exchangeDataAzimuthal(intSendRecBuffers.
getPointer(), 1);
1919 for(
MInt i = 0; i < m_solver->grid().noAzimuthalNeighborDomains(); i++) {
1920 for(
MInt j = 0; j < m_solver->grid().noAzimuthalHaloCells(i); j++) {
1921 MInt thishaloCellId = m_solver->grid().azimuthalHaloCell(i, j);
1922 if(!m_solver->a_hasProperty(thishaloCellId, SolverCell::IsOnCurrentMGLevel))
continue;
1923 if(m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff))
continue;
1924 if(intSendRecBuffers[thishaloCellId] > 0) {
1925 if(!m_solver->a_hasNeighbor(thishaloCellId, axDir)) {
1926 if(m_solver->c_parentId(thishaloCellId) < 0
1927 || (m_solver->c_parentId(thishaloCellId) > -1
1928 && !m_solver->a_hasNeighbor(m_solver->c_parentId(thishaloCellId), axDir))) {
1929 m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff) = intSendRecBuffers[thishaloCellId];
1931 }
else if(!m_solver->a_hasNeighbor(thishaloCellId, axDir + 1)) {
1932 if(m_solver->c_parentId(thishaloCellId) < 0
1933 || (m_solver->c_parentId(thishaloCellId) > -1
1934 && !m_solver->a_hasNeighbor(m_solver->c_parentId(thishaloCellId), axDir + 1))) {
1935 m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff) = intSendRecBuffers[thishaloCellId];
1939 if(m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff)) {
1940 m_sortedCutOffCells[bcId]->a[m_sortedCutOffCells[bcId]->size()] = thishaloCellId;
1941 m_sortedCutOffCells[bcId]->append();
1945 for(
MUint i = 0; i < m_solver->m_azimuthalRemappedNeighborDomains.size(); i++) {
1946 for(
MUint j = 0; j < m_solver->m_azimuthalRemappedHaloCells[i].size(); j++) {
1947 MInt thishaloCellId = m_solver->m_azimuthalRemappedHaloCells[i][j];
1948 if(!m_solver->a_hasProperty(thishaloCellId, SolverCell::IsOnCurrentMGLevel))
continue;
1949 if(m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff))
continue;
1950 if(intSendRecBuffers[thishaloCellId]
1951 && (!m_solver->a_hasNeighbor(thishaloCellId, axDir)
1952 || !m_solver->a_hasNeighbor(thishaloCellId, axDir + 1))) {
1953 m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff) = intSendRecBuffers[thishaloCellId];
1955 if(m_solver->a_hasProperty(thishaloCellId, SolverCell::IsCutOff)) {
1956 m_sortedCutOffCells[bcId]->a[m_sortedCutOffCells[bcId]->size()] = thishaloCellId;
1957 m_sortedCutOffCells[bcId]->append();
1962 m_log <<
" finished. " << endl
1963 <<
" number received cut off cells = " << m_sortedCutOffCells[bcId]->size() - noInternalCutOffCells
1964 <<
" for current bcId = " << bcIdNr << endl;
1974template <MInt nDim,
class SysEqn>
1981 for(
MInt dir = 0; dir < noCutOffDirections; dir++) {
1982 MInt direction = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, dir);
1984 for(
MInt cellId = 0; cellId < m_solver->noInternalCells(); cellId++) {
1985 if(m_solver->c_noChildren(cellId) > 0)
continue;
1986 if(m_solver->a_hasNeighbor(cellId, direction) != 0)
continue;
1987 if(m_solver->a_isInterface(cellId))
continue;
1988 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
1990 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
1992 if(m_solver->c_parentId(cellId) > -1) {
1993 const MInt parent = m_solver->c_parentId(cellId);
1994 if(m_solver->a_hasNeighbor(parent, direction) != 0)
continue;
1995 if(m_solver->a_isInterface(parent))
continue;
1997 cutOffCells(cellId) = 1;
1998 MInt parentId = m_solver->c_parentId(cellId);
1999 while(parentId > -1 && parentId < m_solver->a_noCells()) {
2000 cutOffCells(parentId) = 1;
2001 parentId = m_solver->c_parentId(parentId);
2006 m_solver->exchangeData(&cutOffCells(0), 1);
2015template <MInt nDim,
class SysEqn>
2017 if(!m_solver->m_cutOffInterface.size())
return 0;
2020 const MFloat cellHalfLength = m_solver->c_cellLengthAtCell(cellId) / F2;
2022 std::vector<MInt> nodeList;
2024 for(
MInt j = 0; j < nDim; j++) {
2025 target[j] = m_solver->a_coordinate(cellId, j) - cellHalfLength;
2026 target[j + nDim] = m_solver->a_coordinate(cellId, j) + cellHalfLength;
2030 if(m_gridCutTest ==
"SAT")
2031 m_solver->m_geometry->getIntersectionElements(target, nodeList, cellHalfLength, &m_solver->a_coordinate(cellId, 0));
2033 m_solver->m_geometry->getIntersectionElements(target, nodeList);
2035 const MInt noNodes = nodeList.size();
2036 if(noNodes == 0)
return 0;
2039 MInt bndCndId = m_solver->m_geometry->elements[nodeList[0]].m_bndCndId;
2040 for(
MInt n = 1; n < noNodes; n++) {
2041 bndCndId =
mMin(m_solver->m_geometry->elements[nodeList[n]].m_bndCndId, bndCndId);
2043 if(m_solver->m_cutOffInterface.find(bndCndId) == m_solver->m_cutOffInterface.end())
2064template <MInt nDim,
class SysEqn>
2068 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++)
2069 (this->*nonReflectingCutOffBoundaryCondition[bcId])(bcId);
2076template <MInt nDim,
class SysEqn>
2080 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++)
2081 (this->*nonReflectingBoundaryConditionAfterTreatmentCutOff[bcId])(bcId);
2088template <MInt nDim,
class SysEqn>
2093 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
2094 (this->*bndryCndHandlerSlopesInviscid[bcId])(bcId);
2102template <MInt nDim,
class SysEqn>
2107 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++) {
2108 (this->*bndryCndHandlerCutOffSlopesInviscid[bcId])(bcId);
2116template <MInt nDim,
class SysEqn>
2120 NEW_TIMER_GROUP_STATIC(tg_initTimer,
"updateGhostCellSlopesViscous");
2121 NEW_TIMER_STATIC(t_timertotal,
"total", tg_initTimer);
2122 NEW_SUB_TIMER_STATIC(t_viscSlopes,
"bndryViscousSlopes", t_timertotal);
2123 NEW_SUB_TIMER_STATIC(t_cghost,
"correctGhostCellSlopesViscous", t_timertotal);
2125 RECORD_TIMER_START(t_timertotal);
2126 RECORD_TIMER_START(t_viscSlopes);
2127 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
2128 (this->*bndryViscousSlopes[bcId])(bcId);
2130 RECORD_TIMER_STOP(t_viscSlopes);
2132 RECORD_TIMER_START(t_cghost);
2133 if(!m_cellMerging) {
2134 correctGhostCellSlopesViscous();
2136 RECORD_TIMER_STOP(t_cghost);
2137 RECORD_TIMER_STOP(t_timertotal);
2144template <MInt nDim,
class SysEqn>
2148 const MInt noBndryCells = m_bndryCells->size();
2149 const MInt noPVars = PV->noVariables;
2152#pragma omp parallel for
2154 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
2155 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
2156 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
2159 if(m_solver->a_isHalo(cellId)) {
2162 if(m_bndryCell[bndryId].m_recNghbrIds.size() == 0) {
2165 if(m_solver->a_hasProperty(cellId, SolverCell::IsCutOff)) {
2169 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
2170 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
2171 MFloat normal[3] = {F0, F0, F0};
2172 for(
MInt i = 0; i < nDim; i++) {
2173 normal[i] = m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVectorCentroid[i];
2176 for(
MInt i = 0; i < nDim; i++) {
2177 dng += (m_solver->a_coordinate(cellId, i) - m_solver->a_coordinate(ghostCellId, i)) * normal[i];
2179 dng -= m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance;
2181 for(
MInt v = 0; v < noPVars; v++) {
2182 switch(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[v]) {
2186 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[v] =
2187 (m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v] - m_solver->a_pvariable(ghostCellId, v))
2191 for(
MInt i = 0; i < nDim; i++) {
2192 m_solver->a_slope(ghostCellId, v, i) =
2193 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[v] * normal[i];
2201 for(
MInt i = 0; i < nDim; i++) {
2202 m_solver->a_slope(ghostCellId, v, i) =
2203 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[v] * normal[i];
2208 for(
MInt i = 0; i < nDim; i++) {
2209 m_solver->a_slope(ghostCellId, v, i) =
2211 * (m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[v]
2212 - m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_robinFactor
2213 * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v]);
2218 stringstream errorMessage;
2219 errorMessage <<
"ERROR: Invalid BC type with value = "
2220 << m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[v] <<
", variable number" << v
2221 <<
", at bc = " << m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId;
2222 mTerm(1, AT_, errorMessage.str());
2226 for(
MInt i = 0; i < nDim; i++) {
2227 m_solver->a_slope(ghostCellId, v, i) =
2228 2.0 * m_solver->a_slope(ghostCellId, v, i) - m_solver->a_slope(cellId, v, i);
2237template <MInt nDim,
class SysEqn>
2241 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++) {
2242 (this->*bndryCutOffViscousSlopes[bcId])(bcId);
2246template <MInt nDim,
class SysEqn>
2250 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
2251 (this->*bndryCndHandlerInit[bcId])(bcId);
2254 if(!m_cellMerging) setBCTypes();
2256 if(m_solver->m_wmLES) {
2265template <MInt nDim,
class SysEqn>
2268 const MInt noPVars = PV->noVariables;
2269 set<MInt> unhandledBCs;
2271 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
2272 if((updateOnlyBndryCndId > -1) && (m_bndryCndIds[bcId] != updateOnlyBndryCndId)) {
2276 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
2277 MInt bndryId = m_sortedBndryCells->a[
id];
2279 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
2280 ASSERT(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId > -1,
"");
2281 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId != m_bndryCndIds[bcId]) {
2286 for(
MInt v = 0; v < noPVars; v++) {
2287 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[v] =
BC_DIRICHLET;
2288 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_normalDeriv[v] = F0;
2290 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_robinFactor = F0;
2293 for(
MInt s = 0; s < m_noSpecies; s++) {
2294 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->Y[s]] =
BC_NEUMANN;
2297 switch(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId) {
2325 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->P] =
BC_NEUMANN;
2326 if(m_isEEGas || isDetChem<SysEqn>) {
2327 for(
MInt s = 0; s < m_noSpecies; s++) {
2328 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->Y[s]] =
BC_DIRICHLET;
2335 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->P] =
BC_NEUMANN;
2337 for(
MInt s = 0; s < m_noSpecies; s++) {
2338 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->Y[s]] =
BC_DIRICHLET;
2350 for(
MInt i = 0; i < nDim; i++) {
2351 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->VV[i]] =
BC_NEUMANN;
2353 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->RHO] =
BC_NEUMANN;
2355 for(
MInt s = 0; s < m_noSpecies; s++) {
2356 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->Y[s]] =
BC_DIRICHLET;
2359 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
2360 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
2361 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->NN[r]] =
BC_NEUMANN;
2380 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->RHO] =
BC_NEUMANN;
2381 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->P] =
BC_NEUMANN;
2388 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->P] =
BC_NEUMANN;
2390 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->RHO] =
BC_ISOTHERMAL;
2401 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->RHO] =
BC_ROBIN;
2402 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->P] =
BC_ROBIN;
2403 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_robinFactor = F0;
2410 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->P] =
BC_NEUMANN;
2411 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->RHO] =
BC_NEUMANN;
2412 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->U] =
BC_NEUMANN;
2414 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
2415 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
2416 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->NN[r]] =
BC_NEUMANN;
2425 for(
MInt v = 0; v < noPVars; v++) {
2426 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[v] =
BC_UNSET;
2428 unhandledBCs.insert(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId);
2434 if(m_firstUseSetBCTypes) {
2435 for(
MInt unhandledBC : unhandledBCs) {
2436 cerr0 <<
"Boundary condition " << unhandledBC <<
" not handled in FvBndryCndXD::setBCTypes(). "
2437 <<
"Defaulting to Dirichlet-type behavior - but on occurrence of a small cell an error will be thrown."
2439 m_log <<
"Boundary condition " << unhandledBC <<
" not handled in FvBndryCndXD::setBCTypes(). "
2440 <<
"Defaulting to Dirichlet-type behavior - but on occurrence of a small cell an error will be thrown."
2443 if(unhandledBCs.empty()) {
2444 m_log <<
"All boundary conditions handled in FvBndryCndXD::setBCTypes()." << endl;
2446 m_firstUseSetBCTypes =
false;
2459template <MInt nDim,
class SysEqn>
2463 mAlloc(bndryCndHandlerVariables, m_maxNoBndryCndIds,
"bndryCndHandlerVariables", AT_);
2466 mAlloc(bndryCndHandlerSpongeVariables,
mMax(1, m_noSpongeBndryCndIds),
"bndryCndHandlerSpongeVariables", AT_);
2469 mAlloc(bndryCndHandlerCutOffVariables, m_maxNoBndryCndIds,
"bndryCndHandlerCutOffVariables", AT_);
2477 mDeallocate(nonReflectingCutOffBoundaryCondition);
2478 mAlloc(nonReflectingCutOffBoundaryCondition, m_maxNoBndryCndIds,
"nonReflectingCutOffBoundaryCondition", AT_);
2480 mDeallocate(nonReflectingBoundaryConditionAfterTreatmentCutOff);
2481 mAlloc(nonReflectingBoundaryConditionAfterTreatmentCutOff, m_maxNoBndryCndIds,
2482 "nonReflectingBoundaryConditionAfterTreatmentCutOff", AT_);
2485 mAlloc(bndryCndHandlerCutOffSlopesInviscid, m_maxNoBndryCndIds,
"bndryCndHandlerCutOffSlopesInviscid", AT_);
2488 mAlloc(bndryCndHandlerSlopesInviscid, m_maxNoBndryCndIds,
"bndryCndHandlerSlopesInviscid", AT_);
2491 mAlloc(bndryViscousSlopes, m_maxNoBndryCndIds,
"bndryViscousSlopes", AT_);
2494 mAlloc(bndryCutOffViscousSlopes, m_maxNoBndryCndIds,
"bndryCutOffViscousSlopes", AT_);
2497 mAlloc(bndryCndHandlerInit, m_maxNoBndryCndIds,
"bndryCndHandlerInit", AT_);
2500 mAlloc(bndryCndHandlerNeumann, m_maxNoBndryCndIds,
"bndryCndHandlerNeumann", AT_);
2502 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++) {
2509 switch(m_cutOffBndryCndIds[bcId]) {
2648 if(!m_solver->m_engineSetup) {
2652 IF_CONSTEXPR(nDim == 3) {
2943 else mTerm(1, AT_,
"BC7902 only works with a SysEqn that has PV->N");
2952 else mTerm(1, AT_,
"BC7905 only works with a SysEqn that has PV->N");
2959 else mTerm(1, AT_,
"BC7908 only works for LES");
2966 else mTerm(1, AT_,
"BC7908 only works for LES");
2978 stringstream errorMessage;
2979 errorMessage <<
"ERROR: Switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
2980 <<
" not matching any case." << endl;
2981 mTerm(1, AT_, errorMessage.str());
2986 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
2987 switch(m_bndryCndIds[bcId]) {
2993 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
2994 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc1000;
3002 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3003 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc1000;
3022 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3023 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<0>;
3030 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3031 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<0>;
3039 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3040 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<1>;
3049 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3050 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<1>;
3058 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3059 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<0>;
3067 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3068 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2901<0>;
3076 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3077 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2901<0>;
3085 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3086 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2901<1>;
3090 IF_CONSTEXPR(nDim == 3) {
3095 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3096 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2901<2>;
3108 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3109 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<0>;
3117 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3118 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<1>;
3121 IF_CONSTEXPR(nDim == 3) {
3126 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3127 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<2>;
3139 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3140 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<2>;
3148 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3149 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<0>;
3157 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3158 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<0>;
3166 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3167 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<0>;
3173 if(m_multipleGhostCells) {
3179 if(m_multipleGhostCells) {
3180 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<true>;
3182 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3185 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3186 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc1000;
3193 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3195 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3196 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc1000;
3201 if(m_multipleGhostCells) {
3202 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<true>;
3204 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3207 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3208 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc1000;
3215 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3216 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<false>;
3224 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3225 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc1000;
3229 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3233 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3234 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc1000;
3240 if(m_multipleGhostCells) {
3241 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<true>;
3243 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3248 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3250 if(m_multipleGhostCells) {
3251 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<true>;
3253 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<false>;
3256 if(m_bndryCndIds[bcId] == 3002) {
3261 if(m_multipleGhostCells) {
3262 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<true>;
3264 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3269 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3271 if(m_multipleGhostCells) {
3272 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<true>;
3274 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<false>;
3277 if(m_bndryCndIds[bcId] == 30021) {
3282 if(m_multipleGhostCells) {
3283 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<true>;
3285 bndryCndHandlerVariables[bcId] = &FvBndryCndXD::bc3399<true>;
3286 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<true>;
3288 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3290 bndryCndHandlerVariables[bcId] = &FvBndryCndXD::bc3399<false>;
3291 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<false>;
3293 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3307 if(m_multipleGhostCells) {
3308 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<true>;
3310 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3313 if(m_multipleGhostCells) {
3318 if(m_multipleGhostCells) {
3319 if(m_bndryCndIds[bcId] == 3003 || m_bndryCndIds[bcId] == 3009) {
3320 bndryCndHandlerVariables[bcId] = &FvBndryCndXD::bc3003<true>;
3321 }
else if(m_bndryCndIds[bcId] == 3037) {
3325 if(m_bndryCndIds[bcId] == 4000) {
3327 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit4000<true>;
3328 }
else if(m_bndryCndIds[bcId] == 4001) {
3330 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit4000<true>;
3332 bndryCndHandlerVariables[bcId] = &FvBndryCndXD::bc3003<false>;
3335 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3336 if(m_multipleGhostCells) {
3337 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<true>;
3339 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<false>;
3344 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3348 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3349 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<false>;
3357 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3358 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<false>;
3364 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3367 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3368 if(m_multipleGhostCells) {
3369 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<true>;
3371 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2000<false>;
3381 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3399 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3419 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3429 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3436 bndryCndHandlerInit[bcId] = &FvBndryCndXD::bcInit0002<false>;
3440 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3441 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc1000;
3448 if(m_bndryCndIds[bcId] == 1101) {
3450 }
else if(m_bndryCndIds[bcId] == 1102) {
3456 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3457 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<0>;
3462 if(m_bndryCndIds[bcId] == 1111) {
3464 }
else if(m_bndryCndIds[bcId] == 1112) {
3470 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3471 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<1>;
3476 if(m_bndryCndIds[bcId] == 1121) {
3478 }
else if(m_bndryCndIds[bcId] == 1122) {
3484 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3485 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc2001<2>;
3498 else mTerm(1, AT_, to_string(m_cutOffBndryCndIds[bcId]) +
" only works for LES");
3500 bndryCndHandlerSlopesInviscid[bcId] = &FvBndryCndXD::sbc1000;
3501 bndryViscousSlopes[bcId] = &FvBndryCndXD::sbc1000;
3506 "This boundary condition id was only used for the ghost fluid solver, which has been removed in Nov. "
3507 "2012. There is an alternative b.c. id that uses the same methods (minus the GF stuff): 4000");
3512 "This boundary condition id was only used for the ghost fluid solver, which has been removed in Nov. "
3513 "2012. There is an alternative b.c. id that uses the same methods (minus the GF stuff): 4001");
3517 std::stringstream errorMsg;
3518 errorMsg <<
"FvBndryCndXD::initBndryCells error" << std::endl
3519 <<
"#" << bcId <<
" Unknown Boundary Condition Id: " << m_bndryCndIds[bcId] << std::endl;
3520 mTerm(1, AT_, errorMsg.str());
3560template <MInt nDim,
class SysEqn>
3564 MBool spongeCellsFound =
false;
3565 MBool append =
false;
3566 MInt bcSpId, spongeCellId;
3567 MInt noBndryCells = m_bndryCells->size();
3568 MInt s1 = -1, s2 = -1, s3 = -1;
3569 MFloat spongeCoordMin2 = F0, spongeCoordMax2 = F0, spongeCoordMin = F0, spongeCoordMax = F0, spongeCoordFace = F0;
3570 MInt cellId, currentSpongeCellId, oldSortedSpongeBndryCellsSize;
3571 MFloat maxSpongeFactor = 0.0, minSpongeFactor = 100.0, maxSpongeFactorOverlap = 0.0, minSpongeFactorOverlap = 100.0;
3572 MFloat cellFaceCoordinate = -11111.0;
3573 MFloat halfCellWidth = F1B2 * m_solver->c_cellLengthAtLevel(m_solver->maxRefinementLevel());
3576 MInt cntHaloInside = 0;
3580 m_solver->m_noCellsInsideSpongeLayer = 0;
3581 m_sortedSpongeBndryCells->setSize(0);
3582 for(
MInt bcId = 0; bcId < m_noSpongeBndryCndIds; bcId++)
3583 m_spongeBndryCells[bcId] = 0;
3586 for(
MInt c = 0; c < m_solver->a_noCells(); c++) {
3587 m_solver->a_hasProperty(c, SolverCell::IsInSpongeLayer) =
false;
3588 m_solver->a_spongeFactor(c) = F0;
3591 std::vector<MFloat> minSpongeCoords(2 * m_noSpongeBndryCndIds);
3592 std::vector<MFloat> maxSpongeCoords(2 * m_noSpongeBndryCndIds);
3595 for(
MInt bcId = 0; bcId < m_noSpongeBndryCndIds; bcId++) {
3596 bcSpId = m_spongeBndryCndIds[bcId];
3597 spongeCellsFound =
false;
3598 spongeCoordMin = 10000;
3599 spongeCoordMax = -10000;
3600 spongeCoordMin2 = 10000;
3601 spongeCoordMax2 = -10000;
3602 spongeCoordFace = -99999999.0;
3603 m_spongeCoord[bcId] = -99999999.0;
3604 cellFaceCoordinate = -11111.0;
3605 m_log <<
"*************************************************************" << endl;
3606 m_log <<
"Information for sponge boundary Id: " << bcSpId << endl;
3607 m_log <<
"*************************************************************" << endl;
3609 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
3611 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
3612 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == bcSpId) {
3618 spongeCellId = m_bndryCells->a[bndryId].m_cellId;
3619 m_sortedSpongeBndryCells->a[m_sortedSpongeBndryCells->size()] = spongeCellId;
3620 m_sortedSpongeBndryCells->append();
3621 spongeCellsFound =
true;
3622 m_solver->a_hasProperty(spongeCellId, SolverCell::IsInSpongeLayer) =
true;
3625 if(spongeCellsFound) {
3626 m_log <<
"Collecting " << m_sortedSpongeBndryCells->size() - m_spongeBndryCells[bcId]
3627 <<
" sponge cells at the boundary ... ";
3628 m_spongeBndryCells[bcId + 1] = m_sortedSpongeBndryCells->size();
3629 m_log <<
" ok" << endl;
3632 if(!spongeCellsFound) {
3634 for(
MInt bcCut = 0; bcCut < m_noCutOffBndryCndIds; bcCut++) {
3635 if(bcSpId != m_cutOffBndryCndIds[bcCut])
continue;
3636 spongeCellsFound =
true;
3637 m_log <<
"Collecting ";
3638 for(
MInt id = 0;
id < m_sortedCutOffCells[bcCut]->size();
id++) {
3639 spongeCellId = m_sortedCutOffCells[bcCut]->a[
id];
3640 m_sortedSpongeBndryCells->a[m_sortedSpongeBndryCells->size()] = spongeCellId;
3641 m_sortedSpongeBndryCells->append();
3642 m_solver->a_hasProperty(spongeCellId, SolverCell::IsInSpongeLayer) =
true;
3644 m_spongeBndryCells[bcId + 1] = m_sortedSpongeBndryCells->size();
3645 m_log << m_sortedSpongeBndryCells->size() - m_spongeBndryCells[bcId]
3646 <<
" sponge cells at the cut-off boundary ... ";
3647 m_log <<
" ok" << endl;
3652 if(!spongeCellsFound || ((m_sortedSpongeBndryCells->size() - m_spongeBndryCells[bcId]) == 0)) {
3653 m_log <<
"sponge cells not yet found on domain " << domainId() << endl;
3654 m_spongeBndryCells[bcId + 1] = m_spongeBndryCells[bcId];
3657 m_spongeFactor[bcId] = abs(m_spongeFactor[bcId]);
3660 switch(m_spongeDirections[bcId]) {
3662 m_log <<
"POSITIVE_XWALL" << endl;
3667 m_spongeFactor[bcId] = -m_spongeFactor[bcId];
3670 m_log <<
"NEGATIVE_XWALL" << endl;
3677 m_log <<
"POSITIVE_YWALL" << endl;
3682 m_spongeFactor[bcId] = -m_spongeFactor[bcId];
3685 m_log <<
"NEGATIVE_YWALL" << endl;
3692 m_log <<
"POSITIVE_ZWALL" << endl;
3697 m_spongeFactor[bcId] = -m_spongeFactor[bcId];
3700 m_log <<
"NEGATIVE_ZWALL" << endl;
3707 mTerm(1, AT_,
"wrong sponge direction selected");
3710 TERMM_IF_COND(vz != 0 && vz != 1,
"ERROR: invalid coordinate orientation of sponge vz = " + std::to_string(vz));
3712 IF_CONSTEXPR(nDim == 3) {
3714 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
3715 cellId = m_sortedSpongeBndryCells->a[
id];
3716 cellFaceCoordinate = m_solver->a_coordinate(cellId, s3) - F1B2 * m_solver->c_cellLengthAtCell(cellId);
3717 spongeCoordMin2 =
mMin(spongeCoordMin2, cellFaceCoordinate);
3721 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
3722 cellId = m_sortedSpongeBndryCells->a[
id];
3723 cellFaceCoordinate = m_solver->a_coordinate(cellId, s3) + F1B2 * m_solver->c_cellLengthAtCell(cellId);
3724 spongeCoordMax2 =
mMax(spongeCoordMax2, cellFaceCoordinate);
3728 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
3729 cellId = m_sortedSpongeBndryCells->a[
id];
3730 cellFaceCoordinate = m_solver->a_coordinate(cellId, s1) - F1B2 * m_solver->c_cellLengthAtCell(cellId);
3731 spongeCoordMin =
mMin(spongeCoordMin, cellFaceCoordinate);
3735 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
3736 cellId = m_sortedSpongeBndryCells->a[
id];
3737 halfCellWidth = F1B2 * m_solver->c_cellLengthAtCell(cellId);
3738 cellFaceCoordinate = m_solver->a_coordinate(cellId, s1) + halfCellWidth;
3739 if(spongeCoordMax < cellFaceCoordinate) {
3740 spongeCoordMax = cellFaceCoordinate;
3741 if(m_spongeFactor[bcId] > 0) {
3742 m_spongeCoord[bcId] =
3743 m_solver->a_coordinate(cellId, s2) + m_spongeLayerThickness * m_spongeFactor[bcId] - halfCellWidth;
3744 spongeCoordFace = m_solver->a_coordinate(cellId, s2) - halfCellWidth;
3746 m_spongeCoord[bcId] =
3747 m_solver->a_coordinate(cellId, s2) + m_spongeLayerThickness * m_spongeFactor[bcId] + halfCellWidth;
3748 spongeCoordFace = m_solver->a_coordinate(cellId, s2) + halfCellWidth;
3753 if(noDomains() == 1) {
3754 if(
approx(spongeCoordMin2, 10000.0, MFloatEps) ||
approx(spongeCoordMax2, -10000.0, MFloatEps)
3755 ||
approx(spongeCoordMin, 10000.0, MFloatEps) ||
approx(spongeCoordMax, -10000.0, MFloatEps)
3756 ||
approx(m_spongeCoord[bcId], -111111.0, MFloatEps)) {
3757 cerr <<
"Warning: sponge boundary Id " << bcSpId <<
" info ( rank " << domainId() <<
" ): " << endl;
3758 cerr <<
"Warning: boundary cell edge couldn't be found" << endl;
3759 cerr <<
"sponge edge coordinate[" << s3 <<
"] = " << spongeCoordMin2 << endl;
3760 cerr <<
"sponge edge coordinate[" << s3 <<
"] = " << spongeCoordMax2 << endl;
3761 cerr <<
"sponge edge coordinate[" << s1 <<
"] = " << spongeCoordMin << endl;
3762 cerr <<
"sponge edge coordinate[" << s1 <<
"] = " << spongeCoordMax << endl;
3763 cerr <<
"sponge cells defined up to coordinate[" << s2 <<
"] = " << m_spongeCoord[bcId] << endl;
3764 mTerm(1, AT_,
"Warning: boundary cell edge couldn't be found");
3770 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
3771 cellId = m_sortedSpongeBndryCells->a[
id];
3772 cellFaceCoordinate = m_solver->a_coordinate(cellId, s1) - F1B2 * m_solver->c_cellLengthAtCell(cellId);
3773 spongeCoordMin =
mMin(spongeCoordMin, cellFaceCoordinate);
3777 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
3778 cellId = m_sortedSpongeBndryCells->a[
id];
3779 halfCellWidth = F1B2 * m_solver->c_cellLengthAtCell(cellId);
3780 cellFaceCoordinate = m_solver->a_coordinate(cellId, s1) + halfCellWidth;
3781 if(spongeCoordMax < cellFaceCoordinate) {
3782 spongeCoordMax = cellFaceCoordinate;
3783 if(m_spongeFactor[bcId] > 0) {
3784 m_spongeCoord[bcId] =
3785 m_solver->a_coordinate(cellId, s2) + m_spongeLayerThickness * m_spongeFactor[bcId] - halfCellWidth;
3786 spongeCoordFace = m_solver->a_coordinate(cellId, s2) - halfCellWidth;
3788 m_spongeCoord[bcId] =
3789 m_solver->a_coordinate(cellId, s2) + m_spongeLayerThickness * m_spongeFactor[bcId] + halfCellWidth;
3790 spongeCoordFace = m_solver->a_coordinate(cellId, s2) + halfCellWidth;
3794 if(noDomains() == 1) {
3795 if(
approx(spongeCoordMin, 10000.0, MFloatEps) ||
approx(spongeCoordMax, -10000.0, MFloatEps)
3796 ||
approx(m_spongeCoord[bcId], -111111.0, MFloatEps)) {
3797 mTerm(1, AT_,
" boundary cell edge couldn't be found");
3804 MPI_Allreduce(MPI_IN_PLACE, &spongeCoordMin, 1, MPI_DOUBLE, MPI_MIN, mpiComm(), AT_,
"MPI_IN_PLACE",
3806 MPI_Allreduce(MPI_IN_PLACE, &spongeCoordMax, 1, MPI_DOUBLE, MPI_MAX, mpiComm(), AT_,
"MPI_IN_PLACE",
3808 IF_CONSTEXPR(nDim == 3) {
3809 MPI_Allreduce(MPI_IN_PLACE, &spongeCoordMin2, 1, MPI_DOUBLE, MPI_MIN, mpiComm(), AT_,
"MPI_IN_PLACE",
3811 MPI_Allreduce(MPI_IN_PLACE, &spongeCoordMax2, 1, MPI_DOUBLE, MPI_MAX, mpiComm(), AT_,
"MPI_IN_PLACE",
3814 MPI_Allreduce(MPI_IN_PLACE, &m_spongeCoord[bcId], 1, MPI_DOUBLE, MPI_MAX, mpiComm(), AT_,
"MPI_IN_PLACE",
3815 "m_spongeCoord[ bcId ]");
3816 MPI_Allreduce(MPI_IN_PLACE, &spongeCoordFace, 1, MPI_DOUBLE, MPI_MAX, mpiComm(), AT_,
"MPI_IN_PLACE",
3819 IF_CONSTEXPR(nDim == 3) {
3820 m_log <<
"sponge edge coordinate[" << s3 <<
"] = " << spongeCoordMin2 << endl;
3821 m_log <<
"sponge edge coordinate[" << s3 <<
"] = " << spongeCoordMax2 << endl;
3823 m_log <<
"sponge edge coordinate[" << s1 <<
"] = " << spongeCoordMin << endl;
3824 m_log <<
"sponge edge coordinate[" << s1 <<
"] = " << spongeCoordMax << endl;
3825 m_log <<
"sponge face coordinate[" << s2 <<
"] = " << spongeCoordFace << endl;
3826 m_log <<
"sponge cells defined up to coordinate[" << s2 <<
"] = " << m_spongeCoord[bcId] << endl;
3828 minSpongeCoords[2 * bcId] = spongeCoordMin;
3829 minSpongeCoords[2 * bcId + 1] = spongeCoordMin2;
3830 maxSpongeCoords[2 * bcId] = spongeCoordMax;
3831 maxSpongeCoords[2 * bcId + 1] = spongeCoordMax2;
3835 const MInt dir = m_spongeDirections[bcId];
3836 MBool isAdditionalSpongeInDir =
false;
3837 MInt firstSpongeBcIdInDir = -1;
3838 MInt firstSpongeIdInDir = -1;
3839 for(
MInt i = 0; i < bcId; i++) {
3840 if(m_spongeDirections[i] == dir) {
3841 isAdditionalSpongeInDir =
true;
3842 firstSpongeBcIdInDir = m_spongeBndryCndIds[i];
3843 firstSpongeIdInDir = i;
3847 if(isAdditionalSpongeInDir) {
3848 m_log <<
"additional sponge in direction " << dir <<
", skipping cells with BC " << firstSpongeBcIdInDir
3849 <<
" intersection" << std::endl;
3853 m_log <<
"Creating ";
3854 oldSortedSpongeBndryCellsSize = m_spongeBndryCells[bcId + 1];
3856 for(
MInt id = 0;
id < m_solver->a_noCells();
id++) {
3858 if(m_solver->a_hasProperty(
id, SolverCell::IsInSpongeLayer))
continue;
3859 if(m_solver->c_noChildren(
id) > 0)
continue;
3861 if(vz == 0 && m_solver->a_coordinate(
id, s2) < m_spongeCoord[bcId])
continue;
3862 if(vz == 1 && m_solver->a_coordinate(
id, s2) > m_spongeCoord[bcId])
continue;
3864 if(m_solver->a_coordinate(
id, s1) > spongeCoordMax)
continue;
3865 if(m_solver->a_coordinate(
id, s1) < spongeCoordMin)
continue;
3866 IF_CONSTEXPR(nDim == 3) {
3867 if(m_solver->a_coordinate(
id, s3) > spongeCoordMax2)
continue;
3868 if(m_solver->a_coordinate(
id, s3) < spongeCoordMin2)
continue;
3872 if(isAdditionalSpongeInDir) {
3873 std::set<MInt> bcIds;
3875 const MFloat halfLength = 0.5 * m_solver->c_cellLengthAtCell(
id);
3880 MBool insideBox =
true;
3882 const MFloat pos1 = m_solver->a_coordinate(
id, s1);
3883 const MFloat pos2 = m_solver->a_coordinate(
id, s3);
3884 const MInt offset = 2 * firstSpongeIdInDir;
3885 if(pos1 + halfLength < minSpongeCoords[offset] || pos1 - halfLength > maxSpongeCoords[offset]) {
3887 }
else if(pos2 + halfLength < minSpongeCoords[offset + 1]
3888 || pos2 - halfLength > maxSpongeCoords[offset + 1]) {
3895 const MFloat outDir = (vz == 0) ? 1.0 : -1.0;
3896 for(
MInt i = 0; i < 2 && !skip; i++) {
3897 for(
MInt j = 0; j < (nDim - 1) && !skip; j++) {
3898 std::copy_n(&m_solver->a_coordinate(
id, 0), nDim, &line[0]);
3899 std::copy_n(&m_solver->a_coordinate(
id, 0), nDim, &line[nDim]);
3901 line[s2] = line[s2] + outDir * 2 * m_solver->c_cellLengthAtLevel(0);
3903 line[s1] -= pow(-1.0, i) * halfLength;
3904 line[s1 + nDim] = line[s1];
3906 IF_CONSTEXPR(nDim == 3) {
3907 line[s3] -= pow(-1.0, j) * halfLength;
3908 line[s3 + nDim] = line[s3];
3913 m_solver->m_geometry->getLineIntersectingElementsBcIds(line, bcIds);
3914 if(bcIds.size() > 0 && (bcIds.count(firstSpongeBcIdInDir) > 0)) {
3923 m_sortedSpongeBndryCells->a[m_sortedSpongeBndryCells->size()] =
id;
3924 m_sortedSpongeBndryCells->append();
3926 m_spongeBndryCells[bcId + 1] = m_sortedSpongeBndryCells->size();
3928 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
3929 currentSpongeCellId = m_sortedSpongeBndryCells->a[
id];
3930 m_solver->a_hasProperty(currentSpongeCellId, SolverCell::IsInSpongeLayer) =
false;
3933 if(noDomains() == 0) {
3934 if(oldSortedSpongeBndryCellsSize == m_sortedSpongeBndryCells->size()) {
3935 m_log <<
"Warning: Only first row of sponge boundary ID " << m_spongeBndryCndIds[bcId]
3936 <<
" was identified as sponge cells" << endl;
3937 m_log <<
" Possible reason could be that the spongeFactor has to be multiplied by -1" << endl;
3938 m_log <<
" Possible reason could be wrong sponge coordinates communicated" << endl;
3939 cerr <<
"Warning: Only first row of sponge boundary ID " << m_spongeBndryCndIds[bcId]
3940 <<
" was identified as sponge cells" << endl;
3941 cerr <<
" Possible reason could be that the spongeFactor has to be multiplied by -1" << endl;
3942 cerr <<
" Possible reason could be wrong sponge coordinates communicated" << endl;
3945 m_log << m_sortedSpongeBndryCells->size() - oldSortedSpongeBndryCellsSize <<
" additional sponge cells ... ";
3946 m_log <<
" ok" << endl;
3947 m_spongeBndryCells[bcId + 1] = m_sortedSpongeBndryCells->size();
3948 m_log <<
"total number of sponge cells " << m_spongeBndryCells[bcId + 1] - m_spongeBndryCells[bcId] << endl;
3949 m_log <<
"*************************************************" << endl << endl;
3951 MInt endBcId = bcId;
3955 for(
MInt id = m_spongeBndryCells[startBcId];
id < m_spongeBndryCells[endBcId];
id++) {
3956 spongeCellId = m_sortedSpongeBndryCells->a[
id];
3957 m_solver->a_hasProperty(spongeCellId, SolverCell::IsInSpongeLayer) =
true;
3960 switch(m_spongeLayerLayout) {
3962 const MFloat spongeThicknessEpsilon = m_spongeLayerThickness / 10000000.0;
3963 MFloat spongeEpsilon = m_solver->c_cellLengthAtLevel(m_solver->maxRefinementLevel()) / 1000.0;
3964 MFloat beta = m_spongeBeta;
3966 MFloat spongeFactorBcId = m_spongeLayerThickness * abs(m_spongeFactor[bcId]);
3967 MFloat spongeDistanceFactor = F1 / (
mMax(spongeEpsilon, spongeFactorBcId));
3968 MFloat spongeDistance = F0;
3970 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
3971 bcSpId = m_spongeBndryCndIds[bcId];
3972 spongeCellId = m_sortedSpongeBndryCells->a[
id];
3973 if(m_solver->a_isHalo(spongeCellId)) cntHalo++;
3975 if(m_solver->a_hasProperty(spongeCellId, SolverCell::IsInSpongeLayer)) {
3977 spongeDistance = abs(m_solver->a_coordinate(spongeCellId, s2) - m_spongeCoord[bcId]) * spongeDistanceFactor;
3978 distance.p[spongeCellId] =
mMax(distance.p[spongeCellId], spongeDistance);
3983 constant = pow(distance.p[spongeCellId], beta);
3984 constant *= m_sigmaSpongeBndryId[bcId];
3987 if(distance.p[spongeCellId] > spongeThicknessEpsilon) {
3988 if(m_solver->a_spongeBndryId(spongeCellId, 1) == -1) {
3990 m_solver->a_spongeBndryId(spongeCellId, 1) = bcSpId;
3992 m_solver->a_spongeFactor(spongeCellId) =
mMax(constant, m_solver->a_spongeFactor(spongeCellId));
3993 }
else if(nDim == 3 && m_solver->a_spongeBndryId(spongeCellId, 2) == -1) {
3996 m_solver->a_spongeBndryId(spongeCellId, 2) = bcSpId;
3997 m_solver->a_spongeFactor(spongeCellId) =
mMax(constant, m_solver->a_spongeFactor(spongeCellId));
3998 if(!m_solver->a_isHalo(spongeCellId)) count++;
3999 IF_CONSTEXPR(nDim == 2) {
4000 cerr <<
"ERROR: three sponge boundary Ids: " << m_solver->a_spongeBndryId(spongeCellId, 0) <<
", "
4001 << m_solver->a_spongeBndryId(spongeCellId, 1) <<
", ";
4002 cerr << m_solver->a_spongeBndryId(spongeCellId, 2)
4003 <<
"founded for one cell -> not possible for 2 dimensional case" << endl;
4004 stringstream errorMessage;
4005 errorMessage <<
" three sponge boundary Ids: " << m_solver->a_spongeBndryId(spongeCellId, 0) <<
", "
4006 << m_solver->a_spongeBndryId(spongeCellId, 1) <<
", "
4007 << m_solver->a_spongeBndryId(spongeCellId, 2)
4008 <<
"founded for one cell -> not possible for 2 dimensional case";
4009 mTerm(1, AT_, errorMessage.str());
4012 stringstream errorMessage;
4013 IF_CONSTEXPR(nDim == 3) {
4014 errorMessage <<
"four sponge boundary Ids: " << m_solver->a_spongeBndryId(spongeCellId, 0) <<
", "
4015 << m_solver->a_spongeBndryId(spongeCellId, 1) <<
", "
4016 << m_solver->a_spongeBndryId(spongeCellId, 2) <<
", " << bcSpId
4017 <<
"founded for one cell -> not possible for 3 dimensional case";
4020 errorMessage <<
"three sponge boundary Ids: " << m_solver->a_spongeBndryId(spongeCellId, 0) <<
", "
4021 << m_solver->a_spongeBndryId(spongeCellId, 1) <<
", " << bcSpId
4022 <<
"founded for one cell -> not possible for 2 dimensional case";
4024 mTerm(1, AT_, errorMessage.str());
4026 if(m_solver->m_spongeTimeDependent[bcId] > 0)
4027 m_solver->a_spongeFactorStart(spongeCellId) = m_solver->a_spongeFactor(spongeCellId);
4029 maxSpongeFactorOverlap =
mMax(maxSpongeFactorOverlap, m_solver->a_spongeFactor(spongeCellId));
4030 minSpongeFactorOverlap =
mMin(minSpongeFactorOverlap, m_solver->a_spongeFactor(spongeCellId));
4036 m_solver->a_spongeFactor(spongeCellId) = F0;
4038 distance.p[spongeCellId] =
4039 abs(m_solver->a_coordinate(spongeCellId, s2) - m_spongeCoord[bcId]) * spongeDistanceFactor;
4044 constant = pow(distance.p[spongeCellId], beta);
4045 constant *= m_sigmaSpongeBndryId[bcId];
4047 if(distance.p[spongeCellId] > spongeThicknessEpsilon) {
4048 m_solver->m_cellsInsideSpongeLayer[m_solver->m_noCellsInsideSpongeLayer] = spongeCellId;
4049 m_solver->m_noCellsInsideSpongeLayer++;
4050 if(m_solver->a_isHalo(spongeCellId)) cntHaloInside++;
4052 m_solver->a_hasProperty(spongeCellId, SolverCell::IsInSpongeLayer) =
true;
4053 m_solver->a_spongeFactor(spongeCellId) = constant;
4054 if(m_solver->m_spongeTimeDependent[bcId] > 0) m_solver->a_spongeFactorStart(spongeCellId) = constant;
4056 m_solver->a_spongeBndryId(spongeCellId, 0) = bcSpId;
4057 m_solver->a_spongeBndryId(spongeCellId, 1) =
4060 IF_CONSTEXPR(nDim == 3) {
4061 m_solver->a_spongeBndryId(spongeCellId, 2) =
4069 maxSpongeFactor =
mMax(maxSpongeFactor, m_solver->a_spongeFactor(spongeCellId));
4070 minSpongeFactor =
mMin(minSpongeFactor, m_solver->a_spongeFactor(spongeCellId));
4078 const MFloat spongeThicknessEpsilon = m_spongeLayerThickness / 10000000.0;
4079 MFloat spongeEpsilon = m_solver->c_cellLengthAtLevel(m_solver->maxRefinementLevel()) / 1000.0;
4081 MFloat spongeFactorBcId = m_spongeLayerThickness * abs(m_spongeFactor[bcId]);
4082 MFloat spongeDistanceFactor = F1 / (
mMax(spongeEpsilon, spongeFactorBcId));
4083 MFloat spongeDistance = F0;
4090 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
4091 bcSpId = m_spongeBndryCndIds[bcId];
4092 spongeCellId = m_sortedSpongeBndryCells->a[
id];
4093 if(m_solver->a_isHalo(spongeCellId)) cntHalo++;
4095 if(m_solver->a_hasProperty(spongeCellId, SolverCell::IsInSpongeLayer)) {
4097 spongeDistance = abs(m_solver->a_coordinate(spongeCellId, s2) - m_spongeCoord[bcId]) * spongeDistanceFactor;
4098 distance.p[spongeCellId] =
mMax(distance.p[spongeCellId], spongeDistance);
4100 constant = F1 - F1B2 * tanh(5.0) + F1B2 * tanh((F2 * (distance.p[spongeCellId]) - F1) * 5.0);
4101 constant *= m_sigmaSpongeBndryId[bcId];
4103 if(distance.p[spongeCellId] > spongeThicknessEpsilon) {
4104 if(m_solver->a_spongeBndryId(spongeCellId, 1) == -1) {
4106 m_solver->a_spongeBndryId(spongeCellId, 1) = bcSpId;
4108 m_solver->a_spongeFactor(spongeCellId) =
mMax(constant, m_solver->a_spongeFactor(spongeCellId));
4109 }
else if(nDim == 3 && m_solver->a_spongeBndryId(spongeCellId, 2) == -1) {
4112 m_solver->a_spongeBndryId(spongeCellId, 2) = bcSpId;
4113 m_solver->a_spongeFactor(spongeCellId) =
mMax(constant, m_solver->a_spongeFactor(spongeCellId));
4114 if(!m_solver->a_isHalo(spongeCellId)) count++;
4115 IF_CONSTEXPR(nDim == 2) {
4116 cerr <<
"ERROR: three sponge boundary Ids: " << m_solver->a_spongeBndryId(spongeCellId, 0) <<
", "
4117 << m_solver->a_spongeBndryId(spongeCellId, 1) <<
", ";
4118 cerr << m_solver->a_spongeBndryId(spongeCellId, 2)
4119 <<
"founded for one cell -> not possible for 2 dimensional case" << endl;
4123 cerr <<
"ERROR: four sponge boundary Ids: " << m_solver->a_spongeBndryId(spongeCellId, 0) <<
", "
4124 << m_solver->a_spongeBndryId(spongeCellId, 1) <<
", ";
4125 cerr << m_solver->a_spongeBndryId(spongeCellId, 2) <<
", " << bcSpId
4126 <<
"founded for one cell -> not possible for 3 dimensional case" << endl;
4130 if(m_solver->m_spongeTimeDependent[bcId] > 0)
4131 m_solver->a_spongeFactorStart(spongeCellId) = m_solver->a_spongeFactor(spongeCellId);
4133 maxSpongeFactorOverlap =
mMax(maxSpongeFactorOverlap, m_solver->a_spongeFactor(spongeCellId));
4134 minSpongeFactorOverlap =
mMin(minSpongeFactorOverlap, m_solver->a_spongeFactor(spongeCellId));
4140 m_solver->a_spongeFactor(spongeCellId) = F0;
4142 distance.p[spongeCellId] =
4143 abs(m_solver->a_coordinate(spongeCellId, s2) - m_spongeCoord[bcId]) * spongeDistanceFactor;
4146 F1 - F1B2 * tanh(5.0) + F1B2 * tanh((F2 * (distance.p[spongeCellId]) - F1) * 5.0);
4150 constant *= m_sigmaSpongeBndryId[bcId];
4152 if(distance.p[spongeCellId] > spongeThicknessEpsilon) {
4153 m_solver->m_cellsInsideSpongeLayer[m_solver->m_noCellsInsideSpongeLayer] = spongeCellId;
4154 m_solver->m_noCellsInsideSpongeLayer++;
4155 if(m_solver->a_isHalo(spongeCellId)) cntHaloInside++;
4157 m_solver->a_hasProperty(spongeCellId, SolverCell::IsInSpongeLayer) =
true;
4158 m_solver->a_spongeFactor(spongeCellId) = constant;
4159 if(m_solver->m_spongeTimeDependent[bcId] > 0) m_solver->a_spongeFactorStart(spongeCellId) = constant;
4161 m_solver->a_spongeBndryId(spongeCellId, 0) = bcSpId;
4162 m_solver->a_spongeBndryId(spongeCellId, 1) =
4165 IF_CONSTEXPR(nDim == 3) {
4166 m_solver->a_spongeBndryId(spongeCellId, 2) =
4174 maxSpongeFactor =
mMax(maxSpongeFactor, m_solver->a_spongeFactor(spongeCellId));
4175 minSpongeFactor =
mMin(minSpongeFactor, m_solver->a_spongeFactor(spongeCellId));
4182 stringstream errorMessage;
4183 errorMessage <<
"ERROR: spongeLayerLayout " << m_spongeLayerLayout <<
" does not exist!" << endl;
4184 mTerm(1, AT_, errorMessage.str());
4188 for(
MInt id = m_spongeBndryCells[startBcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
4189 spongeCellId = m_sortedSpongeBndryCells->a[
id];
4190 m_solver->a_hasProperty(spongeCellId, SolverCell::IsInSpongeLayer) =
false;
4193 MInt noHaloSpongeCells = cntHalo;
4194 MInt noSpongeCells = m_spongeBndryCells[m_noSpongeBndryCndIds] - cntHalo;
4195 MInt noInternalSpongeCells = m_solver->m_noCellsInsideSpongeLayer - cntHaloInside;
4196 MInt noOverlappingSpongeCells3d = count;
4198 MPI_Allreduce(MPI_IN_PLACE, &noHaloSpongeCells, 1, MPI_INT, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
4199 "noHaloSpongeCells");
4200 MPI_Allreduce(MPI_IN_PLACE, &noSpongeCells, 1, MPI_INT, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
"noSpongeCells");
4201 MPI_Allreduce(MPI_IN_PLACE, &noInternalSpongeCells, 1, MPI_INT, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
4202 "noInternalSpongeCells");
4204 IF_CONSTEXPR(nDim == 3)
4205 MPI_Allreduce(MPI_IN_PLACE, &noOverlappingSpongeCells3d, 1, MPI_INT, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
4206 "noOverlappingSpongeCells3d");
4207 MPI_Allreduce(MPI_IN_PLACE, &maxSpongeFactor, 1, MPI_DOUBLE, MPI_MAX, mpiComm(), AT_,
"MPI_IN_PLACE",
4209 MPI_Allreduce(MPI_IN_PLACE, &minSpongeFactor, 1, MPI_DOUBLE, MPI_MIN, mpiComm(), AT_,
"MPI_IN_PLACE",
4211 MPI_Allreduce(MPI_IN_PLACE, &maxSpongeFactorOverlap, 1, MPI_DOUBLE, MPI_MAX, mpiComm(), AT_,
"MPI_IN_PLACE",
4212 "maxSpongeFactorOverlap");
4213 MPI_Allreduce(MPI_IN_PLACE, &minSpongeFactorOverlap, 1, MPI_DOUBLE, MPI_MIN, mpiComm(), AT_,
"MPI_IN_PLACE",
4214 "minSpongeFactorOverlap");
4216 m_log <<
"*********************" << endl;
4217 m_log <<
"Sponge cell summary" << endl;
4218 m_log <<
"*********************" << endl;
4219 m_log << noSpongeCells <<
" sponge cells + " << endl;
4220 m_log << noHaloSpongeCells <<
" sponge halo cells created" << endl;
4221 m_log <<
"with " << noInternalSpongeCells <<
" internal sponge cells and " << endl;
4222 m_log <<
"with " << noSpongeCells - noInternalSpongeCells - noOverlappingSpongeCells3d
4223 <<
" sponge cells laying in 2 sponge areas and " << endl;
4224 m_log <<
"with " << noOverlappingSpongeCells3d <<
" sponge cells laying in 3 sponge areas " << endl;
4225 m_log <<
"max sponge factor: " << maxSpongeFactor << endl;
4226 m_log <<
"min sponge factor: " << minSpongeFactor << endl;
4227 m_log <<
"max sponge factor overlap: " << maxSpongeFactorOverlap << endl;
4228 m_log <<
"min sponge factor overlap: " << minSpongeFactorOverlap << endl;
4230 if((!(maxSpongeFactor >= F0) && !(maxSpongeFactor <= F0)) || (!(minSpongeFactor >= F0) && !(minSpongeFactor <= F0))) {
4231 mTerm(1, AT_,
"error: maximum sponge factor is nan");
4233 if(maxSpongeFactor < 0 || minSpongeFactor < 0) {
4234 mTerm(1, AT_,
"sponge Factor is negative");
4236 if(m_spongeTimeDep) {
4237 m_log <<
"***********************************" << endl;
4238 m_log <<
"Time dependent sponge cell summary" << endl;
4239 m_log <<
"***********************************" << endl;
4240 for(
MInt bcId = 0; bcId < m_noSpongeBndryCndIds; bcId++) {
4241 bcSpId = m_spongeBndryCndIds[bcId];
4242 if(m_spongeTimeDependent[bcId] < 1)
continue;
4243 if(m_spongeTimeDependent[bcId] == 1) {
4244 m_log <<
"time dependent sponge decreasing function at sponge boundary " << bcSpId << endl;
4245 m_log <<
"sponge decreasing start at iteration: " << m_spongeStartIteration[bcId] << endl;
4246 m_log <<
"sponge decreasing end at iteration: " << m_spongeEndIteration[bcId] << endl;
4247 m_log <<
"sponge start value: " << m_sigmaSpongeBndryId[bcId] << endl;
4248 m_log <<
"sponge end value will be zero" << endl << endl;
4249 }
else if(m_spongeTimeDependent[bcId] == 2) {
4250 m_log <<
"time dependent sponge increasing function at sponge boundary " << bcSpId << endl;
4251 m_log <<
"sponge increasing start at iteration: " << m_spongeStartIteration[bcId] << endl;
4252 m_log <<
"sponge increasing end at iteration: " << m_spongeEndIteration[bcId] << endl << endl;
4253 }
else if(m_spongeTimeDependent[bcId] == 3) {
4254 m_log <<
"time dependent sponge decreasing function at sponge boundary " << bcSpId << endl;
4255 m_log <<
"sponge decreasing start at iteration: " << m_spongeStartIteration[bcId] << endl;
4256 m_log <<
"sponge decreasing end at iteration: " << m_spongeEndIteration[bcId] << endl;
4257 m_log <<
"sponge start value: " << m_sigmaSpongeBndryId[bcId] << endl;
4258 m_log <<
"sponge end value: " << m_sigmaEndSpongeBndryId[bcId] << endl << endl;
4264 for(
MInt bcId = 0; bcId < m_noSpongeBndryCndIds; bcId++) {
4265 for(
MInt id = m_spongeBndryCells[bcId];
id < m_spongeBndryCells[bcId + 1];
id++) {
4266 spongeCellId = m_sortedSpongeBndryCells->a[
id];
4267 m_solver->a_hasProperty(spongeCellId, SolverCell::IsInSpongeLayer) =
true;
4273 m_sortedSpongeBndryCells->setSize(0);
4284template <MInt nDim,
class SysEqn>
4288 MInt noDirs = 2 * nDim;
4297 MInt noReconstructIds = 0;
4301 for(
MInt bc = m_bndryCndCells[bcId]; bc < m_bndryCndCells[bcId + 1]; bc++) {
4302 bndryId = m_sortedBndryCells->a[bc];
4303 cellId = m_bndryCells->a[bndryId].m_cellId;
4304 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
4305 if(m_bndryCells->a[bndryId].m_linkedCellId == -1) {
4307 noReconstructIds = 0;
4310 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
4311 reconstructIds[noReconstructIds] = ghostCellId;
4315 for(
MInt c = m_solver->m_identNghbrIds[cellId * noDirs]; c < m_solver->m_identNghbrIds[(cellId + 1) * noDirs];
4317 reconstructIds[noReconstructIds] = m_solver->m_storeNghbrIds[c];
4322 temp = noReconstructIds;
4323 for(
MInt k = 0; k < temp; k++) {
4324 id = reconstructIds[k];
4325 bnd = m_solver->a_bndryId(
id);
4327 for(
MInt c = m_solver->m_identNghbrIds[
id * noDirs]; c < m_solver->m_identNghbrIds[(
id + 1) * noDirs];
4329 nghbrId = m_solver->m_storeNghbrIds[c];
4330 if(m_solver->a_bndryId(nghbrId) == -1) {
4331 reconstructIds[noReconstructIds] = nghbrId;
4340 temp = noReconstructIds;
4341 for(
MInt k = 0; k < temp; k++) {
4342 id = reconstructIds[k];
4343 bnd = m_solver->a_bndryId(
id);
4345 linkedCell = m_bndryCells->a[bnd].m_linkedCellId;
4346 if(linkedCell > -1) {
4347 reconstructIds[k] = linkedCell;
4348 if(linkedCell == cellId) {
4349 for(
MInt c = m_solver->m_identNghbrIds[
id * noDirs]; c < m_solver->m_identNghbrIds[(
id + 1) * noDirs];
4351 nghbrId = m_solver->m_storeNghbrIds[c];
4352 if(m_solver->a_bndryId(nghbrId) > -1) {
4353 if(m_bndryCells->a[m_solver->a_bndryId(nghbrId)].m_linkedCellId == -1) {
4354 reconstructIds[noReconstructIds] = nghbrId;
4357 reconstructIds[noReconstructIds] = m_bndryCells->a[m_solver->a_bndryId(nghbrId)].m_linkedCellId;
4361 reconstructIds[noReconstructIds] = nghbrId;
4371 temp = noReconstructIds;
4372 for(
MInt k = temp - 1; k > -1; k--) {
4373 if(reconstructIds[k] == cellId) {
4375 reconstructIds[k] = reconstructIds[noReconstructIds];
4381 m_solver->a_noReconstructionNeighbors(cellId) =
4384 for(
MInt k = 0; k < m_solver->a_noReconstructionNeighbors(cellId); k++) {
4385 m_solver->a_reconstructionNeighborId(cellId, k) = reconstructIds[k];
4408template <MInt nDim,
class SysEqn>
4413 static constexpr MInt noDirs = 2 * nDim;
4415 MInt noReconstructIds = 0;
4416 MIntScratchSpace reconstructIds(MGC ? 100 : noDirs + 1, AT_,
"reconstructIds");
4420 for(
MInt bc = m_bndryCndCells[bcId]; bc < m_bndryCndCells[bcId + 1]; bc++) {
4421 const MInt bndryId = m_sortedBndryCells->a[bc];
4422 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
4423 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient))
continue;
4424 if(m_solver->a_hasProperty(cellId, SolverCell::IsInvalid))
continue;
4425 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
4426 if((!MGC && m_bndryCells->a[bndryId].m_linkedCellId == -1)
4427 || (MGC && m_bndryCells->a[bndryId].m_linkedCellId > -1)) {
4429 noReconstructIds = 0;
4433 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
4434 reconstructIds[noReconstructIds] = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
4439 reconstructIds.
p[noReconstructIds] = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
4440 noReconstructIds = 1;
4444 for(
MInt c = m_solver->m_identNghbrIds[cellId * noDirs]; c < m_solver->m_identNghbrIds[(cellId + 1) * noDirs];
4446 reconstructIds.
p[noReconstructIds] = m_solver->m_storeNghbrIds[c];
4452 temp = noReconstructIds;
4453 for(
MInt k = 0; k < temp; k++) {
4454 const MInt id = reconstructIds.
p[k];
4455 if(m_solver->a_bndryId(
id) > -1) {
4456 const MInt linkedCell = m_bndryCells->a[m_solver->a_bndryId(
id)].m_linkedCellId;
4457 if(linkedCell > -1) {
4458 reconstructIds.
p[k] = linkedCell;
4459 if(linkedCell == cellId) {
4460 for(
MInt c = m_solver->m_identNghbrIds[
id * noDirs]; c < m_solver->m_identNghbrIds[(
id + 1) * noDirs];
4462 const MInt nghbrId = m_solver->m_storeNghbrIds[c];
4463 if(m_solver->a_bndryId(nghbrId) > -1) {
4464 if(m_bndryCells->a[m_solver->a_bndryId(nghbrId)].m_linkedCellId == -1) {
4465 reconstructIds.
p[noReconstructIds] = nghbrId;
4468 reconstructIds.
p[noReconstructIds] = m_bndryCells->a[m_solver->a_bndryId(nghbrId)].m_linkedCellId;
4472 reconstructIds.
p[noReconstructIds] = nghbrId;
4477 MInt bnd = m_solver->a_bndryId(
id);
4479 for(
MInt srfcSM = 0; srfcSM < m_bndryCells->a[bnd].m_noSrfcs; srfcSM++) {
4480 reconstructIds[noReconstructIds] = m_bndryCells->a[bnd].m_srfcVariables[srfcSM]->m_ghostCellId;
4490 temp = noReconstructIds;
4491 for(
MInt k = temp - 1; k > -1; k--) {
4492 if(reconstructIds.
p[k] == cellId) {
4494 reconstructIds.
p[k] = reconstructIds.
p[noReconstructIds];
4500 m_solver->a_noReconstructionNeighbors(cellId) =
4503 for(
MInt k = 0; k < m_solver->a_noReconstructionNeighbors(cellId); k++) {
4504 m_solver->a_reconstructionNeighborId(cellId, k) = reconstructIds.
p[k];
4512 computeNeumannLSConstants(bcId);
4528template <MInt nDim,
class SysEqn>
4532 MInt noDirs = 2 * nDim;
4533 MInt requiredNoCells, tmpCell;
4534 IF_CONSTEXPR(nDim == 2) requiredNoCells = 7;
4535 IF_CONSTEXPR(nDim == 3) requiredNoCells = 9;
4536 MInt cellId, bndryId, nghbrId, ghostCellId, temp, bnd,
id, linkedCell;
4537 MInt noReconstructIds;
4539 stack<MInt> tmpStack;
4543 for(
MInt bc = m_bndryCndCells[bcId]; bc < m_bndryCndCells[bcId + 1]; bc++) {
4544 bndryId = m_sortedBndryCells->a[bc];
4545 cellId = m_bndryCells->a[bndryId].m_cellId;
4546 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
4547 if(m_bndryCells->a[bndryId].m_linkedCellId == -1) {
4549 noReconstructIds = 0;
4552 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
4553 reconstructIds[noReconstructIds] = ghostCellId;
4557 for(
MInt c = m_solver->m_identNghbrIds[cellId * noDirs]; c < m_solver->m_identNghbrIds[(cellId + 1) * noDirs];
4559 reconstructIds[noReconstructIds] = m_solver->m_storeNghbrIds[c];
4561 tmpStack.push(m_solver->m_storeNghbrIds[c]);
4564 while(noReconstructIds < requiredNoCells) {
4566 for(
MInt n = 0; n < noReconstructIds; n++) {
4567 tmpStack.push(reconstructIds[n]);
4571 while(!tmpStack.empty()) {
4572 tmpCell = tmpStack.top();
4574 for(
MInt c = m_solver->m_identNghbrIds[tmpCell * noDirs];
4575 c < m_solver->m_identNghbrIds[(tmpCell + 1) * noDirs];
4577 reconstructIds[noReconstructIds] = m_solver->m_storeNghbrIds[c];
4584 temp = noReconstructIds;
4585 for(
MInt k = 0; k < temp; k++) {
4586 id = reconstructIds[k];
4587 bnd = m_solver->a_bndryId(
id);
4589 linkedCell = m_bndryCells->a[bnd].m_linkedCellId;
4590 if(linkedCell > -1) {
4591 reconstructIds[k] = linkedCell;
4592 if(linkedCell == cellId) {
4593 for(
MInt c = m_solver->m_identNghbrIds[
id * noDirs]; c < m_solver->m_identNghbrIds[(
id + 1) * noDirs];
4595 nghbrId = m_solver->m_storeNghbrIds[c];
4596 if(m_solver->a_bndryId(nghbrId) > -1) {
4597 if(m_bndryCells->a[m_solver->a_bndryId(nghbrId)].m_linkedCellId == -1) {
4598 reconstructIds[noReconstructIds] = nghbrId;
4601 reconstructIds[noReconstructIds] = m_bndryCells->a[m_solver->a_bndryId(nghbrId)].m_linkedCellId;
4605 reconstructIds[noReconstructIds] = nghbrId;
4614 temp = noReconstructIds;
4615 for(
MInt k = 0; k < temp; k++) {
4616 id = reconstructIds[k];
4617 bnd = m_solver->a_bndryId(
id);
4619 linkedCell = m_bndryCells->a[bnd].m_linkedCellId;
4620 if(linkedCell > -1) reconstructIds[k] = linkedCell;
4625 temp = noReconstructIds;
4626 for(
MInt k = temp - 1; k > -1; k--) {
4627 if(reconstructIds[k] == cellId) {
4629 reconstructIds[k] = reconstructIds[noReconstructIds];
4635 m_solver->a_noReconstructionNeighbors(cellId) =
4638 for(
MInt k = 0; k < m_solver->a_noReconstructionNeighbors(cellId); k++)
4639 m_solver->a_reconstructionNeighborId(cellId, k) = reconstructIds[k];
4646 computeNeumannLSConstants(bcId);
4654template <MInt nDim,
class SysEqn>
4658 m_bc1251ForcingAmplitude =
4659 Context::getSolverProperty<MFloat>(
"bc1251ForcingAmplitude", m_solverId, AT_, &m_bc1251ForcingAmplitude);
4660 m_bc1251ForcingWavelength =
4661 Context::getSolverProperty<MFloat>(
"bc1251ForcingWavelength", m_solverId, AT_, &m_bc1251ForcingWavelength);
4662 m_bc1251ForcingDirection =
4663 Context::getSolverProperty<MInt>(
"bc1251ForcingDirection", m_solverId, AT_, &m_bc1251ForcingDirection);
4665 const MFloat inletSoundSpeed = sysEqn().speedOfSound(m_solver->m_rhoInfinity, m_solver->m_PInfinity);
4666 m_bc1251ForcingFrequency = inletSoundSpeed / m_bc1251ForcingWavelength;
4668 MInt cellId, nghbrId, d = 0;
4669 const MFloat time = m_solver->m_time;
4671 switch(m_cutOffBndryCndIds[bcId]) {
4685 stringstream errorMessage;
4686 errorMessage <<
"ERROR: switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
4687 <<
" not matching any case." << endl;
4688 mTerm(1, AT_, errorMessage.str());
4692 const MInt mainVelocityDirection = (d == 0 || d == 1) ? 0 : 1;
4693 const MInt secondaryVelocityDirection = (d == 0 || d == 1) ? 1 : 0;
4695 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
4696 cellId = m_sortedCutOffCells[bcId]->a[
id];
4697 nghbrId = m_solver->c_neighborId(cellId, d);
4699 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
4701 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
4703 m_solver->a_pvariable(cellId, PV->VV[mainVelocityDirection]) =
4704 (F1 + m_bc1251ForcingAmplitude * sin(2.0 * PI * m_bc1251ForcingFrequency * time))
4705 * m_solver->m_VVInfinity[mainVelocityDirection];
4707 m_solver->a_pvariable(cellId, PV->VV[secondaryVelocityDirection]) = 0;
4709 IF_CONSTEXPR(isDetChem<SysEqn>) {
4710 for(
MInt s = 0; s < m_noSpecies; s++) {
4711 m_solver->a_pvariable(cellId, PV->Y[s]) = m_solver->m_YInfinity[s];
4729template <MInt nDim,
class SysEqn>
4733 MInt forcing = m_solver->m_forcing;
4734 MInt cellId, nghbrId, d = 0;
4735 MFloat time = m_solver->m_time;
4736 MFloat St = m_solver->m_flameStrouhal;
4737 MFloat ampl = m_solver->m_forcingAmplitude;
4747 switch(m_cutOffBndryCndIds[bcId]) {
4761 stringstream errorMessage;
4762 errorMessage <<
"ERROR: switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
4763 <<
" not matching any case." << endl;
4764 mTerm(1, AT_, errorMessage.str());
4770 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
4771 cellId = m_sortedCutOffCells[bcId]->a[
id];
4772 nghbrId = m_solver->c_neighborId(cellId, d);
4778 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
4781 m_solver->a_pvariable(cellId, PV->RHO) =
4782 sysEqn().density_ES(m_solver->a_pvariable(cellId, PV->P), m_solver->m_TInfinity);
4795 m_solver->a_pvariable(cellId, PV->VV[0]) = 0;
4797 xPlus = m_solver->a_coordinate(cellId, 0) + m_radiusVelFlameTube;
4798 xNegative = m_solver->a_coordinate(cellId, 0) - m_radiusVelFlameTube;
4800 m_solver->a_pvariable(cellId, PV->VV[1]) =
4801 m_solver->m_VInfinity
4802 * (F1B2 * (F1 + tanh(xPlus * m_shearLayerStrength)) * (F1 - tanh(xNegative * m_shearLayerStrength)) - F1);
4836 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
4837 cellId = m_sortedCutOffCells[bcId]->a[
id];
4838 nghbrId = m_solver->c_neighborId(cellId, d);
4844 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
4847 m_solver->a_pvariable(cellId, PV->RHO) =
4848 sysEqn().density_ES(m_solver->a_pvariable(cellId, PV->P), m_solver->m_TInfinity);
4851 m_solver->a_pvariable(cellId, PV->VV[0]) = 0;
4853 xPlus = m_solver->a_coordinate(cellId, 0) + m_radiusVelFlameTube;
4854 xNegative = m_solver->a_coordinate(cellId, 0) - m_radiusVelFlameTube;
4856 m_solver->a_pvariable(cellId, PV->VV[1]) =
4857 m_solver->m_VInfinity
4858 * (F1B2 * (F1 + tanh(xPlus * m_shearLayerStrength)) * (F1 - tanh(xNegative * m_shearLayerStrength)) - F1);
4859 m_solver->a_pvariable(cellId, PV->VV[1]) *= (F1 + ampl * sin(St * time));
4933template <MInt nDim,
class SysEqn>
4936 MInt cellId, nghbrId, d = 0;
4938 switch(m_cutOffBndryCndIds[bcId]) {
4949 stringstream errorMessage;
4950 errorMessage <<
"ERROR: switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
4951 <<
" not matching any case." << endl;
4952 mTerm(1, AT_, errorMessage.str());
4958 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
4959 cellId = m_sortedCutOffCells[bcId]->a[
id];
4960 nghbrId = m_solver->c_neighborId(cellId, d);
4967 for(
MInt i = 0; i < nDim; i++)
4968 if(i != d / 2) radius +=
POW2(m_solver->a_coordinate(cellId, i));
4969 radius = sqrt(radius);
4972 jet = F1B2 * (1 + tanh((m_jetHeight - radius) / (2 * m_momentumThickness)));
4975 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity * (1 / (sysEqn().CroccoBusemann(m_Ma, jet)));
4977 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
4979 if(radius <= m_jetHeight) {
4983 m_solver->a_pvariable(cellId, PV->VV[0]) =
4984 F1B2 * m_solver->m_VVInfinity[0] * (1 + tanh((m_jetHeight - radius) / (2 * m_momentumThickness)));
4985 m_solver->a_pvariable(cellId, PV->VV[1]) = m_solver->m_VVInfinity[1];
4986 m_solver->a_pvariable(cellId, PV->VV[2]) = m_solver->m_VVInfinity[2];
4988 m_solver->a_pvariable(cellId, PV->VV[0]) = F0;
4989 m_solver->a_pvariable(cellId, PV->VV[1]) = F0;
4990 m_solver->a_pvariable(cellId, PV->VV[2]) = F0;
5006template <MInt nDim,
class SysEqn>
5010 MInt forcing = m_solver->m_forcing;
5011 MInt cellId, nghbrId, d = 0;
5012 MFloat massFlux = F0, density = F0, pressure = F0, velocity = F0, count = 0;
5013 MFloat maxXCoord = F0, minXCoord = F0, area = F0;
5014 MFloat refPressure = m_solver->m_PInfinity;
5015 if(m_solver->m_combustion) {
5016 refPressure = m_solver->m_pressureFlameTube;
5020 switch(m_cutOffBndryCndIds[bcId]) {
5052 stringstream errorMessage;
5053 errorMessage <<
"ERROR: switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
5054 <<
" not matching any case." << endl;
5055 mTerm(1, AT_, errorMessage.str());
5061 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
5062 cellId = m_sortedCutOffCells[bcId]->a[
id];
5063 nghbrId = m_solver->c_neighborId(cellId, d);
5066 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
5069 for(
MInt i = 0; i < nDim; i++)
5070 m_solver->a_pvariable(cellId, PV->VV[i]) = m_solver->a_pvariable(nghbrId, PV->VV[i]);
5073 m_solver->a_pvariable(cellId, PV->P) = F2 * refPressure - m_solver->a_pvariable(nghbrId, PV->P);
5076 for(
MInt s = 0; s < m_noSpecies; s++)
5077 m_solver->a_pvariable(cellId, PV->Y[s]) = m_solver->a_pvariable(nghbrId, PV->Y[s]);
5079 if(!m_solver->a_isHalo(nghbrId))
5080 if(m_solver->m_combustion) {
5081 if(m_solver->m_massFlux || m_solver->m_plenumWall) {
5083 massFlux += m_solver->a_pvariable(nghbrId, PV->VV[1]) * m_solver->a_pvariable(nghbrId, PV->RHO);
5086 velocity += m_solver->a_pvariable(nghbrId, PV->VV[1]);
5089 pressure += m_solver->a_pvariable(nghbrId, PV->P);
5092 density += m_solver->a_pvariable(nghbrId, PV->RHO);
5097 maxXCoord =
mMax(maxXCoord, m_solver->a_coordinate(cellId, 0));
5100 minXCoord =
mMin(minXCoord, m_solver->a_coordinate(cellId, 0));
5106 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
5107 cellId = m_sortedCutOffCells[bcId]->a[
id];
5108 nghbrId = m_solver->c_neighborId(cellId, d);
5111 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
5114 for(
MInt i = 0; i < nDim; i++)
5115 m_solver->a_pvariable(cellId, PV->VV[i]) = m_solver->a_pvariable(nghbrId, PV->VV[i]);
5123 m_solver->a_pvariable(cellId, PV->P) = F2 * refPressure - m_solver->a_pvariable(nghbrId, PV->P);
5126 for(
MInt i = 0; i < m_noSpecies; i++)
5127 m_solver->a_pvariable(cellId, PV->Y[i]) = m_solver->a_pvariable(nghbrId, PV->Y[i]);
5129 if(!m_solver->a_isHalo(nghbrId))
5130 if(m_solver->m_combustion) {
5131 if(m_solver->m_massFlux || m_solver->m_plenumWall) {
5133 massFlux += m_solver->a_pvariable(nghbrId, PV->VV[1]) * m_solver->a_pvariable(nghbrId, PV->RHO);
5136 velocity += m_solver->a_pvariable(nghbrId, PV->VV[1]);
5139 pressure += m_solver->a_pvariable(nghbrId, PV->P);
5142 density += m_solver->a_pvariable(nghbrId, PV->RHO);
5147 maxXCoord =
mMax(maxXCoord, m_solver->a_coordinate(cellId, 0));
5150 minXCoord =
mMin(minXCoord, m_solver->a_coordinate(cellId, 0));
5155 if(m_solver->m_combustion) {
5156 if((m_solver->m_massFlux || m_solver->m_plenumWall) && m_solver->m_RKStep == (m_solver->m_noRKSteps - 1)) {
5157 if(noDomains() > 1)
mTerm(1, AT_,
"parallize mass flux computation in bc1753");
5158 density = density / count;
5159 pressure = pressure / count;
5160 velocity = velocity / count;
5161 massFlux = massFlux / count;
5162 area = abs(maxXCoord) + abs(minXCoord) + m_solver->c_cellLengthAtLevel(m_solver->maxRefinementLevel());
5168 datei = fopen(
"massFluxOutflow",
"a+");
5170 fprintf(datei,
" %f", m_solver->m_time);
5171 fprintf(datei,
" %-10.10f", massFlux);
5172 fprintf(datei,
" %-10.10f", velocity);
5173 fprintf(datei,
" %-10.10f", density);
5174 fprintf(datei,
" %-10.10f", pressure);
5175 fprintf(datei,
"\n");
5193template <MInt nDim,
class SysEqn>
5197 MInt cellId = -1, nghbrId = -1, d = 0;
5198 MFloat pressure = m_solver->m_PInfinity;
5199 if(m_solver->m_jet) pressure = m_solver->m_jetPressure;
5203 switch(m_cutOffBndryCndIds[bcId]) {
5217 stringstream errorMessage;
5218 errorMessage <<
"ERROR: switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
5219 <<
" not matching any case." << endl;
5220 mTerm(1, AT_, errorMessage.str());
5225 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
5226 cellId = m_sortedCutOffCells[bcId]->a[
id];
5227 nghbrId = m_solver->c_neighborId(cellId, d);
5230 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
5233 for(
MInt i = 0; i < nDim; i++)
5234 m_solver->a_pvariable(cellId, PV->VV[i]) = m_solver->a_pvariable(nghbrId, PV->VV[i]);
5237 m_solver->a_pvariable(cellId, PV->P) = F2 * pressure - m_solver->a_pvariable(nghbrId, PV->P);
5240 for(
MInt s = 0; s < m_noSpecies; s++) {
5241 m_solver->a_pvariable(cellId, PV->Y[s]) = m_solver->a_pvariable(nghbrId, PV->Y[s]);
5255template <MInt nDim,
class SysEqn>
5259 const MInt noSpecies = m_noSpecies;
5262#pragma omp parallel for
5264 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
5265 const MInt bndryId = m_sortedBndryCells->a[
id];
5266 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
5267 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
5268 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
5269 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
5270 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
5272 for(
MInt i = 0; i < nDim; i++) {
5274 if(m_surfaceGhostCell) {
5275 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = 0.0;
5277 m_solver->a_pvariable(ghostCellId, PV->VV[i]) =
5278 -m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->VV[i]];
5281 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = -m_solver->a_pvariable(cellId, PV->VV[i]);
5285 m_solver->a_pvariable(ghostCellId, PV->RHO) =
5286 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->RHO];
5287 m_solver->a_pvariable(ghostCellId, PV->P) =
5288 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->P];
5291 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
5292 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
5295 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
5296 IF_CONSTEXPR(SysEqn::m_ransModel ==
RANS_SA_DV || SysEqn::m_ransModel ==
RANS_FS) {
5298 if(m_surfaceGhostCell) {
5299 m_solver->a_pvariable(ghostCellId, PV->N) = 0.0;
5301 m_solver->a_pvariable(ghostCellId, PV->N) =
5302 -m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->N];
5305 m_solver->a_pvariable(ghostCellId, PV->N) = -m_solver->a_pvariable(cellId, PV->N);
5310 m_solver->a_pvariable(ghostCellId, PV->K) = -m_solver->a_pvariable(cellId, PV->K);
5312 const MFloat rRe = F1 / sysEqn().m_Re0;
5313 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
5314 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
5315 const MFloat omega = m_solver->a_pvariable(cellId, PV->OMEGA);
5316 const MFloat T = sysEqn().temperature_ES(rho, p);
5317 const MFloat mue = sysEqn().sutherlandLaw(T);
5318 const MFloat nu = mue / rho;
5320 MFloat d = sqrt(
POW2(m_solver->a_coordinate(cellId, 0) - m_solver->a_coordinate(ghostCellId, 0))
5321 +
POW2(m_solver->a_coordinate(cellId, 1) - m_solver->a_coordinate(ghostCellId, 1)));
5322 IF_CONSTEXPR(nDim == 3) {
5323 d = sqrt(
POW2(m_solver->a_coordinate(cellId, 0) - m_solver->a_coordinate(ghostCellId, 0))
5324 +
POW2(m_solver->a_coordinate(cellId, 1) - m_solver->a_coordinate(ghostCellId, 1))
5325 +
POW2(m_solver->a_coordinate(cellId, 2) - m_solver->a_coordinate(ghostCellId, 2)));
5327 const MFloat nu_surface = nu - m_solver->a_slope(cellId, PV->N, 1) * d;
5328 const MFloat omega_surface = pow(rRe, 2.0) * 60 * nu_surface / (beta1 *
POW2(d));
5329 m_solver->a_pvariable(ghostCellId, PV->OMEGA) = F2 * omega_surface - omega;
5333 for(
MInt s = 0; s < noSpecies; s++) {
5335 m_solver->a_pvariable(ghostCellId, PV->Y[s]) =
5336 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->Y[s]];
5338 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
5347template <MInt nDim,
class SysEqn>
5352 m_4000timeStepOffset = Context::getSolverProperty<MInt>(
"bc4000timeStepOffset", m_solverId, AT_);
5353 m_4000timeInterval = Context::getSolverProperty<MInt>(
"bc4000timeInterval", m_solverId, AT_);
5354 m_wFactor = Context::getSolverProperty<MFloat>(
"wFactor", m_solverId, AT_);
5363template <MInt nDim,
class SysEqn>
5367 const MFloat G = m_wFactor * m_solver->m_UInfinity;
5370 if(m_4000timeStepOffset > 0) {
5378#pragma omp parallel for
5380 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
5381 const MInt bndryId = m_sortedBndryCells->a[
id];
5382 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
5383 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
5384 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
5385 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
5386 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
5388 m_solver->a_pvariable(ghostCellId, PV->U) = -m_solver->a_pvariable(cellId, PV->U);
5389 m_solver->a_pvariable(ghostCellId, PV->V) = -m_solver->a_pvariable(cellId, PV->V);
5390 m_solver->a_pvariable(ghostCellId, PV->W) = 2.0 * factor * G - m_solver->a_pvariable(cellId, PV->W);
5392 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
5393 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
5394 m_solver->a_pvariable(ghostCellId, PV->NN[r]) = -m_solver->a_pvariable(cellId, PV->NN[r]);
5398 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
5400 for(
MInt s = 0; s < m_noSpecies; s++) {
5401 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
5415template <MInt nDim,
class SysEqn>
5419 const MFloat G = m_wFactor * m_solver->m_UInfinity;
5420 const MInt timeStepOffset = m_4000timeStepOffset;
5423#pragma omp parallel for
5425 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
5426 const MInt bndryId = m_sortedBndryCells->a[
id];
5427 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
5428 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
5429 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
5430 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
5431 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
5433 m_solver->a_pvariable(ghostCellId, PV->U) = -m_solver->a_pvariable(cellId, PV->U);
5434 m_solver->a_pvariable(ghostCellId, PV->V) = -m_solver->a_pvariable(cellId, PV->V);
5439 factor = 1 - cos(PI / (
MFloat)timeStepOffset * (
globalTimeStep - m_solver->m_restartTimeStep));
5442 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
5443 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
5444 m_solver->a_pvariable(ghostCellId, PV->NN[r]) = -m_solver->a_pvariable(cellId, PV->NN[r]);
5448 m_solver->a_pvariable(ghostCellId, PV->W) = 2.0 * factor * G - m_solver->a_pvariable(cellId, PV->W);
5462template <MInt nDim,
class SysEqn>
5467#pragma omp parallel for
5469 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
5470 const MInt bndryId = m_sortedBndryCells->a[
id];
5471 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
5472 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
5473 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
5474 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
5475 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
5477 for(
MInt i = 0; i < nDim; i++) {
5478 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = -m_solver->a_pvariable(cellId, PV->VV[i]);
5480 const MFloat pressure = m_solver->a_pvariable(cellId, PV->P);
5482 m_solver->a_pvariable(ghostCellId, PV->P) = pressure;
5484 m_solver->a_pvariable(ghostCellId, PV->RHO) =
5485 2 * sysEqn().density_ES(pressure, m_Bc3011WallTemperature) - m_solver->a_pvariable(cellId, PV->RHO);
5487 IF_CONSTEXPR(isDetChem<SysEqn>)
5488 m_solver->a_pvariable(ghostCellId, PV->RHO) =
5489 F2 * m_solver->a_avariable(cellId, AV->W_MEAN) * pressure
5490 / (m_solver->m_gasConstant * m_Bc3011WallTemperature)
5491 - m_solver->a_pvariable(cellId, PV->RHO);
5493 for(
MInt s = 0; s < m_noSpecies; s++) {
5494 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
5509template <MInt nDim,
class SysEqn>
5513 const MInt noSpecies = m_noSpecies;
5516#pragma omp parallel for
5518 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
5519 const MInt bndryId = m_sortedBndryCells->a[
id];
5520 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
5521 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
5522 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
5523 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
5524 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
5526 MFloat wallNormalVelocity = F0;
5528 for(
MInt i = 0; i < nDim; i++)
5529 wallNormalVelocity +=
5530 m_solver->a_pvariable(cellId, PV->VV[i]) * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
5532 for(
MInt i = 0; i < nDim; i++)
5533 m_solver->a_pvariable(ghostCellId, PV->VV[i]) =
5534 m_solver->a_pvariable(cellId, PV->VV[i])
5535 - F2 * wallNormalVelocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
5537 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
5538 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
5540 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
5541 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
5542 m_solver->a_pvariable(ghostCellId, PV->NN[r]) = m_solver->a_pvariable(cellId, PV->NN[r]);
5546 for(
MInt s = 0; s < noSpecies; s++)
5547 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
5562template <MInt nDim,
class SysEqn>
5566 const MInt noSpecies = m_noSpecies;
5569#pragma omp parallel for
5571 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
5572 const MInt bndryId = m_sortedBndryCells->a[
id];
5573 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
5574 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
5575 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
5576 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
5577 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
5579 MFloat wallNormalVelocity = F0;
5581 for(
MInt i = 0; i < nDim; i++)
5582 wallNormalVelocity +=
5583 m_solver->a_pvariable(cellId, PV->VV[i]) * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
5585 for(
MInt i = 0; i < nDim; i++)
5586 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = m_solver->a_pvariable(cellId, PV->VV[i]);
5589 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
5590 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
5592 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
5593 for(
MInt r = 0; r < m_noRansEquations; ++r) {
5594 m_solver->a_pvariable(ghostCellId, PV->N) = m_solver->a_pvariable(cellId, PV->N);
5598 for(
MInt s = 0; s < noSpecies; s++)
5599 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
5610template <MInt nDim,
class SysEqn>
5615#pragma omp parallel for
5617 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
5618 const MInt bndryId = m_sortedBndryCells->a[
id];
5619 const MInt linkedCell = m_bndryCells->a[bndryId].m_linkedCellId;
5620 const MInt cellId = (linkedCell > -1) ? linkedCell : m_bndryCells->a[bndryId].m_cellId;
5621 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
5622 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
5623 if(linkedCell == -1 || m_solver->a_bndryId(linkedCell) == -1) {
5625 for(
MInt i = 0; i < nDim; i++) {
5626 m_solver->a_slope(cellId, PV->RHO, i) = F0;
5627 m_solver->a_slope(cellId, PV->P, i) = F0;
5630 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
5631 const MInt nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
5632 for(
MInt i = 0; i < nDim; i++) {
5633 m_solver->a_slope(cellId, PV->RHO, i) +=
5634 m_reconstructionConstants[bndryId][nghbr * nDim + i]
5635 * (m_solver->a_pvariable(nghbrId, PV->RHO) - m_solver->a_pvariable(cellId, PV->RHO));
5636 m_solver->a_slope(cellId, PV->P, i) +=
5637 m_reconstructionConstants[bndryId][nghbr * nDim + i]
5638 * (m_solver->a_pvariable(nghbrId, PV->P) - m_solver->a_pvariable(cellId, PV->P));
5643 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
5644 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
5645 for(
MInt i = 0; i < nDim; i++) {
5646 const MFloat dx = m_solver->a_coordinate(ghostCellId, i) - m_solver->a_coordinate(cellId, i);
5647 m_solver->a_pvariable(ghostCellId, PV->RHO) += dx * m_solver->a_slope(cellId, PV->RHO, i);
5648 m_solver->a_pvariable(ghostCellId, PV->P) += dx * m_solver->a_slope(cellId, PV->P, i);
5658template <MInt nDim,
class SysEqn>
5663#pragma omp parallel for
5665 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
5666 const MInt bndryId = m_sortedBndryCells->a[
id];
5667 const MInt linkedCell = m_bndryCells->a[bndryId].m_linkedCellId;
5668 const MInt cellId = (linkedCell > -1) ? linkedCell : m_bndryCells->a[bndryId].m_cellId;
5669 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
5670 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
5671 if(linkedCell == -1 || m_solver->a_bndryId(linkedCell) == -1) {
5672 for(
MInt i = 0; i < nDim; i++) {
5673 m_solver->a_slope(cellId, PV->P, i) = F0;
5676 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
5677 const MInt nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
5678 for(
MInt i = 0; i < nDim; i++) {
5679 m_solver->a_slope(cellId, PV->P, i) +=
5680 m_reconstructionConstants[bndryId][nghbr * nDim + i]
5681 * (m_solver->a_pvariable(nghbrId, PV->P) - m_solver->a_pvariable(cellId, PV->P));
5686 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
5688 for(
MInt i = 0; i < nDim; i++) {
5689 dp += (m_solver->a_coordinate(ghostCellId, i) - m_solver->a_coordinate(cellId, i))
5690 * m_solver->a_slope(cellId, PV->P, i);
5692 m_solver->a_pvariable(ghostCellId, PV->P) += dp;
5695 IF_CONSTEXPR(isDetChem<SysEqn>) {
5696 m_solver->a_pvariable(ghostCellId, PV->RHO) +=
5697 m_solver->a_avariable(cellId, AV->W_MEAN) * dp / (m_Bc3011WallTemperature * m_solver->m_gasConstant);
5700 m_solver->a_pvariable(ghostCellId, PV->RHO) += sysEqn().density_ES(dp, m_Bc3011WallTemperature);
5712template <MInt nDim,
class SysEqn>
5716 MInt d = 0, cellId, nghbrId;
5719 switch(m_cutOffBndryCndIds[bcId]) {
5739 stringstream errorMessage;
5740 errorMessage <<
"ERROR: switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
5741 <<
" not matching any case." << endl;
5742 mTerm(1, AT_, errorMessage.str());
5746 MFloat bbox[6] = {F0, F0, F0, F0, F0, F0};
5747 m_solver->m_geometry->getBoundingBox(bbox);
5748 const MFloat deltaY = bbox[1 + nDim] - bbox[1];
5749 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
5750 cellId = m_sortedCutOffCells[bcId]->a[
id];
5751 MFloat vel[3] = {F0, F0, F0};
5752 MFloat dy = m_solver->a_coordinate(cellId, 1) / deltaY;
5753 vel[0] = F2 * m_solver->m_UInfinity * dy;
5754 nghbrId = m_solver->c_neighborId(cellId, d);
5755 if((dy > F0 && d == 1) || (dy < F0 && d == 0)) {
5756 for(
MInt i = 0; i < nDim; i++)
5757 m_solver->a_pvariable(cellId, PV->VV[i]) = vel[i];
5758 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
5759 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
5761 for(
MInt v = 0; v < PV->noVariables; v++)
5762 m_solver->a_pvariable(cellId, v) = m_solver->a_pvariable(nghbrId, v);
5763 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_PInfinity;
5770template <MInt nDim,
class SysEqn>
5774 MInt noCells = m_bndryCells->size();
5776 for(
MInt id = 0;
id < noCells;
id++) {
5777 for(
MInt srfc = 0; srfc < m_bndryCells->a[
id].m_noSrfcs; srfc++) {
5778 MInt ghostCellId = m_bndryCells->a[
id].m_srfcVariables[srfc]->m_ghostCellId;
5779 MInt cellId = m_bndryCells->a[
id].m_cellId;
5780 for(
MInt i = 0; i < FV->noVariables; i++) {
5781 m_solver->a_rightHandSide(ghostCellId, i) = m_solver->a_rightHandSide(cellId, i);
5798template <MInt nDim,
class SysEqn>
5803 MIntScratchSpace comm_allBndryIds_scratch(m_maxNoBndryCndIds, AT_,
"comm_allBndryIds_scratch");
5804 MIntScratchSpace comm_allBndryIds_result_scratch(noDomains() * m_maxNoBndryCndIds, AT_,
5805 "comm_allBndryIds_result_scratch");
5807 MInt* comm_allBndryIds_result = comm_allBndryIds_result_scratch.
getPointer();
5808 for(
MInt i = 0; i < noDomains() * m_maxNoBndryCndIds; i++) {
5809 comm_allBndryIds_result[i] = -1;
5812 MPI_Group world_group;
5815 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
5816 comm_allBndryIds[bcId] = m_bndryCndIds[bcId];
5818 for(
MInt bcId = m_noBndryCndIds; bcId < m_maxNoBndryCndIds; bcId++) {
5819 comm_allBndryIds[bcId] = -1;
5822 MPI_Allgather(comm_allBndryIds, m_maxNoBndryCndIds, MPI_INT, comm_allBndryIds_result, m_maxNoBndryCndIds, MPI_INT,
5823 mpiComm(), AT_,
"comm_allBndryIds",
"comm_allBndryIds_result");
5825 MIntScratchSpace sortedBndryCndIds_scratch(m_maxNoBndryCndIds, AT_,
"sortedBndryCndIds_scratch");
5826 MInt* sortedBndryCndIds = sortedBndryCndIds_scratch.
getPointer();
5827 MInt realNoBndryCndIds = 0;
5828 for(
MInt i = 0; i < m_maxNoBndryCndIds * noDomains(); i++) {
5829 if(comm_allBndryIds_result[i] > -1) sortedBndryCndIds[realNoBndryCndIds++] = comm_allBndryIds_result[i];
5834 MIntScratchSpace procs_bcId_scratch(realNoBndryCndIds * noDomains(), AT_,
"procs_bcId_scratch");
5836 MIntScratchSpace noProcs_scratch(realNoBndryCndIds, AT_,
"noProcs_scratch");
5850 if(realNoBndryCndIds > 0) {
5851 mAlloc(m_comm_bc, realNoBndryCndIds,
"m_comm_bc", AT_);
5855 mAlloc(m_bc_comm_pointer, m_maxNoBndryCndIds,
"m_bc_comm_pointer", -1, AT_);
5857 for(
MInt i = 0; i < realNoBndryCndIds; i++) {
5859 for(
MInt p = 0; p < noDomains(); p++) {
5860 for(
MInt j = 0; j < m_maxNoBndryCndIds; j++) {
5861 if(comm_allBndryIds_result[p * m_maxNoBndryCndIds + j] == sortedBndryCndIds[i]) {
5862 procs_bcId[noProcs[i]++] = p;
5867 MPI_Group_incl(world_group, noProcs[i], procs_bcId, &bc_group, AT_);
5869 MPI_Comm_create(mpiComm(), bc_group, &m_comm_bc[i], AT_,
"m_comm_bc[i]");
5875 m_comm_bc_init = realNoBndryCndIds;
5877 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
5878 for(
MInt i = 0; i < realNoBndryCndIds; i++) {
5879 if(m_bndryCndIds[bcId] == sortedBndryCndIds[i]) {
5880 m_bc_comm_pointer[bcId] = i;
5886 IF_CONSTEXPR(nDim == 3) {
5887 if(m_solver->m_vtuGeometryOutput.empty()) {
5888 m_log <<
"VTU geometry output for boundaryIds: ";
5889 for(
MInt i = 0; i < realNoBndryCndIds; i++) {
5890 if((sortedBndryCndIds[i] >= 3000 && sortedBndryCndIds[i] < 4000)
5892 m_solver->m_vtuGeometryOutput.insert(sortedBndryCndIds[i]);
5893 m_log << sortedBndryCndIds[i] <<
" ";
5902 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++) {
5903 if(m_sortedCutOffCells[bcId]->size() > 0) {
5904 comm_allBndryIds[bcId] = m_cutOffBndryCndIds[bcId];
5906 comm_allBndryIds[bcId] = -1;
5909 for(
MInt bcId = m_noCutOffBndryCndIds; bcId < m_maxNoBndryCndIds; bcId++) {
5910 comm_allBndryIds[bcId] = -1;
5912 for(
MInt i = 0; i < noDomains() * m_maxNoBndryCndIds; i++) {
5913 comm_allBndryIds_result[i] = -1;
5916 MPI_Allgather(comm_allBndryIds, m_maxNoBndryCndIds, MPI_INT, comm_allBndryIds_result, m_maxNoBndryCndIds, MPI_INT,
5917 mpiComm(), AT_,
"comm_allBndryIds",
"comm_allBndryIds_result");
5919 realNoBndryCndIds = 0;
5920 for(
MInt i = 0; i < m_maxNoBndryCndIds * noDomains(); i++) {
5921 if(comm_allBndryIds_result[i] > -1) sortedBndryCndIds[realNoBndryCndIds++] = comm_allBndryIds_result[i];
5926 if(realNoBndryCndIds == 0) {
5930 MIntScratchSpace procs_bcIdCo_scratch(realNoBndryCndIds * noDomains(), AT_,
"procs_bcIdCo_scratch");
5931 procs_bcId = procs_bcIdCo_scratch.
getPointer();
5932 MIntScratchSpace noProcsCo_scratch(realNoBndryCndIds, AT_,
"noProcsCo_scratch");
5947 if(realNoBndryCndIds > 0) {
5948 mAlloc(m_comm_bcCo, realNoBndryCndIds,
"m_comm_bcCo", AT_);
5952 mAlloc(m_bcCo_comm_pointer, m_maxNoBndryCndIds,
"m_bcCo_comm_pointer", -1, AT_);
5954 for(
MInt i = 0; i < realNoBndryCndIds; i++) {
5956 for(
MInt p = 0; p < noDomains(); p++) {
5957 for(
MInt j = 0; j < m_maxNoBndryCndIds; j++) {
5958 if(comm_allBndryIds_result[p * m_maxNoBndryCndIds + j] == sortedBndryCndIds[i]) {
5959 procs_bcId[noProcs[i]++] = p;
5964 MPI_Group_incl(world_group, noProcs[i], procs_bcId, &bc_group, AT_);
5966 MPI_Comm_create(mpiComm(), bc_group, &m_comm_bcCo[i], AT_,
"m_comm_bcCo[i]");
5972 m_comm_bcCo_init = realNoBndryCndIds;
5974 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++) {
5975 if(m_sortedCutOffCells[bcId]->size() == 0)
continue;
5977 for(
MInt i = 0; i < realNoBndryCndIds; i++) {
5978 if(m_cutOffBndryCndIds[bcId] == sortedBndryCndIds[i]) {
5979 m_bcCo_comm_pointer[bcId] = i;
5992 if(loadRandomNumbers())
return;
5994 m_log <<
" generate Random Numbers ..." << endl;
6007 for(
MInt n = 0; n < m_noOfModes; n++) {
6008 std::normal_distribution<>
dist{1.0, 1.0};
6009 m_omega[n] =
dist(randNumGen);
6011 std::normal_distribution<> dist2{0.0, 0.5};
6012 d1 = dist2(randNumGen);
6013 d2 = dist2(randNumGen);
6014 d3 = dist2(randNumGen);
6016 std::normal_distribution<> dist3{0.0, 1.0};
6017 xi1 = dist3(randNumGen);
6018 xi2 = dist3(randNumGen);
6019 xi3 = dist3(randNumGen);
6020 zeta1 = dist3(randNumGen);
6021 zeta2 = dist3(randNumGen);
6022 zeta3 = dist3(randNumGen);
6025 m_p1[n] = zeta2 * d3 - zeta3 * d2;
6026 m_p2[n] = zeta3 * d1 - zeta1 * d3;
6027 m_p3[n] = zeta1 * d2 - zeta2 * d1;
6028 m_q1[n] = xi2 * d3 - xi3 * d2;
6029 m_q2[n] = xi3 * d1 - xi1 * d3;
6030 m_q3[n] = xi1 * d2 - xi2 * d1;
6040 * ((uuref * d1 * d1 + vvref * d2 * d2 + wwref * d3 * d3
6041 + 2.0 * (uvref * d1 * d2 + uwref * d1 * d3 + vwref * d2 * d3))
6042 / (d1 * d1 + d2 * d2 + d3 * d3)));
6045 m_dhat1[n] = d1 * m_v_b / vc;
6046 m_dhat2[n] = d2 * m_v_b / vc;
6047 m_dhat3[n] = d3 * m_v_b / vc;
6056 if(m_rank_bc1601 == 0) {
6057 for(
MInt n = 0; n < m_noOfModes; n++) {
6058 sendRecvBuffer[n + 0 * m_noOfModes] = m_omega[n];
6060 for(
MInt n = 0; n < m_noOfModes; n++) {
6061 sendRecvBuffer[n + 1 * m_noOfModes] = m_p1[n];
6063 for(
MInt n = 0; n < m_noOfModes; n++) {
6064 sendRecvBuffer[n + 2 * m_noOfModes] = m_p2[n];
6066 for(
MInt n = 0; n < m_noOfModes; n++) {
6067 sendRecvBuffer[n + 3 * m_noOfModes] = m_p3[n];
6069 for(
MInt n = 0; n < m_noOfModes; n++) {
6070 sendRecvBuffer[n + 4 * m_noOfModes] = m_q1[n];
6072 for(
MInt n = 0; n < m_noOfModes; n++) {
6073 sendRecvBuffer[n + 5 * m_noOfModes] = m_q2[n];
6075 for(
MInt n = 0; n < m_noOfModes; n++) {
6076 sendRecvBuffer[n + 6 * m_noOfModes] = m_q3[n];
6078 for(
MInt n = 0; n < m_noOfModes; n++) {
6079 sendRecvBuffer[n + 7 * m_noOfModes] = m_dhat1[n];
6081 for(
MInt n = 0; n < m_noOfModes; n++) {
6082 sendRecvBuffer[n + 8 * m_noOfModes] = m_dhat2[n];
6084 for(
MInt n = 0; n < m_noOfModes; n++) {
6085 sendRecvBuffer[n + 9 * m_noOfModes] = m_dhat3[n];
6089 MPI_Bcast(&sendRecvBuffer[0], 10 * m_noOfModes, MPI_DOUBLE, 0, m_comm_bc1601, AT_,
"sendRecvBuffer[0]");
6091 if(m_rank_bc1601 != 0) {
6092 for(
MInt n = 0; n < m_noOfModes; n++) {
6093 m_omega[n] = sendRecvBuffer[n];
6095 for(
MInt n = 0; n < m_noOfModes; n++) {
6096 m_p1[n] = sendRecvBuffer[n + 1 * m_noOfModes];
6098 for(
MInt n = 0; n < m_noOfModes; n++) {
6099 m_p2[n] = sendRecvBuffer[n + 2 * m_noOfModes];
6101 for(
MInt n = 0; n < m_noOfModes; n++) {
6102 m_p3[n] = sendRecvBuffer[n + 3 * m_noOfModes];
6104 for(
MInt n = 0; n < m_noOfModes; n++) {
6105 m_q1[n] = sendRecvBuffer[n + 4 * m_noOfModes];
6107 for(
MInt n = 0; n < m_noOfModes; n++) {
6108 m_q2[n] = sendRecvBuffer[n + 5 * m_noOfModes];
6110 for(
MInt n = 0; n < m_noOfModes; n++) {
6111 m_q3[n] = sendRecvBuffer[n + 6 * m_noOfModes];
6113 for(
MInt n = 0; n < m_noOfModes; n++) {
6114 m_dhat1[n] = sendRecvBuffer[n + 7 * m_noOfModes];
6116 for(
MInt n = 0; n < m_noOfModes; n++) {
6117 m_dhat2[n] = sendRecvBuffer[n + 8 * m_noOfModes];
6119 for(
MInt n = 0; n < m_noOfModes; n++) {
6120 m_dhat3[n] = sendRecvBuffer[n + 9 * m_noOfModes];
6125 if((m_rank_bc1601 == 0) || (!m_commValues)) {
6132 if(stat((test.str()).c_str(), &st) != 0) {
6133#if defined(MAIA_MS_COMPILER)
6134#pragma message("WARNING: Not compatible")
6135 mTerm(0,
"ERROR: Not implemented!");
6137 mkdir((test.str()).c_str(), 0744);
6139 m_log << endl <<
"creating folder " << test.str() <<
" for random numbers" << endl;
6141 test <<
"/" << file <<
"_D" << m_domainId;
6143 file.append(test.str());
6145 writeRnd.
open(file.c_str(), ios_base::out | ios_base::trunc | ios_base::binary);
6149 for(
MInt n = 0; n < m_noOfModes; n++) {
6150 fnumber = m_omega[n];
6154 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6159 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6164 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6169 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6174 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6179 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6184 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6185 fnumber = m_dhat1[n];
6189 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6190 fnumber = m_dhat2[n];
6194 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6195 fnumber = m_dhat3[n];
6199 writeRnd.write(
reinterpret_cast<char*
>(&fnumber),
sizeof(
MFloat));
6211 test << file <<
"/" << file <<
"_D" << m_domainId;
6213 file.append(test.str());
6215 readRnd.open(file.c_str(), ios_base::in | ios_base::binary);
6221 m_log <<
" read Random numbers from restartFile " << file <<
" ..." << endl;
6225 for(
MInt n = 0; n < m_noOfModes; n++) {
6226 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6230 m_omega[n] = fnumber;
6231 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6236 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6241 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6246 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6251 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6256 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6261 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6265 m_dhat1[n] = fnumber;
6266 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6270 m_dhat2[n] = fnumber;
6271 readRnd.read((
char*)(&fnumber),
sizeof(
MFloat));
6275 m_dhat3[n] = fnumber;
6285 : m_domainId(domainId) {
6298 m_l_b = Context::getSolverProperty<MFloat>(
"bc1601Lb", m_solverId, AT_);
6317 m_oldMode = Context::getSolverProperty<MInt>(
"bc1601OldMode", m_solverId, AT_, &
m_oldMode);
6342 m_useUnif = Context::getSolverProperty<MBool>(
"bc1601UseUnif", m_solverId, AT_, &
m_useUnif);
6344 MBool restart =
false;
6345 restart = Context::getSolverProperty<MBool>(
"restartFile", m_solverId, AT_, &restart);
6357 Context::getSolverProperty<MBool>(
"bc1601RegenerateSeeding", m_solverId, AT_, &
m_regenerateSeeding);
6372 Context::getSolverProperty<MInt>(
"bc1601RegenerationInterval", m_solverId, AT_, &
m_regenerationInterval);
6386 uuref = Context::getSolverProperty<MFloat>(
"uuref", m_solverId, AT_, &
uuref);
6387 uvref = Context::getSolverProperty<MFloat>(
"uvref", m_solverId, AT_, &
uvref);
6388 uwref = Context::getSolverProperty<MFloat>(
"uwref", m_solverId, AT_, &
uwref);
6389 vvref = Context::getSolverProperty<MFloat>(
"vvref", m_solverId, AT_, &
vvref);
6390 vwref = Context::getSolverProperty<MFloat>(
"vwref", m_solverId, AT_, &
vwref);
6391 wwref = Context::getSolverProperty<MFloat>(
"wwref", m_solverId, AT_, &
wwref);
6407 smirnov = Context::getSolverProperty<MBool>(
"smirnov", m_solverId, AT_, &
smirnov);
6424 m_log <<
" Use Shin method for synthetic turbulence injection..." << endl;
6425 m_log <<
" It used Taylor hypothesis for temporal part" << endl;
6430 m_log <<
"It is not using Shin method for synthetic turbulence injection..." << endl;
6451 if(
uuref <= 0.0) cerr <<
"WARNING in proc " <<
m_domainId <<
": a11^2 <= 0 in bcInit1601" << endl;
6455 if((
vvref -
aa[1] *
aa[1]) <= 0.0) cerr <<
"WARNING in proc " <<
m_domainId <<
": a22^2 <= 0 in bcInit1601" << endl;
6459 cerr <<
"WARNING in proc " <<
m_domainId <<
": a33^2 <= 0 in bcInit1601" << endl;
6474 Rey_str[0][0] =
uuref;
6475 Rey_str[1][0] =
uvref;
6476 Rey_str[2][0] =
uwref;
6477 Rey_str[0][1] =
uvref;
6478 Rey_str[1][1] =
vvref;
6479 Rey_str[2][1] =
vwref;
6480 Rey_str[0][2] =
uwref;
6481 Rey_str[1][2] =
vwref;
6482 Rey_str[2][2] =
wwref;
6486 c1 = sqrt(eigval[0]);
6487 c2 = sqrt(eigval[1]);
6488 c3 = sqrt(eigval[2]);
6517 m_log <<
"Initialize 1601 random inflow with " <<
m_noOfModes <<
" random modes..." << endl;
6525 m_log <<
"ok" << endl;
6564 for(
MInt n = 0; n < m_noOfModes; n++) {
6568 xx = eigvec[0][0] * (xhat - that) + eigvec[1][0] * yhat + eigvec[2][0] * zhat;
6569 yy = eigvec[0][1] * (xhat - that) + eigvec[1][1] * yhat + eigvec[2][1] * zhat;
6570 zz = eigvec[0][2] * (xhat - that) + eigvec[1][2] * yhat + eigvec[2][2] * zhat;
6573 tmpVar = m_dhat1[n] / c1 * xx + m_dhat2[n] / c2 * yy + m_dhat3[n] / c3 * zz;
6577 xfluct += m_p1[n] * B + m_q1[n] * D;
6578 yfluct += m_p2[n] * B + m_q2[n] * D;
6579 zfluct += m_p3[n] * B + m_q3[n] * D;
6582 for(
MInt n = 0; n < m_noOfModes; n++) {
6583 tmpVar = m_dhat1[n] * xhat + m_dhat2[n] * yhat + m_dhat3[n] * zhat + m_omega[n] * that;
6588 xfluct += m_p1[n] * B + m_q1[n] * D;
6589 yfluct += m_p2[n] * B + m_q2[n] * D;
6590 zfluct += m_p3[n] * B + m_q3[n] * D;
6598 if(m_noOfModes > 0) {
6599 xfluct *= sqrt(2.0 / ((
MFloat)m_noOfModes));
6600 yfluct *= sqrt(2.0 / ((
MFloat)m_noOfModes));
6601 zfluct *= sqrt(2.0 / ((
MFloat)m_noOfModes));
6625 fluctChol[0] = eigvec[0][0] * w1 + eigvec[0][1] * w2 + eigvec[0][2] * w3;
6626 fluctChol[1] = eigvec[1][0] * w1 + eigvec[1][1] * w2 + eigvec[1][2] * w3;
6627 fluctChol[2] = eigvec[2][0] * w1 + eigvec[2][1] * w2 + eigvec[2][2] * w3;
6630 fluctChol[0] = xfluct * aa[0];
6631 fluctChol[1] = xfluct * aa[1] + yfluct * aa[3];
6632 fluctChol[2] = xfluct * aa[2] + yfluct * aa[4] + zfluct * aa[5];
6640 if(m_regenerateSeeding) {
6641 MInt dummy = floor(time / m_regenerationInterval);
6642 if(dummy > m_regenerationCounter) {
6643 m_regenerationCounter = dummy;
6644 generateAndCommRandomNumbers();
6657template <MInt nDim,
class SysEqn>
6662 const MInt noPVars = PV->noVariables;
6665#pragma omp parallel for
6667 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
6668 const MInt bndryId = m_sortedBndryCells->a[
id];
6669 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
6671 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
6672 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
6673 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
6674 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
6677 IF_CONSTEXPR(nDim == 3) {
6681 / sqrt(
POW2(m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[0]
6682 - m_solver->a_coordinate(ghostCellId, 0))
6683 +
POW2(m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[1]
6684 - m_solver->a_coordinate(ghostCellId, 1))
6685 +
POW2(m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[2]
6686 - m_solver->a_coordinate(ghostCellId, 2)))
6687 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_FJacobian;
6691 / sqrt(
POW2(m_solver->a_coordinate(cellId, 0) - m_solver->a_coordinate(ghostCellId, 0))
6692 +
POW2(m_solver->a_coordinate(cellId, 1) - m_solver->a_coordinate(ghostCellId, 1))
6693 +
POW2(m_solver->a_coordinate(cellId, 2) - m_solver->a_coordinate(ghostCellId, 2)))
6694 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_FJacobian;
6701 / sqrt(
POW2(m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[0]
6702 - m_solver->a_coordinate(ghostCellId, 0))
6703 +
POW2(m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[1]
6704 - m_solver->a_coordinate(ghostCellId, 1)))
6705 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_FJacobian;
6710 / sqrt(
POW2(m_solver->a_coordinate(cellId, 0) - m_solver->a_coordinate(ghostCellId, 0))
6711 +
POW2(m_solver->a_coordinate(cellId, 1) - m_solver->a_coordinate(ghostCellId, 1)))
6712 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_FJacobian;
6720 IF_CONSTEXPR(nDim == 3) {
6722 const1 = (m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector0[1]
6723 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector1[2]
6724 - m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector1[1]
6725 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector0[2])
6728 const2 = (m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector0[2]
6729 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector1[0]
6730 - m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector1[2]
6731 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector0[0])
6734 const3 = (m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector0[0]
6735 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector1[1]
6736 - m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector1[0]
6737 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_planeVector0[1])
6741 const1 = preFactor * m_bndryCells->a[bndryId].m_srfcs[0]->m_planeVector0[1];
6742 const2 = -preFactor * m_bndryCells->a[bndryId].m_srfcs[0]->m_planeVector0[0];
6747 for(
MInt i = 0; i < nDim; i++) {
6750 factor = (m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->VV[i]]
6751 - m_solver->a_pvariable(ghostCellId, PV->VV[i]));
6753 factor = (m_solver->a_pvariable(cellId, PV->VV[i]) - m_solver->a_pvariable(ghostCellId, PV->VV[i]));
6755 m_solver->a_slope(ghostCellId, PV->VV[i], 0) =
6756 2.0 * factor * const1 - m_solver->a_slope(cellId, PV->VV[i], 0);
6757 m_solver->a_slope(ghostCellId, PV->VV[i], 1) =
6758 2.0 * factor * const2 - m_solver->a_slope(cellId, PV->VV[i], 1);
6759 IF_CONSTEXPR(nDim == 3) {
6760 m_solver->a_slope(ghostCellId, PV->VV[i], 2) =
6761 2.0 * factor * const3 - m_solver->a_slope(cellId, PV->VV[i], 2);
6766 for(
MInt varId = nDim; varId < noPVars; varId++) {
6767 for(
MInt i = 0; i < nDim; i++) {
6768 m_solver->a_slope(ghostCellId, varId, i) = -m_solver->a_slope(cellId, varId, i);
6784template <MInt nDim,
class SysEqn>
6788 static_assert(dir <= nDim,
"ERROR: Invalid direction!");
6790 const MInt noPVars = PV->noVariables;
6793#pragma omp parallel for
6795 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
6796 const MInt bndryId = m_sortedBndryCells->a[
id];
6797 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
6798 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
6799 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
6801 for(
MInt v = 0; v < noPVars; v++) {
6803 m_solver->a_slope(ghostCellId, v, 0) =
6804 (m_solver->a_pvariable(cellId, v) - m_solver->a_pvariable(ghostCellId, v))
6805 / (m_solver->a_coordinate(cellId, 0) - m_solver->a_coordinate(ghostCellId, 0));
6807 m_solver->a_slope(ghostCellId, v, 0) = m_solver->a_slope(cellId, v, 0);
6811 m_solver->a_slope(ghostCellId, v, 1) =
6812 (m_solver->a_pvariable(cellId, v) - m_solver->a_pvariable(ghostCellId, v))
6813 / (m_solver->a_coordinate(cellId, 1) - m_solver->a_coordinate(ghostCellId, 1));
6815 m_solver->a_slope(ghostCellId, v, 1) = m_solver->a_slope(cellId, v, 1);
6818 IF_CONSTEXPR(nDim == 3) {
6820 m_solver->a_slope(ghostCellId, v, 2) =
6821 (m_solver->a_pvariable(cellId, v) - m_solver->a_pvariable(ghostCellId, v))
6822 / (m_solver->a_coordinate(cellId, 2) - m_solver->a_coordinate(ghostCellId, 2));
6824 m_solver->a_slope(ghostCellId, v, 2) = m_solver->a_slope(cellId, v, 2);
6830 for(
MInt v = 0; v < noPVars; v++) {
6831 for(
MInt i = 0; i < nDim; i++) {
6832 m_solver->a_slope(ghostCellId, v, i) =
6833 2.0 * m_solver->a_slope(ghostCellId, v, i) - m_solver->a_slope(cellId, v, i);
6846template <MInt nDim,
class SysEqn>
6850 static_assert(dir <= nDim,
"ERROR: Invalid direction!");
6853 const MInt noPVars = PV->noVariables;
6857 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
6858 const MInt bndryId = m_sortedBndryCells->a[
id];
6859 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
6860 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
6861 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
6864 const MFloat Frho = 1.0 / m_solver->a_variable(cellId, CV->RHO);
6865 const MFloat FrhoGhost = 1.0 / m_solver->a_variable(ghostCellId, CV->RHO);
6867 for(
MInt i = 0; i < nDim; i++) {
6868 PVbndry[i] = m_solver->a_variable(cellId, CV->RHO_VV[i]) * Frho;
6869 PVghost[i] = m_solver->a_variable(ghostCellId, CV->RHO_VV[i]) * FrhoGhost;
6873 PVbndry[PV->RHO] = m_solver->a_variable(cellId, CV->RHO);
6874 PVghost[PV->RHO] = m_solver->a_variable(ghostCellId, CV->RHO);
6878 for(
MInt i = 0; i < nDim; i++) {
6879 rhoU2 +=
POW2(m_solver->a_variable(cellId, CV->RHO_VV[i]));
6882 sysEqn().pressure(m_solver->a_variable(cellId, CV->RHO), rhoU2, m_solver->a_variable(cellId, CV->RHO_E));
6885 for(
MInt i = 0; i < nDim; i++) {
6886 rhoU2 +=
POW2(m_solver->a_variable(ghostCellId, CV->RHO_VV[i]));
6888 PVghost[PV->P] = sysEqn().pressure(m_solver->a_variable(ghostCellId, CV->RHO), rhoU2,
6889 m_solver->a_variable(ghostCellId, CV->RHO_E));
6892 for(
MInt s = 0; s < m_noSpecies; s++) {
6893 PVbndry[PV->Y[s]] = m_solver->a_variable(cellId, CV->RHO_Y[s]) * Frho;
6894 PVghost[PV->Y[s]] = m_solver->a_variable(ghostCellId, CV->RHO_Y[s]) * FrhoGhost;
6897 for(
MInt var = 0; var < noPVars; var++) {
6899 m_solver->a_slope(ghostCellId, var, 0) =
6900 (PVbndry[var] - PVghost[var])
6901 / (m_solver->a_coordinate(cellId, 0) - m_solver->a_coordinate(ghostCellId, 0));
6903 m_solver->a_slope(ghostCellId, var, 0) = m_solver->a_slope(cellId, var, 0);
6907 m_solver->a_slope(ghostCellId, var, 1) =
6908 (PVbndry[var] - PVghost[var])
6909 / (m_solver->a_coordinate(cellId, 1) - m_solver->a_coordinate(ghostCellId, 1));
6911 m_solver->a_slope(ghostCellId, var, 1) = m_solver->a_slope(cellId, var, 1);
6914 IF_CONSTEXPR(nDim == 3) {
6916 m_solver->a_slope(ghostCellId, var, 2) =
6917 (PVbndry[var] - PVghost[var])
6918 / (m_solver->a_coordinate(cellId, 2) - m_solver->a_coordinate(ghostCellId, 2));
6920 m_solver->a_slope(ghostCellId, var, 2) = m_solver->a_slope(cellId, var, 2);
6926 for(
MInt varId = 0; varId < noPVars; varId++) {
6927 for(
MInt i = 0; i < nDim; i++) {
6928 m_solver->a_slope(ghostCellId, varId, i) =
6929 2.0 * m_solver->a_slope(ghostCellId, varId, i) - m_solver->a_slope(cellId, varId, i);
6938template <MInt nDim,
class SysEqn>
6942 const MInt noSpecies = m_noSpecies;
6945#pragma omp parallel for
6947 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
6948 const MInt bndryId = m_sortedBndryCells->a[
id];
6949 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
6950 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
6951 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
6952 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
6953 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
6955 for(
MInt i = 0; i < nDim; i++) {
6957 if(m_surfaceGhostCell) {
6958 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = 0.0;
6960 m_solver->a_pvariable(ghostCellId, PV->VV[i]) =
6961 -m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->VV[i]];
6964 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = -m_solver->a_pvariable(cellId, PV->VV[i]);
6968 m_solver->a_pvariable(ghostCellId, PV->RHO) =
6969 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->RHO];
6970 m_solver->a_pvariable(ghostCellId, PV->P) =
6971 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->P];
6974 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
6975 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
6978 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
6979 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
6981 if(m_surfaceGhostCell) {
6982 m_solver->a_pvariable(ghostCellId, PV->NN[r]) = 0.0;
6984 m_solver->a_pvariable(ghostCellId, PV->NN[r]) =
6985 -m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->NN[r]];
6988 m_solver->a_pvariable(ghostCellId, PV->NN[r]) = m_solver->a_pvariable(cellId, PV->NN[r]);
6992 for(
MInt s = 0; s < noSpecies; s++) {
6994 m_solver->a_pvariable(ghostCellId, PV->Y[s]) =
6995 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->Y[s]];
6997 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
7006template <MInt nDim,
class SysEqn>
7010 m_solver->m_wmSurfaces.clear();
7012 if(PV->noVariables > 5)
mTerm(1, AT_,
"WMLES not implemented for noPVars > 5");
7014 const MFloat utau = sqrt(m_solver->m_UInfinity / m_solver->m_wmDistance / sysEqn().m_Re0);
7016 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
7017 MInt bc = m_bndryCndIds[bcId];
7020 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
7021 const MInt bndryId = m_sortedBndryCells->a[
id];
7022 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
7023 if(m_solver->a_hasProperty(cellId, SolverCell::IsHalo))
continue;
7024 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
7026 m_bndryCells->a[bndryId].m_isWMCell =
true;
7028 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
7029 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_wmSrfcId = (
MInt)m_solver->m_wmSurfaces.size();
7031 m_solver->m_wmSurfaces.back().init(bndryId, srfc, utau);
7032 m_solver->m_wmSurfaces.back().m_wmUII = m_solver->m_UInfinity;
7033 if(std::isnan(m_solver->m_wmSurfaces.back().m_wmUTAU)) {
7034 MLong gId = m_solver->c_globalId(cellId);
7035 cerr <<
"utau is nan at globalId = " << gId <<
" bndryId = " << bndryId <<
" surfaceId = " << srfc
7037 m_log <<
"utau is nan at globalId = " << gId <<
" bndryId = " << bndryId <<
" surfaceId = " << srfc
7054template <MInt nDim,
class SysEqn>
7057 const MFloat time = m_solver->m_time;
7058 const MInt bcNum = m_cutOffBndryCndIds[bcId];
7060 for(
MInt mode = 0; mode < m_modes; mode++) {
7061 const MFloat modeEtaMin = m_modeEtaMin[mode];
7062 const MFloat modePhi = m_modePhi[mode];
7063 const MFloat modeOmega = m_modeOmega[mode];
7066 const MFloat modeEtaMax = -(
MFloat)(m_nmbrOfModes[mode]) * PI;
7069 const MFloat pressure_f = m_modeAmp[mode] * m_solver->m_PInfinity * (
MFloat)(m_modeType[mode]);
7072 const MFloat a = sysEqn().speedOfSound(m_solver->m_TInfinity);
7073 const MFloat density_f = m_modeType[mode] ? pressure_f /
POW2(
a) : m_modeAmp[mode] * m_solver->m_rhoInfinity;
7077 for(
MInt i = 0; i < nDim; i++) {
7078 K += pow(m_modeK[mode][i], 2);
7081 const MFloat acImp =
a * m_solver->m_rhoInfinity;
7082 const MFloat modeVelocity = (
MFloat)(m_modeType[mode]) * pressure_f / acImp;
7084 for(
MInt i = 0; i < nDim; i++) {
7085 velocity_f[i] = (m_modeK[mode][i] * modeVelocity) / K;
7088 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
7089 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
7091 if(m_solver->a_coordinate(cellId, 1)
7092 < m_ys + (tan(m_solver->m_angle[0] + m_sigmaShock) * m_solver->a_coordinate(cellId, 0))) {
7098 for(
MInt i = 0; i < nDim; i++) {
7099 trigTerm += m_modeK[mode][i] * m_solver->a_coordinate(cellId, i);
7101 trigTerm -= modeOmega * time;
7102 trigTerm += modePhi;
7107 trigTerm -= modeEtaMin;
7110 if(trigTerm > F0 || trigTerm < modeEtaMax) {
7116 trigTerm = sin(trigTerm);
7120 m_solver->a_pvariable(cellId, PV->RHO) += trigTerm * density_f;
7123 for(
MInt dim = 0; dim < m_solver->nDim; dim++) {
7124 m_solver->a_pvariable(cellId, PV->VV[dim]) += trigTerm * velocity_f[dim];
7128 m_solver->a_pvariable(cellId, PV->P) += trigTerm * pressure_f;
7134template <MInt nDim,
class SysEqn>
7136 const MInt bcNum = m_cutOffBndryCndIds[bcId];
7137 m_log << endl <<
"initializing plane modes for bcId " << bcId << endl;
7138 m_log <<
" running for " << bcNum << endl;
7140 const MFloat time = m_solver->m_restart ? m_solver->m_time : F0;
7157 mAlloc(m_modeType, m_modes,
"m_modeType", 0, AT_);
7158 for(
MInt i = 0; i < m_modes; i++) {
7159 m_modeType[i] = Context::getSolverProperty<MInt>(
"modeType", m_solverId, AT_, i);
7173 mAlloc(m_modeAmp, m_modes,
"m_modeAmp", F0, AT_);
7174 for(
MInt i = 0; i < m_modes; i++) {
7175 m_modeAmp[i] = Context::getSolverProperty<MFloat>(
"modeAmp", m_solverId, AT_, i);
7188 mAlloc(m_modePhi, m_modes,
"m_modePhi", F0, AT_);
7189 for(
MInt i = 0; i < m_modes; i++) {
7190 m_modePhi[i] = Context::getSolverProperty<MFloat>(
"modePhi", m_solverId, AT_, i) * PI / 180.0;
7204 mAlloc(m_modeK, m_modes, nDim,
"m_modeK", F0, AT_);
7205 for(
MInt mode = 0; mode < m_modes; mode++) {
7206 for(
MInt j = 0; j < nDim - 1; j++) {
7207 modeAngle(mode, j) = Context::getSolverProperty<MFloat>(
"modeAngle", m_solverId, AT_, mode * 2 + j) * PI / 180.0;
7209 m_modeK[mode][0] =
cos(modeAngle(mode, 0)) *
cos(modeAngle(mode, 1));
7210 m_modeK[mode][1] = sin(modeAngle(mode, 0)) *
cos(modeAngle(mode, 1));
7211 IF_CONSTEXPR(nDim == 3) m_modeK[mode][2] = sin(modeAngle(mode, 1));
7223 if(m_modes !=
Context::propertyLength("nmbrOfModes", m_solverId))
mTerm(1, AT_, "nmbrOfModes does not fit modeType");
7224 mAlloc(m_nmbrOfModes, m_modes, "m_nmbrOfModes", 0, AT_);
7225 for(
MInt i = 0; i < m_modes; i++) {
7226 m_nmbrOfModes[i] = Context::getSolverProperty<MInt>(
"nmbrOfModes", m_solverId, AT_, i);
7230 for(
MInt i = 0; i < nDim; i++) {
7231 UInfinity +=
POW2(m_solver->m_VVInfinity[i]);
7233 UInfinity = sqrt(UInfinity);
7236 for(
MInt i = 0; i < nDim; i++) {
7237 if(m_solver->grid().periodicCartesianDir(i) > 0) {
7238 if(lambdaParN > F0)
mTerm(1, AT_,
"more then two periodic directions in initModes");
7239 lambdaParN += m_solver->grid().periodicCartesianLength(i);
7242 m_log <<
"periodic length " << lambdaParN << endl;
7243 if(lambdaParN > F0) {
7244 m_log <<
"periodicCartesianDir: calculating modeSr from nmbrPeriodicModes" << endl;
7257 mTerm(1, AT_,
"nmbrPeriodicModes does not fit modeType");
7260 for(
MInt i = 0; i < m_modes; i++) {
7261 nmbrPeriodicModes(i) = Context::getSolverProperty<MInt>(
"nmbrPeriodicModes", m_solverId, AT_, i);
7264 for(
MInt mode = 0; mode < m_modes; mode++) {
7266 for(
MInt i = 0; i < nDim; i++) {
7267 Uk += m_solver->m_VVInfinity[i] * m_modeK[mode][i];
7270 MFloat lambdaDotKnorm = F0;
7271 for(
MInt i = 0; i < nDim; i++) {
7272 if(m_solver->grid().periodicCartesianDir(i) > 0) {
7273 if(lambdaDotKnorm > F0)
mTerm(1, AT_,
"more then two periodic directions in initModes");
7274 lambdaDotKnorm += m_solver->grid().periodicCartesianLength(i) * m_modeK[mode][i];
7278 if(lambdaDotKnorm / lambdaParN < pow(10, -3)) {
7279 m_log <<
" modeSr(" << mode <<
") from property file" << endl;
7281 modeSr(mode) = Context::getSolverProperty<MInt>(
"modeSr", m_solverId, AT_, mode);
7283 modeSr(mode) = nmbrPeriodicModes(mode) * m_solver->m_referenceLength
7284 * abs((
MFloat)(m_modeType[mode]) * sysEqn().speedOfSound(m_solver->m_TInfinity) + Uk)
7285 / (UInfinity * abs(lambdaDotKnorm));
7287 m_log <<
"modeSr(" << mode <<
") = " << modeSr(mode) << endl;
7303 for(
MInt i = 0; i < m_modes; i++) {
7304 modeSr(i) = Context::getSolverProperty<MFloat>(
"modeSr", m_solverId, AT_, i);
7309 if(m_solver->m_restartBc2800) {
7310 initTime = m_solver->m_restartTimeBc2800;
7313 m_solver->m_restartTimeBc2800 = time;
7315 m_log <<
"time = " << time << endl;
7316 m_log <<
"initTime = " << initTime << endl;
7319 mAlloc(m_modeOmega, m_modes,
"m_modeOmega", F0, AT_);
7320 mAlloc(m_modeEtaMin, m_modes,
"m_modeEtaMin", F0, AT_);
7322 for(
MInt mode = 0; mode < m_modes; mode++) {
7323 m_log <<
"-- mode " << mode <<
" --" << endl;
7324 m_log <<
" modeType = " << m_modeType[mode] << endl;
7325 m_log <<
" modeSr = " << modeSr(mode) << endl;
7326 m_log <<
" modeAmp = " << m_modeAmp[mode] << endl;
7327 m_log <<
" modePhi = " << m_modePhi[mode] << endl;
7328 m_log <<
" nmbrOfModes= " << m_nmbrOfModes[mode] << endl;
7329 for(
MInt i = 0; i < (nDim - 1); i++) {
7330 m_log <<
" modeAngle(" << i <<
") = " << modeAngle(mode, i) <<
" (rad)" << endl;
7334 m_modeOmega[mode] = F2 * PI * modeSr(mode) * UInfinity / m_solver->m_referenceLength;
7337 for(
MInt i = 0; i < nDim; i++) {
7338 Uk += m_solver->m_VVInfinity[i] * m_modeK[mode][i];
7340 const MFloat propVel = (
MFloat)(m_modeType[mode]) * sysEqn().speedOfSound(m_solver->m_TInfinity);
7341 const MFloat K = m_modeOmega[mode] / abs(Uk + propVel);
7342 for(
MInt i = 0; i < nDim; i++) {
7343 m_modeK[mode][i] *= K;
7346 m_log <<
" Uk = " << Uk << endl;
7347 m_log <<
" modeOmega = " << m_modeOmega[mode] << endl;
7348 m_log <<
" K = " << K << endl;
7349 for(
MInt i = 0; i < nDim; i++) {
7350 m_log <<
" modeK[" << i <<
"] = " << m_modeK[mode][i] << endl;
7353 MFloat modeEtaMin = std::numeric_limits<MFloat>::max();
7354 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
7356 if(m_solver->a_isHalo(cellId))
continue;
7358 if(m_solver->a_coordinate(cellId, 1)
7365 for(
MInt i = 0; i < nDim; i++) {
7366 eta += m_solver->a_coordinate(cellId, i) * m_modeK[mode][i];
7368 eta -= m_modeOmega[mode] * initTime;
7370 modeEtaMin =
mMin(modeEtaMin, eta);
7372 m_modeEtaMin[mode] = modeEtaMin;
7374 MPI_Allreduce(MPI_IN_PLACE, &(m_modeEtaMin[mode]), 1, MPI_DOUBLE, MPI_MIN, mpiComm(), AT_,
"MPI_IN_PLACE",
7375 "(m_modeEtaMin[mode])");
7377 m_log <<
" modeEtaMin = " << m_modeEtaMin[mode] << endl;
7379 m_log <<
" mode initialisation finished" << endl;
7383template <MInt nDim,
class SysEqn>
7385 const MInt bcNum = m_cutOffBndryCndIds[bcId];
7386 m_log << endl <<
"initializing bessel modes for bcId " << bcId << endl;
7387 m_log <<
" running for " << bcNum << endl;
7389 const MFloat time = m_solver->m_restart ? m_solver->m_time : F0;
7405 mAlloc(m_modeType, m_modes,
"m_modeType", 0, AT_);
7406 for(
MInt i = 0; i < m_modes; i++) {
7407 m_modeType[i] = Context::getSolverProperty<MInt>(
"modeType", m_solverId, AT_, i);
7422 mAlloc(m_modeAmp, m_modes,
"m_modeAmp", F0, AT_);
7423 for(
MInt i = 0; i < m_modes; i++) {
7424 m_modeAmp[i] = Context::getSolverProperty<MFloat>(
"modeAmp", m_solverId, AT_, i);
7440 for(
MInt i = 0; i < m_modes; i++) {
7441 modeAngle(i) = Context::getSolverProperty<MFloat>(
"modeAnlge", m_solverId, AT_, i) * PI / 180.0;
7442 if(bcNum == 2800 && modeAngle(i) < F0) {
7444 "error in modeAngle property: correct implementation of circumferential integrals not tested for "
7445 "negative radial wave numbers, switch sign");
7462 for(
MInt i = 0; i < m_modes; i++) {
7463 modeSr(i) = Context::getSolverProperty<MFloat>(
"modeSr", m_solverId, AT_, i);
7476 mAlloc(m_nmbrOfModes, m_modes,
"m_nmbrOfModes", 0, AT_);
7477 for(
MInt i = 0; i < m_modes; i++) {
7478 m_nmbrOfModes[i] = Context::getSolverProperty<MInt>(
"nmbrOfModes", m_solverId, AT_, i);
7482 mAlloc(m_modeOmega, m_modes,
"m_modeOmega", F0, AT_);
7483 mAlloc(m_modeK, m_modes, 2,
"m_modeK", F0, AT_);
7484 mAlloc(m_modeEtaMin, m_modes,
"m_modeEtaMin", F0, AT_);
7486 mAlloc(m_besselTrig, m_modes * 2 * m_sortedCutOffCells[bcId]->size(),
"m_besselTrig", F0, AT_);
7490 if(m_solver->m_restartBc2800) {
7491 initTime = m_solver->m_restartTimeBc2800;
7494 m_solver->m_restartTimeBc2800 = time;
7496 m_log <<
"time = " << time << endl;
7497 m_log <<
"initTime = " << initTime << endl;
7500 for(
MInt mode = 0; mode < m_modes; mode++) {
7501 m_log <<
" modeType = " << m_modeType[mode] << endl;
7502 m_log <<
" modeSr = " << modeSr(mode) << endl;
7503 m_log <<
" modeAmp = " << m_modeAmp[mode] << endl;
7504 m_log <<
" modeAngle = " << modeAngle(mode) <<
" (rad)" << endl;
7507 m_modeOmega[mode] = F2 * PI * modeSr(mode) * m_solver->m_VVInfinity[0] / m_solver->m_referenceLength;
7510 m_modeK[mode][0] =
cos(modeAngle(mode));
7511 m_modeK[mode][1] = sin(modeAngle(mode));
7512 MFloat Uk = m_solver->m_VVInfinity[0] * m_modeK[mode][0];
7513 const MFloat propVel = (
MFloat)(m_modeType[mode]) * sysEqn().speedOfSound(m_solver->m_TInfinity);
7514 const MFloat K = m_modeOmega[mode] / abs(Uk + propVel);
7515 for(
MInt i = 0; i < 2; i++) {
7516 m_modeK[mode][i] *= K;
7520 m_log <<
" Uk = " << Uk << endl;
7521 m_log <<
" modeOmega = " << m_modeOmega[mode] << endl;
7522 m_log <<
" K = " << K << endl;
7523 for(
MInt i = 0; i < 2; i++) {
7524 m_log <<
" modeK[" << i <<
"] = " << m_modeK[mode][i] << endl;
7528 MFloat modeEtaMin = std::numeric_limits<MFloat>::max();
7529 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
7531 if(m_solver->a_isHalo(cellId))
continue;
7532 const MFloat x = m_solver->a_coordinate(cellId, 0);
7533 const MFloat r = sqrt(
POW2(m_solver->a_coordinate(cellId, 1)) +
POW2(m_solver->a_coordinate(cellId, 2)));
7535 const MFloat eta = x * m_modeK[mode][0] - r * m_modeK[mode][1] - m_modeOmega[mode] * initTime - PIB2;
7537 modeEtaMin =
mMin(modeEtaMin, eta);
7540 MPI_Allreduce(MPI_IN_PLACE, &modeEtaMin, 1, MPI_DOUBLE, MPI_MIN, mpiComm(), AT_,
"MPI_IN_PLACE",
"modeEtaMin");
7541 m_modeEtaMin[mode] = modeEtaMin;
7542 m_log <<
" modeEtaMin = " << m_modeEtaMin[mode] << endl;
7544 m_log <<
" mode initialisation finished" << endl;
7548template <MInt nDim,
class SysEqn>
7551 const MFloat time = m_solver->m_time;
7552 const MBool isFiltered = m_cutOffBndryCndIds[bcId] == 2800 ? true :
false;
7553 const MInt noCutOffCells = m_sortedCutOffCells[bcId]->size();
7555 for(
MInt mode = 0; mode < m_modes; mode++) {
7556 const MFloat modeOmega = m_modeOmega[mode];
7557 const MFloat modeEtaMin = m_modeEtaMin[mode];
7558 const MFloat dphi = m_nmbrOfModes[mode] * PI;
7560 for(
MInt id = 0;
id < noCutOffCells;
id++) {
7561 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
7564 const MFloat dy = m_solver->a_coordinate(cellId, 1);
7565 const MFloat dz = m_solver->a_coordinate(cellId, 2);
7569 const MFloat xkxmot = m_modeK[mode][0] * m_solver->a_coordinate(cellId, 0) - modeOmega * time;
7570 const MFloat rkr = r * m_modeK[mode][1];
7572 const MInt offset = mode * noCutOffCells + 2 *
id;
7575 calcBesselFractions(xkxmot - modeEtaMin, rkr, dphi, m_besselTrig[offset], m_besselTrig[offset + 1]);
7585template <MInt nDim,
class SysEqn>
7588 const MInt noCutOffCells = m_sortedCutOffCells[bcId]->size();
7590 for(
MInt mode = 0; mode < m_modes; mode++) {
7592 const MFloat a = sysEqn().speedOfSound(m_solver->m_TInfinity);
7595 const MFloat pressure_f = m_modeAmp[mode] * m_solver->m_PInfinity * (
MFloat)(m_modeType[mode]);
7598 const MFloat density_f = m_modeType[mode] ? pressure_f /
POW2(
a) : m_modeAmp[mode] * m_solver->m_rhoInfinity;
7601 const MFloat acImp =
a * m_solver->m_rhoInfinity;
7602 const MFloat velocity_f = (
MFloat)(m_modeType[mode]) * pressure_f / acImp;
7603 const MFloat cosIncl = cos(atan2(m_modeK[mode][1], m_modeK[mode][0]));
7604 const MFloat sinIncl = sin(atan2(m_modeK[mode][1], m_modeK[mode][0]));
7606 for(
MInt id = 0;
id < noCutOffCells;
id++) {
7607 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
7609 const MFloat phi = atan2(m_solver->a_coordinate(cellId, 1), m_solver->a_coordinate(cellId, 2));
7611 const MInt offset = mode * noCutOffCells + 2 *
id;
7612 const MFloat trig_P_RHO_U = m_besselTrig[offset];
7613 const MFloat trig_V_W = m_besselTrig[offset + 1];
7616 m_solver->a_pvariable(cellId, PV->RHO) += density_f * trig_P_RHO_U;
7619 m_solver->a_pvariable(cellId, PV->U) += velocity_f * cosIncl * trig_P_RHO_U;
7622 const MFloat radialVelocity = velocity_f * sinIncl * trig_V_W;
7623 m_solver->a_pvariable(cellId, PV->V) += radialVelocity * sin(phi);
7624 m_solver->a_pvariable(cellId, PV->W) += radialVelocity * cos(phi);
7627 m_solver->a_pvariable(cellId, PV->P) += pressure_f * trig_P_RHO_U;
7634template <MInt nDim,
class SysEqn>
7638 const MFloat phiMax = xkxmot + rkr;
7639 const MFloat phiMin = xkxmot - rkr;
7640 const MFloat PIB2MinusDdhi = PIB2 - dphi;
7642 const MFloat DPSI = PI / 180;
7643 const MInt MINN = 10;
7644 const MFloat INTDEC = PIB2;
7645 if(phiMin >= PIB2 || phiMax <= PIB2MinusDdhi) {
7649 }
else if(phiMin >= PIB2MinusDdhi && phiMax <= PIB2) {
7653 }
else if(phiMin < PIB2MinusDdhi && phiMax > PIB2) {
7655 const MFloat psihatmax = acos((PIB2 - xkxmot) / rkr);
7656 const MFloat psihatmin = acos((PIB2MinusDdhi - xkxmot) / rkr);
7657 if(psihatmin - psihatmax < INTDEC) {
7659 const MInt noSeg =
mMax((
MInt)ceil((psihatmin - psihatmax) / DPSI), MINN);
7660 const MFloat dpsi = (psihatmin - psihatmax) / noSeg;
7665 for(
MInt cnt = 1; cnt <= noSeg; cnt++) {
7668 resultB1 += F1B2 * (firstValB1 + secondValB1) * dpsi;
7669 resultB2 += F1B2 * (firstValB2 + secondValB2) * dpsi;
7670 firstValB1 = secondValB1;
7671 firstValB2 = secondValB2;
7673 trig_P_RHO_U = resultB1 / PI;
7674 trig_V_W = resultB2 / PI;
7677 const MInt noSeg1 =
mMax((
MInt)ceil(psihatmax / DPSI), MINN);
7678 const MFloat dpsi1 = psihatmax / noSeg1;
7683 for(
MInt cnt = 1; cnt <= noSeg1; cnt++) {
7686 resultB1 += F1B2 * (firstValB1 + secondValB1) * dpsi1;
7687 resultB2 += F1B2 * (firstValB2 + secondValB2) * dpsi1;
7688 firstValB1 = secondValB1;
7689 firstValB2 = secondValB2;
7692 const MInt noSeg2 =
mMax((
MInt)ceil((PI - psihatmin) / DPSI), MINN);
7693 const MFloat dpsi2 = (PI - psihatmin) / noSeg2;
7696 for(
MInt cnt = 1; cnt <= noSeg2; cnt++) {
7699 resultB1 += F1B2 * (firstValB1 + secondValB1) * dpsi2;
7700 resultB2 += F1B2 * (firstValB2 + secondValB2) * dpsi2;
7701 firstValB1 = secondValB1;
7702 firstValB2 = secondValB2;
7709 const MFloat psihatintersec = acos((((phiMax > PIB2) ? PIB2 : PIB2MinusDdhi) - xkxmot) / rkr);
7710 if(psihatintersec < INTDEC) {
7712 const MInt noSeg =
mMax((
MInt)ceil(psihatintersec / DPSI), MINN);
7713 const MFloat dpsi = psihatintersec / noSeg;
7718 for(
MInt cnt = 1; cnt <= noSeg; cnt++) {
7721 resultB1 += F1B2 * (firstValB1 + secondValB1) * dpsi;
7722 resultB2 += F1B2 * (firstValB2 + secondValB2) * dpsi;
7723 firstValB1 = secondValB1;
7724 firstValB2 = secondValB2;
7730 trig_P_RHO_U = resultB1 / PI;
7731 trig_V_W = resultB2 / PI;
7735 const MInt noSeg =
mMax((
MInt)ceil((PI - psihatintersec) / DPSI), MINN);
7736 const MFloat dpsi = (PI - psihatintersec) / noSeg;
7741 for(
MInt cnt = 1; cnt <= noSeg; cnt++) {
7744 resultB1 += F1B2 * (firstValB1 + secondValB1) * dpsi;
7745 resultB2 += F1B2 * (firstValB2 + secondValB2) * dpsi;
7746 firstValB1 = secondValB1;
7747 firstValB2 = secondValB2;
7750 trig_P_RHO_U = resultB1 / PI;
7751 trig_V_W = resultB2 / PI;
7761template <MInt nDim,
class SysEqn>
7765 MInt noCells = m_bndryCells->size();
7768 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
7769 if(m_bndryCells->a[bndryId].m_volume <= 0) {
7770 cerr <<
"Cell " << m_bndryCells->a[bndryId].m_cellId <<
" at level "
7771 << m_solver->a_level(m_bndryCells->a[bndryId].m_cellId) <<
" has volume "
7772 << m_bndryCells->a[bndryId].m_volume << endl;
7773 cerr <<
"Cut points of cell " << m_bndryCells->a[bndryId].m_cellId <<
":" << endl;
7774 for(
MInt point = 0; point < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; point++) {
7775 for(
MInt i = 0; i < nDim; i++) {
7776 cerr << point <<
" x" << i <<
" " << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[point][i] << endl;
7850template <MInt nDim,
class SysEqn>
7854 MInt noCells = m_bndryCells->size();
7857 MInt formerMasterBnd;
7862 MInt primaryDirection = 0;
7868 m_smallBndryCells->setSize(0);
7870 m_log <<
"Small cell treatment " << endl;
7871 m_log <<
"using " << m_volumeLimitWall <<
" " << m_volumeLimitOther << endl;
7875 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
7876 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
false;
7877 m_solver->a_slope(bndryId, 0, 1) = (
MFloat)
false;
7878 cellId = m_bndryCell[bndryId].m_cellId;
7880 for(
MInt srfcId = 0; srfcId < m_bndryCells->a[m_solver->a_bndryId(cellId)].m_noSrfcs; srfcId++) {
7881 if(m_bndryCell[bndryId].m_srfcs[srfcId]->m_bndryCndId / 1000 == 3) {
7887 if(m_bndryCell[bndryId].m_volume / m_solver->grid().gridCellVolume(m_solver->a_level(cellId))
7888 < m_volumeLimitWall) {
7889 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
true;
7890 m_bndryCell[bndryId].m_linkedCellId = cellId;
7894 if(m_bndryCell[bndryId].m_volume / m_solver->grid().gridCellVolume(m_solver->a_level(cellId))
7895 < m_volumeLimitOther) {
7896 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
true;
7897 m_bndryCell[bndryId].m_linkedCellId = cellId;
7904 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
7905 m_solver->a_slope(bndryId, 1, 0) = (
MFloat)(-1);
7906 m_solver->a_slope(bndryId, 1, 1) = (
MFloat)(-1);
7907 if((
MInt)m_solver->a_slope(bndryId, 0, 0)) {
7910 for(
MInt i = 0; i < nDim; i++) {
7911 if(fabs(m_bndryCell[bndryId].m_srfcs[0]->m_normalVector[i]) > maxComponent) {
7912 maxComponent = fabs(m_bndryCell[bndryId].m_srfcs[0]->m_normalVector[i]);
7913 if(m_bndryCell[bndryId].m_srfcs[0]->m_normalVector[i] < F0) {
7914 primaryDirection = 2 * i;
7916 primaryDirection = 2 * i + 1;
7921 cellId = m_bndryCell[bndryId].m_cellId;
7922 if(m_solver->a_hasNeighbor(cellId, primaryDirection) > 0) {
7923 nghbrId = m_solver->c_neighborId(cellId, primaryDirection);
7924 if(m_solver->a_bndryId(nghbrId) > -1) {
7925 m_solver->a_slope(bndryId, 1, 1) = (
MFloat)nghbrId;
7927 m_solver->a_slope(bndryId, 1, 0) = (
MFloat)nghbrId;
7933 m_log <<
"Small cell treatment..." << endl;
7934 m_log << counter <<
" small cells to link" << endl;
7941 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
7942 if(!(
MInt)m_solver->a_slope(bndryId, 0, 0))
continue;
7943 if((
MInt)m_solver->a_slope(bndryId, 1, 0) == -1)
continue;
7944 m_bndryCell[bndryId].m_linkedCellId = (
MInt)m_solver->a_slope(bndryId, 1, 0);
7945 m_solver->a_slope(bndryId, 0, 1) = (
MFloat)
true;
7951 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
7952 if(!(
MInt)m_solver->a_slope(bndryId, 0, 0))
continue;
7953 if((
MInt)m_solver->a_slope(bndryId, 0, 1))
continue;
7954 if((
MInt)m_solver->a_slope(bndryId, 1, 1) == -1)
continue;
7955 m_bndryCell[bndryId].m_linkedCellId = (
MInt)m_solver->a_slope(bndryId, 1, 1);
7956 m_solver->a_slope(bndryId, 0, 1) = (
MFloat)
true;
7962 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
7963 if(!(
MInt)m_solver->a_slope(bndryId, 0, 0))
continue;
7964 if(!(
MInt)m_solver->a_slope(bndryId, 0, 1))
continue;
7965 if(m_solver->a_bndryId(m_bndryCell[bndryId].m_linkedCellId) == -1)
continue;
7966 if(!(
MInt)m_solver->a_slope(m_solver->a_bndryId(m_bndryCell[bndryId].m_linkedCellId), 0, 0))
continue;
7967 formerMasterBnd = m_solver->a_bndryId(m_bndryCell[bndryId].m_linkedCellId);
7968 m_bndryCell[bndryId].m_linkedCellId = m_bndryCell[formerMasterBnd].m_linkedCellId;
7972 m_log <<
"Master cell statistics: " << endl;
7973 m_log <<
"__________________________________" << endl << endl;
7974 m_log <<
" * links to internal cells " << count1 << endl;
7975 m_log <<
" * links to boundary cells " << count2 << endl;
7976 m_log <<
" * chained links " << countChained << endl;
7977 m_log <<
"__________________________________" << endl;
7980 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
7981 if((
MInt)m_solver->a_slope(bndryId, 0, 0) && (
MInt)m_solver->a_slope(bndryId, 0, 1)) {
7982 m_smallBndryCells->append();
7983 m_smallBndryCells->a[m_smallBndryCells->size() - 1] = bndryId;
7988 noCells = m_smallBndryCells->size();
7989 for(
MInt s = 0; s < noCells; s++) {
7990 m_solver->m_smallCellIds[s] = m_bndryCell[m_smallBndryCells->a[s]].m_cellId;
7991 m_solver->m_masterCellIds[s] = m_bndryCell[m_smallBndryCells->a[s]].m_linkedCellId;
8016template <MInt nDim,
class SysEqn>
8020 MInt noCells = m_bndryCells->size();
8027 MInt primaryDirection = -1;
8028 MInt secondaryDirection = -1;
8029 MInt thirdDirection = -1;
8033 MBool MGCPreferWallBoundaries =
false;
8048 MGCPreferWallBoundaries =
8049 Context::getSolverProperty<MBool>(
"MGC_preferWallBoundaries", m_solverId, AT_, &MGCPreferWallBoundaries);
8053 m_smallBndryCells->setSize(0);
8055 m_log <<
"Small cell treatment " << endl;
8056 m_log <<
"using " << m_volumeLimitWall <<
" " << m_volumeLimitOther << endl;
8060 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
8061 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
false;
8062 m_solver->a_slope(bndryId, 0, 1) = (
MFloat)
false;
8063 m_solver->a_slope(bndryId, 2, 0) = (
MFloat)(-1);
8064 m_solver->a_slope(bndryId, 2, 1) = (
MFloat)
false;
8065 cellId = m_bndryCell[bndryId].m_cellId;
8066 m_bndryCell[bndryId].m_linkedCellId = -1;
8068 for(
MInt srfcId = 0; srfcId < m_bndryCells->a[m_solver->a_bndryId(cellId)].m_noSrfcs; srfcId++) {
8069 if(m_bndryCell[bndryId].m_srfcs[srfcId]->m_bndryCndId >= 3000
8070 && m_bndryCell[bndryId].m_srfcs[srfcId]->m_bndryCndId < 4000) {
8075 if(m_solver->c_noChildren(cellId) > 0)
continue;
8077 if(m_bndryCell[bndryId].m_volume / m_solver->grid().gridCellVolume(m_solver->a_level(cellId))
8078 < m_volumeLimitWall) {
8079 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
true;
8080 m_bndryCell[bndryId].m_linkedCellId =
cellId;
8084 if(m_bndryCell[bndryId].m_volume / m_solver->grid().gridCellVolume(m_solver->a_level(cellId))
8085 < m_volumeLimitOther) {
8086 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
true;
8087 m_bndryCell[bndryId].m_linkedCellId =
cellId;
8094 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
8095 m_solver->a_slope(bndryId, 1, 0) = (
MFloat)(-1);
8096 m_solver->a_slope(bndryId, 1, 1) = (
MFloat)(-1);
8097 if((
MInt)m_solver->a_slope(bndryId, 0, 0)) {
8100 for(
MInt srfcId = 0; srfcId < m_bndryCells->a[bndryId].m_noSrfcs; srfcId++) {
8102 if(m_bndryCells->a[bndryId].m_srfcs[srfcId]->m_bndryCndId == 3003
8103 || m_bndryCells->a[bndryId].m_srfcs[srfcId]->m_bndryCndId == 3005) {
8105 if(MGCPreferWallBoundaries)
break;
8106 }
else if(!MGCPreferWallBoundaries) {
8114 primaryDirection = -1;
8115 for(
MInt i = 0; i < nDim; i++) {
8116 if(fabs(m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVector[i]) > maxComponent) {
8117 maxComponent = fabs(m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVector[i]);
8118 thirdDirection = secondaryDirection;
8119 secondaryDirection = primaryDirection;
8120 if(m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVector[i] < F0) {
8121 primaryDirection = 2 * i;
8123 primaryDirection = 2 * i + 1;
8127 cellId = m_bndryCell[bndryId].m_cellId;
8129 m_solver->a_slope(bndryId, 3, 0) = -1;
8130 m_solver->a_slope(bndryId, 3, 1) = -1;
8131 m_solver->a_slope(bndryId, 3, 2) = -1;
8132 if(primaryDirection > -1
8133 && m_solver->m_identNghbrIds[cellId * m_noDirs + primaryDirection]
8134 < m_solver->m_identNghbrIds[cellId * m_noDirs + primaryDirection + 1]) {
8135 nghbrId = m_solver->m_storeNghbrIds[m_solver->m_identNghbrIds[
cellId * m_noDirs + primaryDirection]];
8136 m_solver->a_slope(bndryId, 3, 0) = (
MFloat)nghbrId;
8138 if(secondaryDirection > -1
8139 && m_solver->m_identNghbrIds[cellId * m_noDirs + secondaryDirection]
8140 < m_solver->m_identNghbrIds[cellId * m_noDirs + secondaryDirection + 1]) {
8141 nghbrId = m_solver->m_storeNghbrIds[m_solver->m_identNghbrIds[
cellId * m_noDirs + secondaryDirection]];
8142 m_solver->a_slope(bndryId, 3, 1) = (
MFloat)nghbrId;
8144 if(thirdDirection > -1
8145 && m_solver->m_identNghbrIds[cellId * m_noDirs + thirdDirection]
8146 < m_solver->m_identNghbrIds[cellId * m_noDirs + thirdDirection + 1]) {
8147 nghbrId = m_solver->m_storeNghbrIds[m_solver->m_identNghbrIds[
cellId * m_noDirs + thirdDirection]];
8148 m_solver->a_slope(bndryId, 3, 2) = (
MFloat)nghbrId;
8151 nghbrId = m_solver->a_slope(bndryId, 3, 0);
8153 if(m_solver->a_bndryId(nghbrId) > -1) {
8154 m_solver->a_slope(bndryId, 1, 1) = (
MFloat)nghbrId;
8156 m_solver->a_slope(bndryId, 1, 0) = (
MFloat)nghbrId;
8159 nghbrId = m_solver->a_slope(bndryId, 3, 1);
8161 if(m_solver->a_bndryId(nghbrId) > -1) {
8162 m_solver->a_slope(bndryId, 1, 1) = (
MFloat)nghbrId;
8164 m_solver->a_slope(bndryId, 1, 0) = (
MFloat)nghbrId;
8167 nghbrId = m_solver->a_slope(bndryId, 3, 2);
8169 if(m_solver->a_bndryId(nghbrId) > -1) {
8170 m_solver->a_slope(bndryId, 1, 1) = (
MFloat)nghbrId;
8172 m_solver->a_slope(bndryId, 1, 0) = (
MFloat)nghbrId;
8175 cerr <<
" " << domainId() <<
" " <<
cellId <<
" " << primaryDirection <<
" " << m_solver->c_parentId(cellId)
8176 <<
" " << m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId << endl;
8177 cerr <<
"Coordinates: " << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 1)
8178 <<
" " << m_solver->a_coordinate(cellId, 2) << endl;
8179 cerr <<
"Normal vector: " << m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVector[0] <<
" "
8180 << m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVector[1] <<
" "
8181 << m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVector[2] << endl;
8182 cerr << m_solver->a_hasNeighbor(cellId, 0) <<
" " << m_solver->a_hasNeighbor(cellId, 1) <<
" "
8183 << m_solver->a_hasNeighbor(cellId, 2) <<
" " << m_solver->a_hasNeighbor(cellId, 3) <<
" ";
8184 IF_CONSTEXPR(nDim == 3) {
8185 cerr << m_solver->a_hasNeighbor(cellId, 4) <<
" " << m_solver->a_hasNeighbor(cellId, 5) << endl;
8188 cerr << m_solver->c_neighborId(cellId, 0) <<
" " << m_solver->c_neighborId(cellId, 1) <<
" "
8189 << m_solver->c_neighborId(cellId, 2) <<
" " << m_solver->c_neighborId(cellId, 3) <<
" ";
8190 IF_CONSTEXPR(nDim == 3) {
8191 cerr << m_solver->c_neighborId(cellId, 4) <<
" " << m_solver->c_neighborId(cellId, 5) << endl;
8194 cerr <<
"[" << domainId() <<
"]: Error in small cell treatment: No neighbor in any direction" << endl;
8195 if(m_solver->a_isHalo(cellId)) {
8196 m_solver->a_hasProperty(cellId, SolverCell::IsDummy) =
true;
8197 m_solver->a_isBndryGhostCell(cellId) =
false;
8198 m_solver->a_hasProperty(cellId, SolverCell::IsInterface) =
false;
8199 m_solver->a_isPeriodic(cellId) =
false;
8200 m_solver->a_hasProperty(cellId, SolverCell::IsCutOff) =
false;
8201 m_solver->a_hasProperty(cellId, SolverCell::IsInvalid) =
true;
8202 m_solver->a_hasProperty(cellId, SolverCell::IsFlux) =
false;
8203 m_solver->a_hasProperty(cellId, SolverCell::IsActive) =
false;
8204 m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel) =
false;
8205 m_solver->a_hasProperty(cellId, SolverCell::IsInSpongeLayer) =
false;
8206 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
false;
8207 cerr <<
" cell inactive"
8208 <<
", cellId: " <<
cellId << endl;
8214 m_solver->a_level(cellId) = -1;
8216 cerr <<
"cell is no multi solver halo cell! " << endl;
8224 m_log <<
"Small cell treatment..." << endl;
8225 m_log << counter <<
" small cells to link" << endl;
8227 MInt invalidCounter = 0;
8228 stringstream filename;
8233 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
8234 cellId = m_bndryCell[bndryId].m_cellId;
8235 if(!(
MInt)m_solver->a_slope(bndryId, 0, 0))
continue;
8236 if(m_solver->a_hasProperty(cellId, SolverCell::IsInvalid)) {
8238 cerr <<
" found invalid small cell. Please check! CellId is " <<
cellId <<
" bndryId is " << bndryId
8239 <<
" counter is " << invalidCounter <<
". Cell is no set to be non-small." << endl;
8241 filename <<
cellId <<
"_invalidSmall.stl";
8243 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
false;
8245 if((
MInt)m_solver->a_slope(bndryId, 1, 0) > -1) {
8246 if(m_solver->a_hasProperty((
MInt)m_solver->a_slope(bndryId, 1, 0), SolverCell::IsInvalid)) {
8247 cerr <<
" found small cell with invalid internal master. Please check! CellId is " <<
cellId <<
" bndryId is "
8248 << bndryId <<
", master is " << (
MInt)m_solver->a_slope(bndryId, 1, 0)
8249 <<
". Cell is no set to be non-small." << endl;
8251 filename <<
cellId <<
"_smallInvalidMaster.stl";
8253 filename << (
MInt)m_solver->a_slope(bndryId, 1, 0) <<
"_invalidMaster.stl";
8255 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
false;
8258 if((
MInt)m_solver->a_slope(bndryId, 1, 1) == -1) {
8259 cerr <<
" found small cell with no master. Please check! CellId is " <<
cellId <<
" bndryId is " << bndryId
8260 <<
". Cell is no set to be non-small." << endl;
8262 filename <<
cellId <<
"_smallNoMaster.stl";
8264 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
false;
8266 if(m_solver->a_hasProperty((
MInt)m_solver->a_slope(bndryId, 1, 1), SolverCell::IsInvalid)) {
8267 cerr <<
" found small cell with invalid bndry master. Please check! CellId is " <<
cellId <<
" bndryId is "
8268 << bndryId <<
", master is " << (
MInt)m_solver->a_slope(bndryId, 1, 1)
8269 <<
". Cell is no set to be non-small." << endl;
8271 filename <<
cellId <<
"_smallInvalidMaster.stl";
8273 filename << (
MInt)m_solver->a_slope(bndryId, 1, 1) <<
"_invalidMaster.stl";
8275 m_solver->a_slope(bndryId, 0, 0) = (
MFloat)
false;
8285 MInt countBigCluster = 0;
8286 MInt countSpecialcluster = 0;
8288 MInt masterBndryId = -1;
8291 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
8292 cellId = m_bndryCell[bndryId].m_cellId;
8293 if(!(
MInt)m_solver->a_slope(bndryId, 0, 0))
continue;
8294 if((
MInt)m_solver->a_slope(bndryId, 1, 0) == -1)
continue;
8295 m_bndryCell[bndryId].m_linkedCellId = (
MInt)m_solver->a_slope(bndryId, 1, 0);
8296 m_solver->a_slope(bndryId, 0, 1) = (
MFloat)
true;
8301 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
8302 if(!(
MInt)m_solver->a_slope(bndryId, 0, 0))
continue;
8303 if((
MInt)m_solver->a_slope(bndryId, 0, 1))
continue;
8304 if((
MInt)m_solver->a_slope(bndryId, 1, 1) == -1)
continue;
8306 master = (
MInt)m_solver->a_slope(bndryId, 1, 1);
8307 masterBndryId = m_solver->a_bndryId(master);
8309 if((
MInt)m_solver->a_slope(masterBndryId, 0, 0))
continue;
8311 m_bndryCell[bndryId].m_linkedCellId = master;
8312 m_solver->a_slope(bndryId, 0, 1) = (
MFloat)
true;
8318 MBool reconnected =
true;
8319 while(reconnected) {
8320 reconnected =
false;
8321 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
8322 if(!(
MInt)m_solver->a_slope(bndryId, 0, 0))
continue;
8323 if((
MInt)m_solver->a_slope(bndryId, 0, 1))
continue;
8324 if((
MInt)m_solver->a_slope(bndryId, 1, 1) == -1)
continue;
8326 master = (
MInt)m_solver->a_slope(bndryId, 1, 1);
8327 masterBndryId = m_solver->a_bndryId(master);
8329 if((
MInt)m_solver->a_slope(masterBndryId, 0, 0)) {
8330 if((
MInt)m_solver->a_slope(masterBndryId, 0, 1)) {
8331 m_bndryCell[bndryId].m_linkedCellId = m_bndryCell[masterBndryId].m_linkedCellId;
8332 m_solver->a_slope(bndryId, 0, 1) = (
MFloat)
true;
8344 stack<MInt> clusterStack;
8345 MInt startCellId = -1;
8346 MInt currentCell = -1;
8347 MInt clusterColor = -1;
8348 MInt nghbrBndryId = -1;
8352 MInt noClusterCells = 0;
8354 MBool changedColor =
true;
8355 MInt checkMasterBndryId;
8357 for(
MInt i = 0; i < (
MInt)counter / 2; i++) {
8358 clusterCounter[i] = 0;
8359 clusterFinished[i] = 0;
8362 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
8363 if(!(
MInt)m_solver->a_slope(bndryId, 0, 0))
continue;
8364 if((
MInt)m_solver->a_slope(bndryId, 0, 1))
continue;
8365 if((
MInt)m_solver->a_slope(bndryId, 2, 0) > -1)
continue;
8366 startCellId = bndryId;
8367 checkMasterBndryId = startCellId;
8369 m_solver->a_slope(startCellId, 2, 0) = (
MFloat)clusterColor;
8370 clusterCells[noClusterCells++] = startCellId;
8371 clusterCounter[clusterColor]++;
8374 checkMasterId = (
MInt)m_solver->a_slope(checkMasterBndryId, 1, 1);
8375 checkMasterBndryId = m_solver->a_bndryId(checkMasterId);
8376 if((
MInt)m_solver->a_slope(checkMasterBndryId, 2, 0) < 0) {
8377 m_solver->a_slope(checkMasterBndryId, 2, 0) = (
MFloat)clusterColor;
8378 clusterCells[noClusterCells++] = checkMasterBndryId;
8379 clusterCounter[clusterColor]++;
8384 changedColor =
true;
8385 while(changedColor) {
8386 changedColor =
false;
8387 for(
MInt checkBndryId = 0; checkBndryId < noCells; checkBndryId++) {
8388 if(!(
MInt)m_solver->a_slope(checkBndryId, 0, 0))
continue;
8389 if((
MInt)m_solver->a_slope(checkBndryId, 0, 1))
continue;
8390 if((
MInt)m_solver->a_slope(checkBndryId, 2, 0) > -1)
continue;
8391 checkMasterId = (
MInt)m_solver->a_slope(checkBndryId, 1, 1);
8392 checkMasterBndryId = m_solver->a_bndryId(checkMasterId);
8393 if((
MInt)m_solver->a_slope(checkMasterBndryId, 2, 0) > -1) {
8394 m_solver->a_slope(checkBndryId, 2, 0) = m_solver->a_slope(checkMasterBndryId, 2, 0);
8395 clusterCells[noClusterCells++] = checkBndryId;
8396 clusterCounter[clusterColor]++;
8397 changedColor =
true;
8406 MFloat clusterVolume = F0;
8407 MInt maxVolumeCell = -1;
8409 MInt minClusterLevel = 1000;
8413 for(
MInt color = 0; color < clusterColor; color++) {
8417 minClusterLevel = 1000;
8418 for(
MInt cC = 0; cC < clusterCounter[color]; cC++) {
8419 currentCell = clusterCells[cC +
index];
8420 cellId = m_bndryCells->a[currentCell].m_cellId;
8421 clusterVolume += m_bndryCell[currentCell].m_volume;
8422 if(m_bndryCell[currentCell].m_volume > maxVolume) {
8423 maxVolume = m_bndryCells->a[currentCell].m_volume;
8424 maxVolumeCell = currentCell;
8426 if(m_solver->a_level(cellId) < minClusterLevel) minClusterLevel = m_solver->a_level(cellId);
8429 if(clusterVolume / m_solver->grid().gridCellVolume(minClusterLevel) >= m_volumeLimitWall) {
8431 m_solver->a_slope(maxVolumeCell, 0, 0) = (
MFloat)
false;
8432 m_solver->a_slope(maxVolumeCell, 0, 1) = (
MFloat)
true;
8433 m_solver->a_slope(maxVolumeCell, 1, 0) = (
MFloat)-1;
8434 m_solver->a_slope(maxVolumeCell, 1, 1) = (
MFloat)-1;
8435 m_bndryCell[maxVolumeCell].m_linkedCellId = -1;
8439 for(
MInt cC = 0; cC < clusterCounter[color]; cC++) {
8440 currentCell = clusterCells[cC +
index];
8441 if(currentCell == maxVolumeCell) {
8444 cellId = m_bndryCells->a[currentCell].m_cellId;
8445 m_solver->a_slope(currentCell, 0, 1) = (
MFloat)
true;
8446 m_solver->a_slope(currentCell, 1, 1) = (
MFloat)m_bndryCells->a[maxVolumeCell].m_cellId;
8448 m_bndryCell[currentCell].m_linkedCellId = m_bndryCell[maxVolumeCell].m_cellId;
8453 index += clusterCounter[color];
8454 clusterFinished[color] = 1;
8456 index += clusterCounter[color];
8465 const MInt maxNeighbors = 20;
8466 MInt clusterNeighbors[maxNeighbors];
8467 MInt noClusterNeighbors = 0;
8468 MInt clusterCentroid[3] = {0, 0, 0};
8469 MFloat minDist = 1000000000.0;
8470 MInt minDistNghbr = -1;
8473 for(
MInt color = 0; color < clusterColor; color++) {
8474 noClusterNeighbors = 0;
8475 clusterCentroid[0] = F0;
8476 clusterCentroid[1] = F0;
8477 clusterCentroid[2] = F0;
8478 if(clusterFinished[color]) {
8479 index += clusterCounter[color];
8482 for(
MInt cC = 0; cC < clusterCounter[color]; cC++) {
8483 currentCell = clusterCells[cC +
index];
8484 cellId = m_bndryCells->a[currentCell].m_cellId;
8485 for(
MInt i = 0; i < nDim; i++) {
8486 clusterCentroid[i] += m_bndryCell[currentCell].m_volume * m_solver->a_coordinate(cellId, i);
8488 for(
MInt dir = 0; dir < m_noDirs; dir++) {
8489 for(
MInt nghbrID = m_solver->m_identNghbrIds[cellId * m_noDirs + dir];
8490 nghbrID < m_solver->m_identNghbrIds[cellId * m_noDirs + dir + 1];
8492 nghbrId = m_solver->m_storeNghbrIds[nghbrID];
8493 nghbrBndryId = m_solver->a_bndryId(nghbrId);
8494 if(nghbrBndryId < 0) {
8495 clusterNeighbors[noClusterNeighbors++] = nghbrId;
8496 }
else if(!(
MInt)m_solver->a_slope(nghbrBndryId, 0, 0)) {
8497 clusterNeighbors[noClusterNeighbors++] = nghbrId;
8498 }
else if((
MInt)m_solver->a_slope(nghbrBndryId, 0, 1) && (!(
MInt)m_solver->a_slope(nghbrBndryId, 2, 1))) {
8499 clusterNeighbors[noClusterNeighbors++] = nghbrId;
8507 if(noClusterNeighbors == 0) {
8508 cerr <<
" cluster with no neighbors found. this should not happen. isolated small cell island - ... " << endl;
8509 for(
MInt cC = 0; cC < clusterCounter[color]; cC++) {
8510 currentCell = clusterCells[cC +
index];
8511 cellId = m_bndryCells->a[currentCell].m_cellId;
8513 filename <<
cellId <<
"_cluster_" << color <<
".stl";
8514 recorrectCellCoordinates();
8515 writeStlFileOfCell(cellId, (filename.str()).c_str());
8516 rerecorrectCellCoordinates();
8518 for(
MInt cC = 0; cC < clusterCounter[color]; cC++) {
8519 currentCell = clusterCells[cC +
index];
8520 cellId = m_bndryCells->a[currentCell].m_cellId;
8522 m_solver->a_hasProperty(cellId, SolverCell::IsInvalid) =
true;
8523 cerr <<
" cell inactive"
8524 <<
", cellId: " <<
cellId << endl;
8530 m_solver->a_level(cellId) = -1;
8531 m_solver->a_hasProperty(cellId, SolverCell::IsInactive) =
true;
8532 m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel) =
false;
8533 m_solver->a_hasProperty(cellId, SolverCell::IsFlux) =
false;
8534 m_solver->a_hasProperty(cellId, SolverCell::IsActive) =
false;
8535 m_solver->a_isBndryGhostCell(cellId) =
false;
8537 index += clusterCounter[color];
8541 minDist = 1000000000.0;
8544 for(
MInt cN = 0; cN < noClusterNeighbors; cN++) {
8546 for(
MInt i = 0; i < nDim; i++)
8547 dist += (m_solver->a_coordinate(clusterNeighbors[cN], i) - clusterCentroid[i])
8548 * (m_solver->a_coordinate(clusterNeighbors[cN], i) - clusterCentroid[i]);
8550 if(
dist < minDist) {
8552 minDistNghbr = clusterNeighbors[cN];
8555 if(minDistNghbr == -1) {
8556 cerr <<
" cluster with no suitable neighbor found. this should not happen. cluster has " << noClusterNeighbors
8557 <<
" neighbors - exiting... " << endl;
8559 index += clusterCounter[color];
8563 for(
MInt cC = 0; cC < clusterCounter[color]; cC++) {
8564 currentCell = clusterCells[cC +
index];
8565 cellId = m_bndryCells->a[currentCell].m_cellId;
8566 master = minDistNghbr;
8567 masterBndryId = m_solver->a_bndryId(master);
8568 if(masterBndryId > -1 && (
MInt)m_solver->a_slope(masterBndryId, 0, 0)) {
8569 master = m_bndryCells->a[masterBndryId].m_linkedCellId;
8570 masterBndryId = m_solver->a_bndryId(master);
8572 m_solver->a_slope(currentCell, 0, 1) = (
MFloat)
true;
8573 m_solver->a_slope(currentCell, 1, 1) = (
MFloat)master;
8574 m_solver->a_slope(currentCell, 2, 1) = (
MFloat)
true;
8576 m_bndryCell[currentCell].m_linkedCellId = master;
8579 countSpecialcluster++;
8581 index += clusterCounter[color];
8582 clusterFinished[color] = 1;
8586 m_log <<
"Master cell statistics: " << endl;
8587 m_log <<
"__________________________________" << endl << endl;
8588 m_log <<
" * links to internal cells " << count1 << endl;
8589 m_log <<
" * links to boundary cells " << count2 << endl;
8590 m_log <<
" * chained links " << countChained << endl;
8591 m_log <<
" * chained biggest cluster cell " << countBigCluster << endl;
8592 m_log <<
" * chained to special master " << countSpecialcluster << endl;
8593 m_log <<
"__________________________________" << endl;
8596 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
8597 if((
MInt)m_solver->a_slope(bndryId, 0, 0) && (
MInt)m_solver->a_slope(bndryId, 0, 1)) {
8598 cellId = m_bndryCells->a[bndryId].m_cellId;
8599 if(!m_solver->a_hasProperty(cellId, SolverCell::IsInvalid)) {
8600 m_smallBndryCells->append();
8601 m_smallBndryCells->a[m_smallBndryCells->size() - 1] = bndryId;
8608 noCells = m_smallBndryCells->size();
8609 for(
MInt s = 0; s < noCells; s++) {
8610 m_solver->m_smallCellIds[s] = m_bndryCell[m_smallBndryCells->a[s]].m_cellId;
8611 m_solver->m_masterCellIds[s] = m_bndryCell[m_smallBndryCells->a[s]].m_linkedCellId;
8631template <MInt nDim,
class SysEqn>
8639 MInt noCells = m_solver->a_noCells();
8640 MInt noSmallCells = m_smallBndryCells->size();
8651 for(
MInt id = 0;
id < noCells;
id++) {
8652 m_solver->a_slope(
id, 1, 0) = m_solver->grid().gridCellVolume(m_solver->a_level(
id));
8653 for(
MInt i = 0; i < nDim; i++) {
8654 m_solver->a_slope(
id, 0, i) = m_solver->a_coordinate(
id, i);
8658 for(
MInt smallId = 0; smallId < noSmallCells; smallId++) {
8659 smallCell = m_smallBndryCells->a[smallId];
8660 smallCellId = m_bndryCell[smallCell].m_cellId;
8661 masterId = m_bndryCell[smallCell].m_linkedCellId;
8662 master = m_solver->a_bndryId(masterId);
8668 totalVolume = m_bndryCell[master].m_volume + m_bndryCell[smallCell].m_volume;
8670 for(
MInt v = 0; v < CV->noVariables; v++) {
8671 m_solver->a_variable(masterId, v) = (m_solver->a_variable(masterId, v) * m_bndryCell[master].m_volume
8672 + m_solver->a_variable(smallCellId, v) * m_bndryCell[smallCell].m_volume)
8674 m_solver->a_variable(smallCellId, v) = m_solver->a_variable(masterId, v);
8676 for(
MInt v = 0; v < PV->noVariables; v++) {
8677 m_solver->a_pvariable(masterId, v) = (m_solver->a_pvariable(masterId, v) * m_bndryCell[master].m_volume
8678 + m_solver->a_pvariable(smallCellId, v) * m_bndryCell[smallCell].m_volume)
8680 m_solver->a_pvariable(smallCellId, v) = m_solver->a_pvariable(masterId, v);
8684 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8686 coordinates = (m_solver->a_coordinate(masterId, spaceId) * m_bndryCell[master].m_volume
8687 + m_solver->a_coordinate(smallCellId, spaceId) * m_bndryCell[smallCell].m_volume)
8690 m_bndryCell[master].m_coordinates[spaceId] += (coordinates - m_solver->a_coordinate(masterId, spaceId));
8691 m_solver->a_coordinate(masterId, spaceId) = coordinates;
8698 (m_bndryCell[master].m_srfcs[0]->m_coordinates[spaceId] * m_bndryCell[master].m_srfcs[0]->m_area
8699 + m_bndryCell[smallCell].m_srfcs[0]->m_coordinates[spaceId] * m_bndryCell[smallCell].m_srfcs[0]->m_area)
8700 / (m_bndryCell[master].m_srfcs[0]->m_area + m_bndryCell[smallCell].m_srfcs[0]->m_area);
8702 m_bndryCell[master].m_srfcs[0]->m_coordinates[spaceId] = avrgCoordinates;
8706 oldNormalVector[spaceId] = m_bndryCell[master].m_srfcs[0]->m_normalVector[spaceId];
8707 m_bndryCell[master].m_srfcs[0]->m_normalVector[spaceId] =
8708 m_bndryCell[master].m_srfcs[0]->m_normalVector[spaceId] * m_bndryCell[master].m_srfcs[0]->m_area
8709 + m_bndryCell[smallCell].m_srfcs[0]->m_normalVector[spaceId] * m_bndryCell[smallCell].m_srfcs[0]->m_area;
8712 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8713 factor +=
POW2(m_bndryCell[master].m_srfcs[0]->m_normalVector[spaceId]);
8715 factor = sqrt(factor);
8716 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8717 m_bndryCell[master].m_srfcs[0]->m_normalVector[spaceId] =
8718 m_bndryCell[master].m_srfcs[0]->m_normalVector[spaceId] / factor;
8723 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8724 area += m_bndryCell[master].m_srfcs[0]->m_normalVector[spaceId]
8725 * (oldNormalVector[spaceId] * m_bndryCell[master].m_srfcs[0]->m_area
8726 + m_bndryCell[smallCell].m_srfcs[0]->m_normalVector[spaceId]
8727 * m_bndryCell[smallCell].m_srfcs[0]->m_area);
8730 m_bndryCell[master].m_srfcs[0]->m_area = area;
8733 m_bndryCell[master].m_volume = totalVolume;
8738 totalVolume = m_solver->a_slope(masterId, 1, 0) + m_bndryCell[smallCell].m_volume;
8740 for(
MInt v = 0; v < CV->noVariables; v++) {
8741 m_solver->a_variable(masterId, v) = (m_solver->a_variable(masterId, v) * m_solver->a_slope(masterId, 1, 0)
8742 + m_solver->a_variable(smallCellId, v) * m_bndryCell[smallCell].m_volume)
8744 m_solver->a_variable(smallCellId, v) = m_solver->a_variable(masterId, v);
8746 for(
MInt v = 0; v < PV->noVariables; v++) {
8747 m_solver->a_pvariable(masterId, v) = (m_solver->a_pvariable(masterId, v) * m_solver->a_slope(masterId, 1, 0)
8748 + m_solver->a_pvariable(smallCellId, v) * m_bndryCell[smallCell].m_volume)
8750 m_solver->a_pvariable(smallCellId, v) = m_solver->a_pvariable(masterId, v);
8754 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8756 coordinates = (m_solver->a_coordinate(masterId, spaceId) * m_solver->a_slope(masterId, 1, 0)
8757 + m_solver->a_coordinate(smallCellId, spaceId) * m_bndryCell[smallCell].m_volume)
8760 m_solver->a_coordinate(masterId, spaceId) = coordinates;
8762 m_solver->a_slope(masterId, 1, 0) = totalVolume;
8768 for(
MInt smallId = 0; smallId < noSmallCells; smallId++) {
8769 smallCell = m_smallBndryCells->a[smallId];
8770 smallCellId = m_bndryCell[smallCell].m_cellId;
8771 masterId = m_bndryCell[smallCell].m_linkedCellId;
8772 master = m_solver->a_bndryId(masterId);
8774 for(
MInt i = 0; i < nDim; i++) {
8775 m_bndryCell[smallCell].m_coordinates[i] +=
8776 (m_solver->a_coordinate(masterId, i) - m_solver->a_coordinate(smallCellId, i));
8777 m_solver->a_coordinate(smallCellId, i) = m_solver->a_coordinate(masterId, i);
8781 for(
MInt i = 0; i < nDim; i++) {
8782 m_bndryCell[smallCell].m_masterCoordinates[i] = m_solver->a_slope(masterId, 0, i);
8806template <MInt nDim,
class SysEqn>
8814 MInt noCells = m_solver->a_noCells();
8815 MInt noSmallCells = m_smallBndryCells->size();
8821 for(
MInt id = 0;
id < noCells;
id++) {
8822 m_solver->a_slope(
id, 1, 0) = m_solver->grid().gridCellVolume(m_solver->a_level(
id));
8823 for(
MInt i = 0; i < nDim; i++) {
8824 m_solver->a_slope(
id, 0, i) = m_solver->a_coordinate(
id, i);
8828 for(
MInt smallId = 0; smallId < noSmallCells; smallId++) {
8829 smallCell = m_smallBndryCells->a[smallId];
8830 smallCellId = m_bndryCell[smallCell].m_cellId;
8831 masterId = m_bndryCell[smallCell].m_linkedCellId;
8832 master = m_solver->a_bndryId(masterId);
8838 totalVolume = m_bndryCell[master].m_volume + m_bndryCell[smallCell].m_volume;
8840 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8842 coordinates = (m_solver->a_coordinate(masterId, spaceId) * m_bndryCell[master].m_volume
8843 + m_solver->a_coordinate(smallCellId, spaceId) * m_bndryCell[smallCell].m_volume)
8846 m_bndryCell[master].m_coordinates[spaceId] += (coordinates - m_solver->a_coordinate(masterId, spaceId));
8847 m_solver->a_coordinate(masterId, spaceId) = coordinates;
8851 m_bndryCell[master].m_volume = totalVolume;
8856 totalVolume = m_solver->a_slope(masterId, 1, 0) + m_bndryCell[smallCell].m_volume;
8858 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8860 coordinates = (m_solver->a_coordinate(masterId, spaceId) * m_solver->a_slope(masterId, 1, 0)
8861 + m_solver->a_coordinate(smallCellId, spaceId) * m_bndryCell[smallCell].m_volume)
8864 m_solver->a_coordinate(masterId, spaceId) = coordinates;
8868 m_solver->a_slope(masterId, 1, 0) = totalVolume;
8875 for(
MInt smallId = 0; smallId < noSmallCells; smallId++) {
8876 smallCell = m_smallBndryCells->a[smallId];
8877 smallCellId = m_bndryCell[smallCell].m_cellId;
8878 masterId = m_bndryCell[smallCell].m_linkedCellId;
8879 master = m_solver->a_bndryId(masterId);
8881 for(
MInt i = 0; i < nDim; i++) {
8882 m_bndryCell[smallCell].m_coordinates[i] +=
8883 (m_solver->a_coordinate(masterId, i) - m_solver->a_coordinate(smallCellId, i));
8884 m_solver->a_coordinate(smallCellId, i) = m_solver->a_coordinate(masterId, i);
8888 for(
MInt i = 0; i < nDim; i++) {
8889 m_bndryCell[smallCell].m_masterCoordinates[i] = m_solver->a_slope(masterId, 0, i);
8907template <MInt nDim,
class SysEqn>
8914 MInt noCells = m_bndryCells->size();
8929 for(
MInt level = m_solver->maxRefinementLevel() - 1; level > 0; level--) {
8931 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
8933 cellId = m_bndryCells->a[bndryId].m_cellId;
8934 if(m_solver->a_level(cellId) == level) {
8935 noChildren = m_solver->c_noChildren(cellId);
8937 if(noChildren > 0) {
8940 bndryCellVolumes = 0;
8942 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8943 bndryXyz[spaceId] = 0;
8944 cellXyz[spaceId] = 0;
8945 srfcXyz[spaceId] = 0;
8949 for(
MInt childId = 0; childId <
IPOW2(nDim); childId++) {
8950 if(m_solver->c_childId(cellId, childId) == -1)
continue;
8952 childCellId = m_solver->c_childId(cellId, childId);
8954 if(m_solver->a_bndryId(childCellId) > -1) {
8955 volume += m_bndryCells->a[m_solver->a_bndryId(childCellId)].m_volume;
8956 bndryCellVolumes += m_bndryCells->a[m_solver->a_bndryId(childCellId)].m_volume;
8958 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8959 bndryXyz[spaceId] += m_solver->a_coordinate(childCellId, spaceId)
8960 * m_bndryCells->a[m_solver->a_bndryId(childCellId)].m_volume;
8964 srfcArea += m_bndryCells->a[m_solver->a_bndryId(childCellId)].m_srfcs[0]->m_area;
8965 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8966 srfcXyz[spaceId] += m_bndryCells->a[m_solver->a_bndryId(childCellId)].m_srfcs[0]->m_coordinates[spaceId]
8967 * m_bndryCells->a[m_solver->a_bndryId(childCellId)].m_srfcs[0]->m_area;
8971 childVolume = m_solver->c_cellLengthAtCell(childCellId);
8972 for(
MInt spaceId = 1; spaceId < nDim; spaceId++) {
8973 childVolume *= m_solver->c_cellLengthAtCell(childCellId);
8975 volume += childVolume;
8976 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8977 cellXyz[spaceId] += m_solver->a_coordinate(childCellId, spaceId) * childVolume;
8982 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8983 cellXyz[spaceId] += bndryXyz[spaceId];
8984 cellXyz[spaceId] = cellXyz[spaceId] / volume;
8985 bndryXyz[spaceId] = bndryXyz[spaceId] / bndryCellVolumes;
8986 srfcXyz[spaceId] = srfcXyz[spaceId] / srfcArea;
8993 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
8994 m_bndryCells->a[bndryId].m_coordinates[spaceId] +=
8995 cellXyz[spaceId] - m_solver->a_coordinate(cellId, spaceId);
8996 m_solver->a_coordinate(cellId, spaceId) = cellXyz[spaceId];
8997 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[spaceId] = srfcXyz[spaceId];
9001 m_bndryCells->a[bndryId].m_volume = volume;
9015template <MInt nDim,
class SysEqn>
9021 MInt noCVars = CV->noVariables;
9022 MInt noFVars = FV->noVariables;
9023 MInt noCells = m_smallBndryCells->size();
9026 for(
MInt smallCellId = 0; smallCellId < noCells; smallCellId++) {
9027 bndryId = m_smallBndryCells->a[smallCellId];
9028 cellId = m_bndryCells->a[bndryId].m_cellId;
9030 for(
MInt varId = 0; varId < noCVars; varId++) {
9031 m_solver->a_tau(cellId, varId) = 0;
9033 for(
MInt varId = 0; varId < noFVars; varId++) {
9034 m_solver->a_rightHandSide(cellId, varId) = 0;
9044template <MInt nDim,
class SysEqn>
9046 const MUint noVars = PV->noVariables;
9047 const MUint noSlopes = nDim * noVars;
9048 const MUint noSmallCells = m_smallBndryCells->size();
9049 const MInt*
const RESTRICT smallCellIds = m_solver->m_smallCellIds;
9050 const MInt*
const RESTRICT masterCellIds = m_solver->m_masterCellIds;
9051 MFloat*
const RESTRICT slope = &m_solver->a_slope(0, 0, 0);
9053 for(
MUint c = 0; c < noSmallCells; ++c) {
9054 const MUint scId = smallCellIds[c];
9055 const MUint mcId = masterCellIds[c];
9056 MFloat*
const RESTRICT smallCellSlopes = slope + scId * noSlopes;
9057 const MFloat*
const RESTRICT masterCellSlopes = slope + mcId * noSlopes;
9058 for(
MUint slopeId = 0; slopeId < noSlopes; ++slopeId) {
9059 smallCellSlopes[slopeId] = masterCellSlopes[slopeId];
9069template <MInt nDim,
class SysEqn>
9071 const MUint noBndrySurfaces = m_noBoundarySurfaces;
9072 const MUint noVars = PV->noVariables;
9073 const MUint surfaceVarMemory = 2 * noVars;
9074 MFloat*
const RESTRICT surfaceVar = &m_solver->a_surfaceVariable(0, 0, 0);
9075 const MInt*
const RESTRICT nghbrCellIds = &m_solver->a_surfaceNghbrCellId(0, 0);
9076 const MFloat*
const RESTRICT vars = &m_solver->a_pvariable(0, 0);
9079 for(
MUint bs = 0; bs < noBndrySurfaces; ++bs) {
9080 const MUint srfcId = m_boundarySurfaces[bs];
9081 const MUint srfcOffset = srfcId * surfaceVarMemory;
9082 const MFloat*
const RESTRICT vars0 = vars + nghbrCellIds[srfcId * 2] * noVars;
9083 const MFloat*
const RESTRICT vars1 = vars + nghbrCellIds[srfcId * 2 + 1] * noVars;
9084 MFloat*
const RESTRICT surfaceVar0 = surfaceVar + srfcOffset;
9085 MFloat*
const RESTRICT surfaceVar1 = surfaceVar0 + noVars;
9086 for(
MUint v = 0; v < noVars; ++v) {
9087 const MFloat tmp = F1B2 * (vars0[v] + vars1[v]);
9088 surfaceVar0[v] = tmp;
9089 surfaceVar1[v] = tmp;
9093 const MInt noBndryCells = m_bndryCells->size();
9094 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
9095 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
9096 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
9097 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
9098 for(
MInt i = 0; i < nDim; i++) {
9099 const MInt srfcId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_srfcId[i];
9100 if(srfcId < 0)
continue;
9101 const MUint srfcOffset = srfcId * surfaceVarMemory;
9102 MFloat*
const RESTRICT surfaceVar0 = surfaceVar + srfcOffset;
9103 MFloat*
const RESTRICT surfaceVar1 = surfaceVar0 + noVars;
9104 for(
MUint v = 0; v < noVars; ++v) {
9105 surfaceVar0[v] = m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v];
9106 surfaceVar1[v] = m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[v];
9128template <MInt nDim,
class SysEqn>
9130 const MUint noSmallCells = m_smallBndryCells->size();
9131 const MUint noVars = CV->noVariables;
9132 const MInt*
const RESTRICT smallIds = &m_smallBndryCells->a[0];
9134 MFloat*
const RESTRICT vars = &m_solver->a_variable(0, 0);
9137 for(
MUint smallId = 0; smallId < noSmallCells; ++smallId) {
9138 const MUint smallCell = smallIds[smallId];
9143 MFloat*
const RESTRICT smallCellVars = vars + smallCellId * noVars;
9144 const MFloat*
const RESTRICT masterCellVars = vars + masterId * noVars;
9145 for(
MUint v = 0; v < noVars; ++v) {
9146 smallCellVars[v] = masterCellVars[v];
9156template <MInt nDim,
class SysEqn>
9160 const MInt noBndryCells = m_bndryCells->size();
9161 const MInt maxNoNghbrs = 200;
9162 const MInt noLayersStencil = m_noFluxRedistributionLayers;
9163 if(noDomains() > 1 && noLayersStencil >
mMin(m_noFluxRedistributionLayers, m_solver->noHaloLayers())) {
9164 cerr <<
"Warning: noLayersStencil smaller than flux redistribution layers!" << endl;
9171 for(
MInt s = 0; s < FvBndryCell<nDim, SysEqn>::m_maxNoSurfaces; s++) {
9173 if(dummyIds(s) < (m_solver->a_noCells())) {
9175 "Increase cell collector! " + to_string(m_solver->a_noCells()) +
" "
9180 if(updateOnlyBndryCndId < 0) {
9181 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
9182 m_bndryCell[bndryId].m_recNghbrIds.resize(0);
9183 m_bndryCell[bndryId].m_cellVarsRecConst.resize(0);
9184 m_bndryCell[bndryId].m_cellDerivRecConst.resize(0);
9185 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
9186 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.resize(0);
9190 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
9191 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
9192 if(m_solver->a_isPeriodic(cellId) || m_solver->a_isHalo(cellId)) {
9193 m_bndryCell[bndryId].m_cellVarsRecConst.resize(0);
9194 m_bndryCell[bndryId].m_cellDerivRecConst.resize(0);
9198 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitChild))
continue;
9199 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) skip =
true;
9200 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient)) skip =
true;
9201 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitCell)) skip =
true;
9202 if(m_solver->c_noChildren(cellId) > 0) skip =
true;
9204 m_bndryCell[bndryId].m_recNghbrIds.resize(0);
9205 m_bndryCell[bndryId].m_cellVarsRecConst.resize(0);
9206 m_bndryCell[bndryId].m_cellDerivRecConst.resize(0);
9207 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
9208 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.resize(0);
9214 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
9215 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
9216 const MInt noSrfcs = m_bndryCells->a[bndryId].m_noSrfcs;
9217 MInt gridcellId = cellId;
9218 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitClone)) {
9219 gridcellId = m_solver->m_splitChildToSplitCell.find(cellId)->second;
9223 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
9224 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient))
continue;
9225 if(!m_solver->a_hasProperty(cellId, SolverCell::IsSplitChild) && m_solver->c_noChildren(gridcellId) > 0)
continue;
9226 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitCell))
continue;
9229 if(updateOnlyBndryCndId > -1) {
9231 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9232 if(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId == updateOnlyBndryCndId) skip =
false;
9237 m_bndryCell[bndryId].m_recNghbrIds.resize(0);
9238 m_bndryCell[bndryId].m_cellVarsRecConst.resize(0);
9239 m_bndryCell[bndryId].m_cellDerivRecConst.resize(0);
9240 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
9241 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.resize(0);
9245 const MInt rootCell = (m_solver->a_hasProperty(cellId, SolverCell::IsSplitChild)
9246 || m_solver->a_hasProperty(cellId, SolverCell::IsSplitClone))
9247 ? m_solver->getAssociatedInternalCell(cellId)
9249 ASSERT(rootCell > -1 && rootCell < m_solver->a_noCells(),
"");
9250 const MInt addPoints = noSrfcs + 1;
9251 const MInt recSize = m_solver->template getAdjacentLeafCells<1, true>(rootCell, noLayersStencil, nghbrList, layerId)
9254 if(recSize > maxNoNghbrs) {
9256 "too many nghbrs " + to_string(recSize) +
" " + to_string(cellId) +
" "
9257 + to_string(m_solver->a_isHalo(cellId)));
9259 if(recSize < nDim + 2) {
9260 cerr <<
"not enough neighbors " + to_string(recSize) +
" " + to_string(recSize - addPoints) +
" "
9262 <<
" " << m_solver->a_isHalo(cellId) << endl;
9265 for(
MInt k = recSize - 1; k >= addPoints; k--) {
9266 ASSERT(k - addPoints > -1,
"");
9267 ASSERT(nghbrList(k - addPoints) > -1 && nghbrList(k - addPoints) < m_solver->a_noCells(),
"");
9268 nghbrList(k) = nghbrList(k - addPoints);
9269 layerId(k) = layerId(k - addPoints);
9271 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9272 nghbrList(srfc) = dummyIds(srfc);
9275 nghbrList(noSrfcs) = cellId;
9276 layerId(noSrfcs) = 0;
9278 m_bndryCell[bndryId].m_recNghbrIds.resize(recSize);
9279 m_bndryCell[bndryId].m_cellVarsRecConst.resize(recSize);
9280 for(
MInt k = 0; k < recSize; k++) {
9281 m_bndryCell[bndryId].m_recNghbrIds[k] = nghbrList(k);
9282 m_bndryCell[bndryId].m_cellVarsRecConst[k] = (
MFloat)layerId(k);
9292template <MInt nDim,
class SysEqn>
9296 const MInt minRecDim = nDim + 1;
9298 const MInt maxRecDim = m_secondOrderRec ? (
IPOW2(nDim) + 2) : minRecDim;
9299 const MInt noBndryCells = m_bndryCells->size();
9300 const MInt maxNoSrfcs = 14;
9304 const MInt maxNoNghbrs = 200;
9305 const MInt noLayersStencil = m_noFluxRedistributionLayers;
9306 const MFloat condNumThreshold = 1e7;
9307 MBool& firstRun = m_static_computeImagePointRecConst_firstRun;
9308 if(noDomains() > 1 && noLayersStencil >
mMin(m_noFluxRedistributionLayers, m_solver->noHaloLayers())) {
9309 cerr <<
"Warning: noLayersStencil smaller than flux redistribution layers!" << endl;
9331 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
9332 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
9333 const MInt noSrfcs = m_bndryCells->a[bndryId].m_noSrfcs;
9334 MInt gridcellId = cellId;
9335 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitClone)) {
9336 gridcellId = m_solver->m_splitChildToSplitCell.find(cellId)->second;
9340 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
9341 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient))
continue;
9342 if(!m_solver->a_hasProperty(cellId, SolverCell::IsSplitChild) && m_solver->c_noChildren(gridcellId) > 0)
continue;
9343 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitCell))
continue;
9344 if(m_bndryCell[bndryId].m_recNghbrIds.size() == 0)
continue;
9346 if(updateOnlyBndryCndId > -1) {
9348 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9349 if(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId == updateOnlyBndryCndId) skip =
false;
9354 const MFloat normalizationFactor =
9355 FPOW2(m_solver->a_level(cellId))
9356 / m_solver->c_cellLengthAtLevel(0);
9358 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9361 deltaNSurf[srfc] = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance;
9362 for(
MInt i = 0; i < nDim; i++) {
9364 normal(srfc, i) = m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVectorCentroid[i];
9378 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9379 for(
MInt i = 0; i < nDim; i++) {
9382 deltaXSurfProj(srfc, i) = -deltaNSurf[srfc] * normal(srfc, i);
9383 deltaXSurf(srfc, i) = deltaXSurfProj(srfc, i);
9390 imagePoint(srfc, i) =
9391 m_solver->a_coordinate(cellId, i)
9392 +
mMax(F0, (
mMax(deltaNSurf[srfc], F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId)))
9393 - deltaNSurf[srfc]))
9395 surfCoords(srfc, i) = m_solver->a_coordinate(cellId, i) - deltaNSurf[srfc] * normal(srfc, i);
9398 const MInt dummyId = m_bndryCell[bndryId].m_recNghbrIds[srfc];
9399 dummyLevel[srfc] = m_solver->a_level(cellId);
9400 dummyCellVolume(srfc) = m_solver->grid().gridCellVolume(m_solver->a_level(cellId));
9401 m_solver->a_bndryId(dummyId) = -1;
9402 for(
MInt i = 0; i < nDim; i++) {
9403 dummyCoordinates(srfc, i) = m_solver->a_coordinate(cellId, i) + deltaXSurfProj(srfc, i);
9407 const MInt recSize = m_bndryCell[bndryId].m_recNghbrIds.size();
9408 const MInt noNghbrIds = recSize;
9409 for(
MInt k = 0; k < noNghbrIds; k++) {
9410 layerId(k) = (
MInt)m_bndryCell[bndryId].m_cellVarsRecConst[k];
9411 if(k <= noSrfcs && layerId(k) != 0) {
9412 mTerm(1, AT_,
"FvBndryCndXD<nDim, SysEqn>::computeImagePointRecConst: Inconsistency 0.");
9414 if(k > noSrfcs && (layerId(k) < 1 || layerId(k) > noLayersStencil)) {
9415 mTerm(1, AT_,
"FvBndryCndXD::computeImagePointRecConst: Inconsistency 0b.");
9418 m_bndryCell[bndryId].m_cellVarsRecConst.resize(0);
9424 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9425 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.resize(recSize);
9426 ASSERT(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.size()
9427 == m_bndryCell[bndryId].m_recNghbrIds.size(),
9429 for(
MInt k = 0; k < noNghbrIds; k++) {
9430 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[k];
9431 const MFloat*
const nghbrCoord =
9432 (k < noSrfcs) ? &dummyCoordinates(k, 0) : &(m_solver->a_coordinate(nghbrId, 0));
9433 const MInt nghbrLevel = (k < noSrfcs) ? dummyLevel[k] : m_solver->a_level(nghbrId);
9434 const MFloat nghbrCellVolume = (k < noSrfcs) ? dummyCellVolume(k) : m_solver->a_cellVolume(nghbrId);
9437 for(
MInt i = 0; i < nDim; i++) {
9438 mat(k, 1 + i) = (nghbrCoord[i] - imagePoint(srfc, i)) * normalizationFactor;
9439 dx +=
POW2(nghbrCoord[i] - imagePoint(srfc, i));
9441 weights(k) =
maia::math::RBF(dx,
POW2(m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId))))
9442 *
maia::math::deltaFun(nghbrCellVolume / m_solver->grid().gridCellVolume(nghbrLevel), 1e-6, 0.1);
9446 if(layerId(k) > 1) {
9452 const MInt recDim = minRecDim;
9455 maxCondNum0 =
mMax(maxCondNum0, condNum);
9456 avgCondNum0 += condNum;
9458 if(condNum < F0 || condNum > condNumThreshold) {
9459 cerr <<
"() Warning: Image-point SVD failed (" << condNum <<
") cell " << cellId <<
" ("
9460 << m_solver->c_globalId(cellId) <<
") "
9461 <<
", " << recSize <<
"x" << nDim + 1 <<
" vfrac "
9462 << m_bndryCells->a[bndryId].m_volume / m_solver->grid().gridCellVolume(m_solver->a_level(cellId))
9464 for(
MInt k = 0; k < recSize; k++) {
9465 cerr << m_bndryCell[bndryId].m_recNghbrIds[k] <<
" ";
9468 for(
MInt k = 0; k < recSize; k++) {
9469 cerr << weights(k) <<
" ";
9472 for(
MInt k = 0; k < recSize; k++) {
9473 const MFloat nghbrCellVolume =
9474 (k < noSrfcs) ? dummyCellVolume(k) : m_solver->a_cellVolume(m_bndryCell[bndryId].m_recNghbrIds[k]);
9475 cerr << nghbrCellVolume <<
" ";
9483 for(
MInt k = 0; k < noNghbrIds; k++) {
9484 for(
MInt i = 0; i < nDim; i++) {
9485 matInv(1 + i, k) *= normalizationFactor;
9488 for(
MInt k = 0; k < noNghbrIds; k++) {
9489 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst[k] = matInv(0, k);
9492 MFloat phiSum = m_bndryCells->a[bndryId].m_gapDistance;
9494 const MFloat dx0 = F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
9495 const MFloat dx1 = F2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
9497 F1 -
mMax(F0,
mMin(F1, (phiSum - dx0) / (dx1 - dx0)));
9499 if(gapInd > 1e-12) {
9500 for(
MInt k = 0; k < noNghbrIds; k++) {
9501 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst[k] *= (F1 - gapInd);
9503 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst[noSrfcs] += gapInd;
9516 m_log <<
"Image point average (maximum) condition number: " << avgCondNum0 / condCnt0 <<
" (" << maxCondNum0
9517 <<
"), normal stress: " << avgCondNum1 / condCnt1 <<
" (" << maxCondNum1 <<
")." << endl;
9521 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
9522 const MInt noSrfcs = m_bndryCells->a[bndryId].m_noSrfcs;
9523 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9524 if(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.size()
9525 != m_bndryCell[bndryId].m_recNghbrIds.size()) {
9526 cerr << domainId() <<
": " << bndryId <<
" " << srfc <<
" " << m_bndryCell[bndryId].m_recNghbrIds.size() <<
" "
9527 << m_bndryCell[bndryId].m_srfcVariables[srfc]->m_imagePointRecConst.size() << endl;
9528 mTerm(1, AT_,
"FvBndryCndXD::computeImagePointRecConst: Inconsistency 1.");
9548template <MInt nDim,
class SysEqn>
9552 if(m_smallCellRHSCorrection) {
9556 const MInt minRecDim = nDim + 1;
9557 const MInt medRecDim = 2 * nDim + 1;
9558 const MInt maxRecDim = m_secondOrderRec ? (
IPOW2(nDim) + 2) : minRecDim;
9559 const MInt noBndryCells = m_bndryCells->size();
9560 const MInt maxNoSrfcs = 14;
9561 const MInt volFactor = nDim == 3 ? 4 : 2;
9565 const MInt maxNoNghbrs = 200;
9566 const MInt noLayersStencil = m_noFluxRedistributionLayers;
9567 const MFloat condNumThreshold = 1e7;
9568 MBool& firstRun = m_static_initSmallCellCorrection_firstRun;
9569 if(noLayersStencil >
mMin(m_noFluxRedistributionLayers, m_solver->noHaloLayers())) {
9570 cerr <<
"Warning: noLayersStencil smaller than flux redistribution layers!" << endl;
9572 if(firstRun)
m_log <<
"Initializing small cell treatment." << endl;
9590 m_smallCutCells.clear();
9591 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
9592 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
9593 const MInt noSrfcs = m_bndryCells->a[bndryId].m_noSrfcs;
9594 MInt gridcellId = cellId;
9595 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitClone)) {
9596 gridcellId = m_solver->m_splitChildToSplitCell.find(cellId)->second;
9599 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
9600 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient))
continue;
9601 if(!m_solver->a_hasProperty(cellId, SolverCell::IsSplitChild) && m_solver->c_noChildren(gridcellId) > 0)
continue;
9602 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitCell))
continue;
9603 if(m_solver->a_isPeriodic(cellId))
continue;
9604 if(m_solver->a_isHalo(cellId))
continue;
9610 (m_solver->m_localTS)
9611 ? m_solver->a_cellVolume(cellId) / m_solver->grid().gridCellVolume(m_solver->a_level(cellId))
9612 : m_solver->a_cellVolume(cellId) / m_solver->grid().gridCellVolume(m_solver->maxLevel());
9613 MBool atWall =
false;
9614 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
9615 if(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId / 1000 == 3) atWall =
true;
9617 MFloat volumeLimit = atWall ? m_volumeLimitWall : m_volumeLimitOther;
9619 if(m_solver->a_level(cellId) < m_solver->maxLevel() && m_solver->m_bndryLevelJumps) {
9620 volumeLimit = volumeLimit * volFactor * (m_solver->maxLevel() - m_solver->a_level(cellId));
9623 if(vfrac < volumeLimit) {
9624 m_smallCutCells.push_back(bndryId);
9630 if(updateOnlyBndryCndId > -1) {
9632 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9633 if(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId == updateOnlyBndryCndId) skip =
false;
9636 if(skip && vfrac < volumeLimit
9637 && m_bndryCell[bndryId].m_cellVarsRecConst.size()
9638 !=
IPOW2(noSrfcs) * m_bndryCell[bndryId].m_recNghbrIds.size()) {
9639 cerr << domainId() <<
": strange skip " << cellId <<
" " << m_solver->c_globalId(cellId) << endl;
9643 const MFloat normalizationFactor =
9644 FPOW2(m_solver->a_level(cellId))
9645 / m_solver->c_cellLengthAtLevel(0);
9646 const MInt recSize = m_bndryCell[bndryId].m_recNghbrIds.size();
9647 ASSERT(recSize > 0,
"");
9653 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9654 deltaNSurf[srfc] = F0;
9655 for(
MInt i = 0; i < nDim; i++) {
9656 normal(srfc, i) = m_bndryCell[bndryId].m_srfcs[srfc]->m_normalVector[i];
9659 * (m_solver->a_coordinate(cellId, i) - m_bndryCell[bndryId].m_srfcs[srfc]->m_coordinates[i]);
9661 for(
MInt i = 0; i < nDim; i++) {
9662 deltaXSurf(srfc, i) = m_bndryCell[bndryId].m_srfcs[srfc]->m_coordinates[i]
9663 - m_solver->a_coordinate(cellId, i);
9664 deltaXSurfProj(srfc, i) = -
mMax(1e-12, deltaNSurf[srfc]) * normal(srfc, i);
9665 deltaXSurf(srfc, i) = deltaXSurfProj(srfc, i);
9668 const MInt dummyId = m_bndryCell[bndryId].m_recNghbrIds[srfc];
9669 dummyLevel[srfc] = m_solver->a_level(cellId);
9670 dummyCellVolume(srfc) = m_solver->grid().gridCellVolume(m_solver->a_level(cellId));
9671 m_solver->a_bndryId(dummyId) = -1;
9672 for(
MInt i = 0; i < nDim; i++) {
9673 dummyCoordinates(srfc, i) = m_solver->a_coordinate(cellId, i) + deltaXSurfProj(srfc, i);
9681 for(
MInt k = 0; k < recSize; k++) {
9682 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[k];
9683 const MInt nghbrLevel = (k < noSrfcs) ? dummyLevel[k] : m_solver->a_level(nghbrId);
9684 const MFloat nghbrCellVolume = (k < noSrfcs) ? dummyCellVolume(k) : m_solver->a_cellVolume(nghbrId);
9685 counter += (m_solver->a_bndryId(nghbrId) > -1)
9686 ?
maia::math::deltaFun(nghbrCellVolume / m_solver->grid().gridCellVolume(nghbrLevel), 1e-8, F1)
9690 minRecDim, (counter > (
MFloat)maxRecDim) ? maxRecDim : ((counter > (
MFloat)medRecDim) ? medRecDim : minRecDim));
9692 const MInt recDim2 = minRecDim;
9693 ASSERT(minRecDim,
"");
9694 ASSERT(medRecDim,
"");
9696 for(
MInt k = 0; k < recSize; k++) {
9697 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[k];
9698 const MFloat*
const nghbrCoord = (k < noSrfcs) ? &dummyCoordinates(k, 0) : &(m_solver->a_coordinate(nghbrId, 0));
9699 const MInt nghbrLevel = (k < noSrfcs) ? dummyLevel[k] : m_solver->a_level(nghbrId);
9700 const MFloat nghbrCellVolume = (k < noSrfcs) ? dummyCellVolume(k) : m_solver->a_cellVolume(nghbrId);
9703 for(
MInt i = 0; i < nDim; i++) {
9704 deltaX[i] = (nghbrCoord[i] - m_solver->a_coordinate(cellId, i)) * normalizationFactor;
9705 dx +=
POW2(nghbrCoord[i] - m_solver->a_coordinate(cellId, i));
9709 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9711 for(
MInt i = 0; i < nDim; i++) {
9712 dn += (nghbrCoord[i] - m_bndryCell[bndryId].m_srfcs[srfc]->m_coordinates[i]) * normal(srfc, i);
9714 MFloat deltan = 0.1 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
9715 nfac *=
mMin(F1,
mMax(F0, (dn + deltan) / deltan));
9718 if(noSrfcs > 1) nfac = F1;
9721 weights(k) =
maia::math::RBF(dx,
POW2(m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId))))
9722 *
maia::math::deltaFun(nghbrCellVolume / m_solver->grid().gridCellVolume(nghbrLevel), 1e-8, 1.0);
9724 if(k > noSrfcs) weights(k) *= nfac;
9729 for(
MInt i = 0; i < nDim; i++) {
9730 mat(k, cnt) = deltaX[i];
9733 for(
MInt i = 0; i < nDim; i++) {
9734 if(cnt >= recDim)
continue;
9735 mat(k, cnt) = F1B2 *
POW2(deltaX[i]);
9738 for(
MInt i = 0; i < nDim; i++) {
9739 for(
MInt j = i + 1; j < nDim; j++) {
9740 if(cnt >= recDim)
continue;
9741 mat(k, cnt) = deltaX[i] * deltaX[j];
9751 maxCondNum0 =
mMax(maxCondNum0, condNum);
9752 avgCondNum0 += condNum;
9754 if(condNum < F0 || condNum > condNumThreshold) {
9755 cerr <<
"(1) Warning: SVD failed (" << condNum <<
") cell " << cellId <<
" (" << m_solver->c_globalId(cellId)
9757 <<
", " << recSize <<
"x" << recDim <<
" vfrac " << setprecision(14)
9758 << m_bndryCells->a[bndryId].m_volume / m_solver->grid().gridCellVolume(m_solver->a_level(cellId))
9759 << setprecision(6) <<
", p13: " << m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)
9760 <<
", p15: " << m_solver->a_isHalo(cellId) <<
" at timestep " <<
globalTimeStep
9761 <<
", coords: " << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 10) <<
" "
9762 << m_solver->a_coordinate(cellId,
mMin(nDim - 1, 2)) << endl;
9767 if(rank >= min(recSize, minRecDim)) {
9768 cerr <<
"Succeeded using reduced-order reconstruction." << endl;
9770 cerr <<
"Failed also with reduced-order reconstruction, using fallback solution." << endl;
9774 for(
MInt k = 0; k < recSize; k++) {
9776 for(
MInt i = 0; i < nDim; i++) {
9777 matInv(cnt, k) *= normalizationFactor;
9780 for(cnt = nDim + 1; cnt < recDim; cnt++) {
9781 matInv(cnt, k) *=
POW2(normalizationFactor);
9789 m_bndryCell[bndryId].m_cellVarsRecConst.resize(recSize *
IPOW2(noSrfcs));
9790 for(
MInt p = 0; p < recSize; p++) {
9791 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * p] = matInv(0, p);
9795 MInt noDerivs = maxRecDim - 1;
9796 m_bndryCell[bndryId].m_cellDerivRecConst.resize(noDerivs * recSize);
9797 std::fill_n(m_bndryCell[bndryId].m_cellDerivRecConst.begin(), noDerivs * recSize, F0);
9798 for(
MInt k = 1; k < recDim; k++) {
9800 for(
MInt p = 0; p < recSize; p++) {
9801 m_bndryCell[bndryId].m_cellDerivRecConst[noDerivs * p +
id] = matInv(k, p);
9805 if(condNum < F0 || condNum > condNumThreshold) {
9807 for(
MInt k = 0; k < recSize; k++) {
9808 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[k];
9809 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k] = F0;
9810 if(nghbrId == cellId)
continue;
9812 for(
MInt i = 0; i < nDim; i++) {
9813 dx +=
POW2(m_solver->a_coordinate(nghbrId, i) - m_solver->a_coordinate(cellId, i));
9815 MFloat volume = m_solver->a_cellVolume(nghbrId);
9817 maia::math::deltaFun(volume / m_solver->grid().gridCellVolume(m_solver->a_level(nghbrId)), 1e-8, 1.0);
9818 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k] = fac /
mMax(1e-14, sqrt(dx));
9819 sumcnt += m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k];
9821 for(
MInt k = 0; k < recSize; k++) {
9822 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k] /= sumcnt;
9828 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9829 for(
MInt k = 0; k < recDim; k++) {
9830 backup(srfc, k) = mat(srfc, k);
9835 if(m_bndryCell[bndryId].m_srfcVariables[srfc]->m_variablesType[PV->RHO] ==
BC_ISOTHERMAL) {
9841 for(
MInt s = 1; s <
IPOW2(noSrfcs); s++) {
9842 bitset<maxNoSrfcs> NeumannCode(s);
9843 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
9844 if(NeumannCode.test(srfc)) {
9847 const MFloat beta = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_robinFactor;
9848 if(std::isnan(beta)) cerr <<
"nan" << endl;
9850 mat(srfc, 0) = beta;
9851 for(
MInt i = 0; i < nDim; i++) {
9852 deltaX[i] = deltaXSurfProj(srfc, i) * normalizationFactor;
9854 mat(srfc, cnt) = normal(srfc, i) + beta * deltaX[i];
9858 for(
MInt i = 0; i < nDim; i++) {
9859 if(cnt >= recDim2)
continue;
9861 mat(srfc, cnt) = normal(srfc, i) * deltaX[i] + beta * F1B2 *
POW2(deltaX[i]);
9865 for(
MInt i = 0; i < nDim; i++) {
9866 for(
MInt j = i + 1; j < nDim; j++) {
9867 if(cnt >= recDim2)
continue;
9872 mat(srfc, cnt) = normal(srfc, i) * deltaX[j] + normal(srfc, j) * deltaX[i] + beta * deltaX[i] * deltaX[j];
9877 for(
MInt k = 0; k < recDim; k++) {
9878 mat(srfc, k) = backup(srfc, k);
9883 ASSERT(recDim2 <= recDim,
"");
9886 maxCondNum1 =
mMax(maxCondNum1, condNum2);
9887 avgCondNum1 += condNum;
9889 if(condNum2 < F0 || condNum2 > condNumThreshold) {
9890 cerr <<
"(2) Warning: SVD failed (" << condNum2 <<
") cell " << cellId <<
" (" << m_solver->c_globalId(cellId)
9892 <<
", " << recSize <<
"x" << recDim2 <<
" vfrac "
9893 << m_bndryCells->a[bndryId].m_volume / m_solver->grid().gridCellVolume(m_solver->a_level(cellId)) << endl;
9896 for(
MInt k = 0; k < recSize; k++) {
9898 for(
MInt i = 0; i < nDim; i++) {
9899 matInv(cnt, k) *= normalizationFactor;
9902 for(cnt = nDim + 1; cnt < recDim2; cnt++) {
9903 matInv(cnt, k) *=
POW2(normalizationFactor);
9906 for(
MInt p = 0; p < recSize; p++) {
9907 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * p + s] = matInv(0, p);
9911 if(condNum2 < F0 || condNum2 > condNumThreshold) {
9913 for(
MInt k = 0; k < recSize; k++) {
9914 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[k];
9915 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k + s] = F0;
9916 if(nghbrId == cellId)
continue;
9917 if(k < noSrfcs)
continue;
9919 for(
MInt i = 0; i < nDim; i++) {
9920 dx +=
POW2(m_solver->a_coordinate(nghbrId, i) - m_solver->a_coordinate(cellId, i));
9922 MFloat volume = m_solver->a_cellVolume(nghbrId);
9924 maia::math::deltaFun(volume / m_solver->grid().gridCellVolume(m_solver->a_level(nghbrId)), 1e-8, 1.0);
9925 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k + s] = fac /
mMax(1e-14, sqrt(dx));
9926 sumcnt += m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k + s];
9928 for(
MInt k = 0; k < recSize; k++) {
9929 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k + s] /= sumcnt;
9935 m_log <<
"Small cell treatment average (maximum) condition numbers == Dirichlet stencil: " << avgCondNum0 / condCnt0
9936 <<
" (" << maxCondNum0 <<
"), Neumann stencil: " << avgCondNum1 / condCnt1 <<
" (" << maxCondNum1 <<
")."
9940 MLong smallCells = m_smallCutCells.size();
9941 MPI_Allreduce(MPI_IN_PLACE, &smallCells, 1, MPI_LONG, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
"smallCells");
9944 m_log <<
"Number of small cut cells for flux redistribution: " << m_smallCutCells.size() <<
"; global "
9945 << smallCells << endl;
9960 for(
MUint smallc = 0; smallc < m_smallCutCells.size(); smallc++) {
9961 const MInt bndryId = m_smallCutCells[smallc];
9962 const MInt noSrfcs = m_bndryCells->a[bndryId].m_noSrfcs;
9963 if(m_bndryCell[bndryId].m_cellVarsRecConst.size() !=
IPOW2(noSrfcs) * m_bndryCell[bndryId].m_recNghbrIds.size()) {
9964 cerr << m_bndryCell[bndryId].m_cellVarsRecConst.size() <<
" "
9965 <<
IPOW2(noSrfcs) * m_bndryCell[bndryId].m_recNghbrIds.size() <<
" "
9966 << m_solver->a_isHalo(m_bndryCells->a[bndryId].m_cellId) << endl;
9967 mTerm(1, AT_,
"FvBndryCndXD::initSmallCellCorrection: Inconsistency 1.");
9984template <MInt nDim,
class SysEqn>
9988 static constexpr MInt cornerIndices[8][3] = {{-1, -1, -1}, {1, -1, -1}, {-1, 1, -1}, {1, 1, -1},
9989 {-1, -1, 1}, {1, -1, 1}, {-1, 1, 1}, {1, 1, 1}};
9990 MFloat corner[3] = {0, 0, 0};
9991 MBool inside =
true;
9992 MFloat cellHalfLength = F1B2 * m_solver->c_cellLengthAtCell(cellId);
9994 for(
MInt i = 0; i < m_noCorners; i++) {
9995 for(
MInt dim = 0; dim < nDim; dim++) {
9996 corner[dim] = m_solver->c_coordinate(cellId, dim) + cornerIndices[i][dim] * cellHalfLength;
9998 IF_CONSTEXPR(nDim == 2) {
9999 if((
MBool)m_solver->m_geometry->pointIsInside(corner)) {
10004 if((
MBool)m_solver->m_geometry->pointIsInside2(corner)) {
10013template <MInt nDim,
class SysEqn>
10016 static constexpr MInt cornerIndices[8][3] = {{-1, -1, -1}, {1, -1, -1}, {-1, 1, -1}, {1, 1, -1},
10017 {-1, -1, 1}, {1, -1, 1}, {-1, 1, 1}, {1, 1, 1}};
10018 MFloat corner[3] = {0, 0, 0};
10019 MBool outside =
true;
10020 MFloat cellHalfLength = F1B2 * m_solver->c_cellLengthAtCell(cellId);
10022 for(
MInt i = 0; i < m_noCorners; i++) {
10023 for(
MInt dim = 0; dim < nDim; dim++) {
10024 corner[dim] = m_solver->c_coordinate(cellId, dim) + cornerIndices[i][dim] * cellHalfLength;
10026 IF_CONSTEXPR(nDim == 2) {
10027 if(!m_solver->m_geometry->pointIsInside(corner)) {
10032 if(!m_solver->m_geometry->pointIsInside2(corner)) {
10040template <MInt nDim,
class SysEqn>
10043 static constexpr MInt cornerIndices[8][3] = {{-1, -1, -1}, {1, -1, -1}, {-1, 1, -1}, {1, 1, -1},
10044 {-1, -1, 1}, {1, -1, 1}, {-1, 1, 1}, {1, 1, 1}};
10045 MFloat corner[3] = {0, 0, 0};
10046 MBool outside =
true;
10047 MFloat cellHalfLength = F1B2 * m_solver->c_cellLengthAtLevel(level);
10049 for(
MInt i = 0; i < m_noCorners; i++) {
10050 for(
MInt dim = 0; dim < nDim; dim++) {
10051 corner[dim] = coords[dim] + cornerIndices[i][dim] * cellHalfLength;
10053 IF_CONSTEXPR(nDim == 2) {
10054 if(!m_solver->m_geometry->pointIsInside(corner)) {
10059 if(!m_solver->m_geometry->pointIsInside2(corner)) {
10079template <MInt nDim,
class SysEqn>
10097 MBool bndryRfnJump =
false;
10098 bndryRfnJump = Context::getSolverProperty<MBool>(
"bndryRfnJump", m_solverId, AT_, &bndryRfnJump);
10100 const MBool redirect =
true;
10101 if(redirect && !bndryRfnJump) {
10102 m_cutCandidates.clear();
10103 m_cutCandidates.reserve((
signed)m_bndryCells->size());
10106 for(
MInt bndryId = 0; bndryId < (signed)m_bndryCells->size(); bndryId++) {
10107 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
10108 ASSERT((
signed)m_cutCandidates.size() == bndryId,
"");
10109 m_cutCandidates.emplace_back();
10110 m_cutCandidates[bndryId].cellId = cellId;
10111 m_solver->assertValidGridCellId(cellId);
10114 ASSERT((
signed)m_cutCandidates.size() == (
signed)m_bndryCells->size(),
"");
10116 m_noBndryCndIds = 0;
10117 m_noCutOffBndryCndIds = 0;
10119 m_geometryIntersection->computeCutPointsFromSTL(m_cutCandidates);
10123 for(
MInt cndt = 0; cndt < (signed)m_cutCandidates.size(); cndt++) {
10124 const MInt bndryCndId = m_cutCandidates[cndt].associatedBodyIds[0];
10126 if(bndryCndId > 9999999) {
10127 m_bndryCells->a[cndt].m_srfcs[0]->m_bndryCndId = 9999999;
10128 m_bndryCells->a[cndt].m_srfcs[0]->m_noCutPoints = 0;
10129 ASSERT(m_cutCandidates[cndt].noCutPoints == 0,
"");
10134 MBool newBndryCnd =
true;
10135 for(
MInt j = 0; j < m_noBndryCndIds; j++) {
10136 if(m_bndryCndIds[j] == bndryCndId) {
10137 newBndryCnd =
false;
10142 m_bndryCndIds[m_noBndryCndIds] = bndryCndId;
10146 const MInt noCutPoints = m_cutCandidates[cndt].noCutPoints;
10147 m_bndryCells->a[cndt].m_srfcs[0]->m_noCutPoints = noCutPoints;
10148 IF_CONSTEXPR(nDim == 2) { ASSERT(noCutPoints <= 2,
""); }
10150 m_bndryCells->a[cndt].m_srfcs[0]->m_bndryCndId = bndryCndId;
10152 for(
MInt cutPoint = 0; cutPoint < noCutPoints; cutPoint++) {
10153 m_bndryCells->a[cndt].m_srfcs[0]->m_cutEdge[cutPoint] = m_cutCandidates[cndt].cutEdges[cutPoint];
10154 m_bndryCells->a[cndt].m_srfcs[0]->m_bodyId[cutPoint] = m_cutCandidates[cndt].cutBodyIds[cutPoint];
10155 for(
MInt i = 0; i < nDim; i++) {
10156 m_bndryCells->a[cndt].m_srfcs[0]->m_cutCoordinates[cutPoint][i] =
10157 m_cutCandidates[cndt].cutPoints[cutPoint][i];
10162 if(m_solver->m_geometry->m_parallelGeometry) {
10163 checkCutPointsValidityParGeom();
10165 checkCutPointsValidity();
10169 if(m_solver->m_zonal) {
10171 vector<int> sortingIndex(m_noBndryCndIds);
10172 for(
MInt i = 0; i < m_noBndryCndIds; i++) {
10173 sorting[i] = m_bndryCndIds[i];
10176 std::iota(sortingIndex.begin(), sortingIndex.end(), x++);
10177 sort(sortingIndex.begin(), sortingIndex.end(), [&](
int i,
int j) { return sorting[i] < sorting[j]; });
10179 for(
MInt bcId = 0; bcId < m_noBndryCndIds; bcId++) {
10180 m_bndryCndIds[bcId] = sorting[sortingIndex[bcId]];
10187 const MInt DOFStencil[12] = {1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2, 2};
10188 const MFloat signStencil[8][3] = {{-F1, -F1, -F1}, {F1, -F1, -F1}, {-F1, F1, -F1}, {F1, F1, -F1},
10189 {-F1, -F1, F1}, {F1, -F1, F1}, {-F1, F1, F1}, {F1, F1, F1}};
10191 const MInt nodeStencil[2][12] = {{0, 1, 0, 2, 4, 5, 4, 6, 0, 1, 2, 3}, {2, 3, 1, 3, 6, 7, 5, 7, 4, 5, 6, 7}};
10192 const MInt noCells = m_bndryCells->size();
10193 const MFloat epsilon = 0.00000000001;
10194 const MInt maxNoCutPointsPerEdge = 10;
10201 MFloat target[6] = {0, 0, 0, 0, 0, 0};
10202 MFloatScratchSpace cutPointsEdge(maxNoCutPointsPerEdge, nDim, AT_,
"cutPointsEdge");
10207 m_noBndryCndIds = 0;
10208 m_noCutOffBndryCndIds = 0;
10211 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
10212 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
10213 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints = 0;
10214 m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId = 9999999;
10216 if(m_solver->c_noChildren(cellId) > 0)
continue;
10218 MFloat cellHalfLength = F1B2 * m_solver->c_cellLengthAtCell(cellId);
10221 for(
MInt i = 0; i < nDim; i++) {
10222 center[i] = m_solver->a_coordinate(cellId, i);
10224 for(
MInt n = 0; n < m_noCorners; n++) {
10225 for(
MInt i = 0; i < nDim; i++) {
10226 corners(n, i) = center[i] + signStencil[n][i] * cellHalfLength;
10231 for(
MInt i = 0; i < nDim; i++) {
10232 target[i] = center[i] - cellHalfLength * 1.05;
10233 target[i + nDim] = center[i] + cellHalfLength * 1.05;
10235 MFloat eps = m_solver->c_cellLengthAtCell(cellId) / 10000000.0;
10238 std::vector<MInt> nodeList;
10239 if(m_gridCutTest ==
"SAT") {
10240 m_solver->m_geometry->getIntersectionElements(target, nodeList, cellHalfLength,
10241 &m_solver->a_coordinate(cellId, 0));
10243 m_solver->m_geometry->getIntersectionElements(target, nodeList);
10247 for(
MInt edge = 0; edge < m_noEdges; edge++) {
10248 const MInt edgeDOF = DOFStencil[edge];
10250 MInt noCutPointsEdge = 0;
10251 MBool edgeCut =
false;
10254 for(
MInt i = 0; i < nDim; i++) {
10255 d[i] = corners(nodeStencil[0][edge], i);
10256 e[i] = corners(nodeStencil[1][edge], i);
10260 for(
MInt n = 0; n < (signed)nodeList.size(); n++) {
10261 MBool cutsEdge =
false;
10264 IF_CONSTEXPR(nDim == 3) {
10265 const MInt spaceId = (edgeDOF + 1) % nDim;
10266 const MInt spaceId1 = (edgeDOF + 2) % nDim;
10267 const MInt spaceId2 = edgeDOF;
10271 for(
MInt k = 0; k < nDim; k++) {
10272 a[k] = m_solver->m_geometry->elements[nodeList[n]].m_vertices[0][k];
10273 b[k] = m_solver->m_geometry->elements[nodeList[n]].m_vertices[1][k];
10274 c[k] = m_solver->m_geometry->elements[nodeList[n]].m_vertices[2][k];
10276 if(
approx(
a[spaceId1],
b[spaceId1], MFloatEps) && !
approx(
a[spaceId1], c[spaceId1], MFloatEps)) {
10278 q = (d[spaceId1] -
a[spaceId1]) / (c[spaceId1] -
a[spaceId1]);
10279 p = (d[spaceId] -
a[spaceId] - q * (c[spaceId] -
a[spaceId])) / (
b[spaceId] -
a[spaceId]);
10281 if(!
approx(
a[spaceId1],
b[spaceId1], MFloatEps) &&
approx(
a[spaceId1], c[spaceId1], MFloatEps)) {
10283 p = (d[spaceId1] -
a[spaceId1]) / (
b[spaceId1] -
a[spaceId1]);
10284 q = (d[spaceId] -
a[spaceId] -
p * (
b[spaceId] -
a[spaceId])) / (c[spaceId] -
a[spaceId]);
10286 if(
approx(
a[spaceId],
b[spaceId], MFloatEps) && !
approx(
a[spaceId], c[spaceId], MFloatEps)) {
10288 q = (d[spaceId] -
a[spaceId]) / (c[spaceId] -
a[spaceId]);
10289 p = (d[spaceId1] -
a[spaceId1] - q * (c[spaceId1] -
a[spaceId1])) / (
b[spaceId1] -
a[spaceId1]);
10291 if(!
approx(
a[spaceId],
b[spaceId], MFloatEps) &&
approx(
a[spaceId], c[spaceId], MFloatEps)) {
10293 p = (d[spaceId] -
a[spaceId]) / (
b[spaceId] -
a[spaceId]);
10294 q = (d[spaceId1] -
a[spaceId1] -
p * (
b[spaceId1] -
a[spaceId1])) / (c[spaceId1] -
a[spaceId1]);
10297 q = ((d[spaceId1] -
a[spaceId1]) * (
b[spaceId] -
a[spaceId])
10298 - (
b[spaceId1] -
a[spaceId1]) * (d[spaceId] -
a[spaceId]))
10299 / ((c[spaceId1] -
a[spaceId1]) * (
b[spaceId] -
a[spaceId])
10300 - (
b[spaceId1] -
a[spaceId1]) * (c[spaceId] -
a[spaceId]));
10301 p = (d[spaceId] -
a[spaceId] - q * (c[spaceId] -
a[spaceId])) / (
b[spaceId] -
a[spaceId]);
10308 if(p * q >= 0 || p * q < 0) {
10310 MFloat gamma =
a[spaceId2] +
p * (
b[spaceId2] -
a[spaceId2]) + q * (c[spaceId2] -
a[spaceId2]);
10311 MFloat s = (gamma - d[spaceId2]) / (e[spaceId2] - d[spaceId2]);
10313 if(s < -epsilon || s > F1 + epsilon || p < -epsilon || q < -epsilon || (p + q) > F1 + epsilon) {
10317 if(noCutPointsEdge < 10) {
10318 for(
MInt k = 0; k < nDim; k++) {
10319 pP[k] = d[k] + s * (e[k] - d[k]);
10320 cutPointsEdge(noCutPointsEdge, k) = pP[k];
10323 mTerm(1, AT_,
" Too many cut points on edge...");
10329 if(m_solver->m_geometry->edgeTriangleIntersection(m_solver->m_geometry->elements[nodeList[n]].m_vertices[0],
10330 m_solver->m_geometry->elements[nodeList[n]].m_vertices[1],
10331 0, d.getPointer(), e.getPointer())) {
10332 for(
MInt k = 0; k < nDim; k++) {
10333 a[k] = m_solver->m_geometry->elements[nodeList[n]].m_vertices[0][k];
10334 b[k] = m_solver->m_geometry->elements[nodeList[n]].m_vertices[1][k];
10337 MFloat gamma = (
b[0] -
a[0]) * (d[1] - e[1]) - (d[0] - e[0]) * (
b[1] -
a[1]);
10338 if(
ABS(gamma) < 0.0000000000001)
continue;
10339 MFloat s1 = ((d[0] - e[0]) * (
a[1] - d[1]) - (d[1] - e[1]) * (
a[0] - d[0])) / gamma;
10340 MFloat s2 = ((
b[0] -
a[0]) * (d[1] -
a[1]) - (d[0] -
a[0]) * (
b[1] -
a[1])) / gamma;
10345 if(noCutPointsEdge < 10) {
10346 for(
MInt k = 0; k < nDim; k++) {
10347 if(s1 * s1 < s2 * s2) {
10348 pP[k] = d[k] + s2 * (e[k] - d[k]);
10350 pP[k] =
a[k] + s1 * (
b[k] -
a[k]);
10352 cutPointsEdge(noCutPointsEdge, k) = pP[k];
10355 mTerm(1, AT_,
" Too many cut points on edge...");
10362 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints < m_noEdges) {
10364 if(m_solver->m_geometry->elements[nodeList[n]].m_bndCndId
10365 < m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId) {
10366 m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId =
10367 m_solver->m_geometry->elements[nodeList[n]].m_bndCndId;
10368 MBool newBndryCnd =
true;
10369 for(
MInt j = 0; j < m_noBndryCndIds; j++) {
10370 if(m_bndryCndIds[j] == m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId) {
10371 newBndryCnd =
false;
10376 m_bndryCndIds[m_noBndryCndIds] = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
10377 if(m_noBndryCndIds < m_maxNoBndryCndIds) {
10380 mTerm(1, AT_,
"Too many different boundary conditions...");
10389 MBool newCutPoint =
true;
10390 for(
MInt i = 0; i < noCutPointsEdge; i++) {
10391 MBool equal = (
ABS(pP[0] - cutPointsEdge(i, 0)) < eps &&
ABS(pP[1] - cutPointsEdge(i, 1)) < eps);
10392 IF_CONSTEXPR(nDim == 3) equal = (equal && (
ABS(pP[2] - cutPointsEdge(i, 2)) < eps));
10394 newCutPoint =
false;
10400 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints--;
10401 m_log <<
"removing two cut points, cell " <<
cellId <<
" edge " << edge << endl;
10402 m_log << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 1) <<
" ";
10403 IF_CONSTEXPR(nDim == 3)
m_log << m_solver->a_coordinate(cellId, 2) << endl;
10412 MBool newCutPoint =
true;
10413 for(
MInt i = 0; i < noCutPointsEdge; i++) {
10414 MBool equal = (
ABS(pP[0] - cutPointsEdge(i, 0)) <= eps &&
ABS(pP[1] - cutPointsEdge(i, 1)) <= eps);
10415 IF_CONSTEXPR(nDim == 3) equal = (equal && (
ABS(pP[2] - cutPointsEdge(i, 2)) <= eps));
10417 newCutPoint =
false;
10423 MInt cutPointNo = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
10424 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPointNo] = edge;
10425 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[cutPointNo] = 0;
10426 for(
MInt i = 0; i < nDim; i++) {
10427 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPointNo][i] = pP[i];
10429 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints++;
10434 cerr <<
"** Warning fvbndrycndxd: " << endl;
10435 cerr <<
"cell " <<
cellId << endl;
10436 cerr <<
" -> Boundary cell " << bndryId <<
" has more than " << m_noEdges <<
" cut points" << endl;
10437 cerr <<
" -> Additional cut points are neglected" << endl;
10438 cerr <<
cellId <<
" " << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 1)
10440 IF_CONSTEXPR(nDim == 3) cerr << m_solver->a_coordinate(cellId, 2) << " ";
10441 cerr << m_solver->a_level(cellId) << endl;
10442 mTerm(1, AT_, "Boundary cell has more than m_noEdges cut points");
10449 if(!bndryRfnJump) {
10450 if(m_solver->m_geometry->m_parallelGeometry) {
10451 checkCutPointsValidityParGeom();
10453 checkCutPointsValidity();
10456 IF_CONSTEXPR(nDim == 2) {
10458 for(
MInt bndryId = noCells - 1; bndryId > -1; bndryId--) {
10459 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
10461 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints > 2) {
10462 cerr <<
"** Fatal error fvbndrycndxd: " << endl;
10463 cerr <<
" -> 2D Boundary cell " << bndryId <<
"(" <<
cellId <<
") has more than 2 cut points" << endl;
10464 cerr << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 1) << endl;
10465 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
10466 cerr << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp][0] <<
" "
10467 << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp][1] << endl;
10469 mTerm(1, AT_,
"Boundary cell has more than 2 cut points");
10477 ASSERT(bndryRfnJump,
"");
10480 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
10481 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] = -1;
10482 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] = -1;
10483 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] = -1;
10484 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3] = -1;
10487 MBool newCutPointAdjustment =
false;
10489 m_log <<
"Boundary refinement jump method is active" << endl;
10490 m_log <<
"WARNING: Make sure you have correctly activated the halo cells in cartesiangrid.cpp; it is wrong on "
10491 "default because otherwise a lot of testcases 'break'."
10493 if(domainId() == 0) {
10494 cerr <<
"Boundary refinement jump method is active" << endl;
10495 cerr <<
"Make sure you have correctly activated the halo cells in cartesiangrid.cpp; it is wrong on default "
10496 "because otherwise a lot of testcases 'break'."
10499 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
10500 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
10502 if(m_solver->c_noChildren(cellId) > 0)
continue;
10507 for(
MInt direction = 0; direction < m_noDirs; direction++) {
10508 MBool problemCell =
false;
10510 if(m_solver->a_hasNeighbor(cellId, direction) == 0) {
10511 MInt parentId = m_solver->c_parentId(cellId);
10512 if(parentId > -1) {
10513 if(m_solver->a_hasNeighbor(parentId, direction) == 1) {
10514 problemCell =
true;
10521 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints == 0 && direction == 5 && problemCell == 0
10522 && m_solver->a_bndryId(cellId) != -5) {
10523 m_solver->a_bndryId(cellId) = -5;
10524 if(!checkInside(cellId)) {
10525 m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel) =
false;
10526 m_solver->a_hasProperty(cellId, SolverCell::IsInvalid) =
true;
10528 cerr <<
"cell activation/deactivation in m1 loop; isonmg and isinvalid: "
10529 << m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel) <<
" "
10530 << m_solver->a_hasProperty(cellId, SolverCell::IsInvalid) <<
" cell id: " <<
cellId << endl;
10534 if(problemCell ==
true) {
10535 MInt parentId = m_solver->c_parentId(cellId);
10536 MInt nghbrId = m_solver->c_neighborId(parentId, direction);
10537 MInt nghbrbndryId = -1;
10538 MFloat cellHalfLengthParent = F1B2 * m_solver->c_cellLengthAtCell(parentId);
10542 MInt noCutPoints1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
10543 if(noCutPoints1 == 0) {
10546 nghbrbndryId = m_solver->a_bndryId(nghbrId);
10547 if(nghbrbndryId == -1) {
10550 MInt noCutPointsNeighbor = m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_noCutPoints;
10551 if(noCutPointsNeighbor == 0)
continue;
10553 for(
MInt i = 0; i < nDim; i++) {
10554 centerParent[i] = m_solver->a_coordinate(parentId, i);
10556 for(
MInt n = 0; n < m_noCorners; n++) {
10557 for(
MInt i = 0; i < nDim; i++) {
10558 cornersParent(n, i) = centerParent[i] + signStencil[n][i] * cellHalfLengthParent;
10562 MFloat cellHalfLengthNeighbor = F1B2 * m_solver->c_cellLengthAtCell(nghbrId);
10566 for(
MInt i = 0; i < nDim; i++) {
10567 centerNeighbor[i] = m_solver->a_coordinate(nghbrId, i);
10569 for(
MInt n = 0; n < m_noCorners; n++) {
10570 for(
MInt i = 0; i < nDim; i++) {
10571 cornersNeighbor(n, i) = centerNeighbor[i] + signStencil[n][i] * cellHalfLengthNeighbor;
10575 MFloat cellHalfLengthCell = F1B2 * m_solver->c_cellLengthAtCell(cellId);
10580 for(
MInt i = 0; i < nDim; i++) {
10581 centerCell[i] = m_solver->a_coordinate(cellId, i);
10583 for(
MInt n = 0; n < m_noCorners; n++) {
10584 for(
MInt i = 0; i < nDim; i++) {
10585 cornersCell(n, i) = centerCell[i] + signStencil[n][i] * cellHalfLengthCell;
10589 const MInt cornerDirectionStencil[8][3] = {{0, 2, 4}, {1, 2, 4}, {0, 3, 4}, {1, 3, 4},
10590 {0, 2, 5}, {1, 2, 5}, {0, 3, 5}, {1, 3, 5}};
10593 const MFloat eps = 0.0000001;
10594 MBool directionMatchesCorner =
false;
10595 MInt cornerId = -1;
10596 for(
MInt n = 0; n < m_noCorners; n++) {
10597 if(abs(cornersParent(n, 0) - cornersCell(n, 0)) < eps && abs(cornersParent(n, 1) - cornersCell(n, 1)) < eps
10598 && abs(cornersParent(n, 2) - cornersCell(n, 2)) < eps) {
10602 for(
MInt i = 0; i < 3; i++) {
10603 if(cornerDirectionStencil[cornerId][i] == direction) {
10604 directionMatchesCorner =
true;
10608 if(directionMatchesCorner ==
false) {
10609 cerr <<
"Direction does not match corner1111; this ERROR should not occur. Check your grid." << endl;
10620 for(
MInt edge = 0; edge < m_noEdges; edge++) {
10621 for(
MInt i = 0; i < nDim; i++) {
10622 dParent[i] = cornersParent(nodeStencil[0][edge], i);
10623 eParent[i] = cornersParent(nodeStencil[1][edge], i);
10624 dNeighbor[i] = cornersNeighbor(nodeStencil[0][edge], i);
10625 eNeighbor[i] = cornersNeighbor(nodeStencil[1][edge], i);
10626 dCell[i] = cornersCell(nodeStencil[0][edge], i);
10627 eCell[i] = cornersCell(nodeStencil[1][edge], i);
10630 const MInt directionEdgesStencil[6][4] = {{0, 4, 8, 10}, {1, 5, 9, 11}, {2, 6, 8, 9},
10631 {3, 7, 10, 11}, {0, 1, 2, 3}, {4, 5, 6, 7}};
10633 const MInt directionEdgesStencilNeighbor[6][4] = {{1, 5, 9, 11}, {0, 4, 8, 10}, {3, 7, 10, 11},
10634 {2, 6, 8, 9}, {4, 5, 6, 7}, {0, 1, 2, 3}};
10635 MInt noEdgesCut = 0;
10636 MInt edgesCut[2] = {0, 0};
10637 if(noEdgesCut == 12341234) {
10638 cerr << edgesCut[1] << endl;
10640 MInt edgesCutRm[2] = {-1, -1};
10641 MInt newEdgeCut[2] = {-1, -1};
10642 MFloat cutPointCoordinatesNeighbor[3][2] = {{0, 0}, {0, 0}, {0, 0}};
10643 for(
MInt i = 0; i < noCutPointsNeighbor; i++) {
10644 for(
MInt j = 0; j < 4; j++) {
10645 if(m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_cutEdge[i] == directionEdgesStencilNeighbor[direction][j]) {
10646 edgesCut[noEdgesCut] = m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_cutEdge[i];
10647 for(
MInt k = 0; k < 3; k++) {
10648 cutPointCoordinatesNeighbor[k][noEdgesCut] =
10649 m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_cutCoordinates[i][k];
10656 if(noEdgesCut != 2 && noEdgesCut != 0) {
10657 cerr <<
"ERROR: noEdgesCut is not 0 or 2; Check if split cells are occuring." << endl;
10661 if(noEdgesCut == 2) {
10662 MInt noCutPoints = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
10663 if(noCutPoints == 0) {
10664 cerr <<
"No cut points on this cell right now" << endl;
10666 if(noCutPoints == 1) {
10667 cerr <<
"There is only 1 cut points in total on this cell: cellId: " <<
cellId << endl;
10669 if(noCutPoints == 2) {
10670 cerr <<
"There are only 2 cut points in total on this cell: cellId: " <<
cellId << endl;
10673 for(
MInt i = 0; i < noCutPoints; i++) {
10674 MBool removed =
false;
10675 for(
MInt j = 0; j < 4; j++) {
10676 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[i]
10677 == directionEdgesStencil[direction][j]) {
10678 MInt rmCutEdge = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[i];
10679 for(
MInt k = i; k < noCutPoints; k++) {
10680 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[k] =
10681 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[k + 1];
10682 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[k] =
10683 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[k + 1];
10684 for(
MInt l = 0; l < 3; l++) {
10685 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[k][l] =
10686 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[k + 1][l];
10690 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints--;
10693 if(edgesCutRm[0] != -1) {
10694 edgesCutRm[1] = rmCutEdge;
10696 if(edgesCutRm[0] == -1) {
10697 edgesCutRm[0] = rmCutEdge;
10701 if(removed ==
true) i--;
10704 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints == 0) {
10705 cerr <<
"nocutpoints is zero for this cellid even though it should be at least 1: " <<
cellId << endl;
10708 MFloat cutPointOne[3] = {0, 0, 0};
10709 MFloat cutPointTwo[3] = {0, 0, 0};
10710 MFloat edgePointOne[3] = {0, 0, 0};
10711 MFloat edgePointTwo[3] = {0, 0, 0};
10712 MInt divisorPosition = -1;
10713 MFloat lineOne[3] = {0, 0, 0};
10714 MFloat lineTwo[3] = {0, 0, 0};
10715 MFloat cutPoint[3] = {0, 0, 0};
10717 MInt noNewCutPoints = 0;
10718 for(
MInt i = 0; i < 3; i++) {
10719 cutPointOne[i] = cutPointCoordinatesNeighbor[i][0];
10720 cutPointTwo[i] = cutPointCoordinatesNeighbor[i][1];
10722 for(
MInt i = 0; i < 4; i++) {
10723 MBool newCutPoint =
false;
10724 MInt edge = directionEdgesStencil[direction][i];
10725 for(
MInt j = 0; j < 3; j++) {
10726 edgePointOne[j] = cornersCell(nodeStencil[0][edge], j);
10727 edgePointTwo[j] = cornersCell(nodeStencil[1][edge], j);
10730 MBool zero =
false;
10731 for(
MInt l = 0; l < 3; l++) {
10732 for(
MInt k = 0; k < 3; k++) {
10733 if(l == k)
continue;
10734 if(zero ==
true)
continue;
10735 if(abs(edgePointOne[l] - 0.0) < eps && abs(edgePointTwo[l] - 0.0) < eps
10736 && abs(edgePointOne[k] - edgePointTwo[k]) < eps
10737 && (!(abs(edgePointOne[k] - 0.0) < eps) || !(abs(edgePointTwo[k] - 0.0) < eps))) {
10740 divisorPosition = k;
10745 for(
MInt l = 0; l < 3; l++) {
10746 for(
MInt k = 0; k < 3; k++) {
10747 if(l == k)
continue;
10748 if(zero ==
true)
continue;
10749 if(abs(edgePointOne[l] - 0.0) < eps && abs(edgePointTwo[l] - 0.0) < eps
10750 && abs(edgePointOne[k] - edgePointTwo[k]) < eps
10751 && ((abs(edgePointOne[k] - 0.0) < eps) && (abs(edgePointTwo[k] - 0.0) < eps))) {
10753 divisorPosition = k;
10759 for(
MInt l = 0; l < 3; l++) {
10760 cutPointOne[l] = cutPointOne[l] + 1;
10761 cutPointTwo[l] = cutPointTwo[l] + 1;
10762 edgePointOne[l] = edgePointOne[l] + 1;
10763 edgePointTwo[l] = edgePointTwo[l] + 1;
10767 lineOne[0] = (cutPointOne[1] * cutPointTwo[2] - cutPointOne[2] * cutPointTwo[1]);
10768 lineOne[1] = (cutPointOne[2] * cutPointTwo[0] - cutPointOne[0] * cutPointTwo[2]);
10769 lineOne[2] = (cutPointOne[0] * cutPointTwo[1] - cutPointOne[1] * cutPointTwo[0]);
10771 lineTwo[0] = (edgePointOne[1] * edgePointTwo[2] - edgePointOne[2] * edgePointTwo[1]);
10772 lineTwo[1] = (edgePointOne[2] * edgePointTwo[0] - edgePointOne[0] * edgePointTwo[2]);
10773 lineTwo[2] = (edgePointOne[0] * edgePointTwo[1] - edgePointOne[1] * edgePointTwo[0]);
10775 cutPoint[0] = (lineOne[1] * lineTwo[2] - lineOne[2] * lineTwo[1]);
10776 cutPoint[1] = (lineOne[2] * lineTwo[0] - lineOne[0] * lineTwo[2]);
10777 cutPoint[2] = (lineOne[0] * lineTwo[1] - lineOne[1] * lineTwo[0]);
10779 dP[0] = cutPoint[0];
10780 dP[1] = cutPoint[1];
10781 dP[2] = cutPoint[2];
10784 for(
MInt l = 0; l < 3; l++) {
10785 cutPointOne[l] = cutPointOne[l] - 1;
10786 cutPointTwo[l] = cutPointTwo[l] - 1;
10787 edgePointTwo[l] = edgePointTwo[l] - 1;
10791 if(zero ==
false) {
10792 for(
MInt l = 0; l < 3; l++) {
10793 if(abs(cutPointOne[l] - cutPointTwo[l]) < eps && abs(cutPointOne[l] - edgePointOne[l]) < eps
10794 && abs(cutPointOne[l] - edgePointTwo[l]) < eps && abs(cutPointTwo[l] - edgePointTwo[l]) < eps) {
10795 divisorPosition = l;
10800 if(divisorPosition == -1) {
10801 cerr <<
"divisorPosition is -1; This ERROR shouldn't be able to occur. Maybe adjust 'eps'" << endl;
10802 for(
MInt l = 0; l < 3; l++) {
10803 cerr << l <<
": coordinate;"
10804 <<
"cutPointOne: " << cutPointOne[l] <<
" -- cutPointTwo: " << cutPointTwo[l]
10805 <<
" -- edgePointOne: " << edgePointOne[l] <<
" -- edgePointTwo: " << edgePointTwo[l] << endl;
10807 cerr <<
"direction: " << direction << endl;
10809 for(
MInt n = 0; n < m_noCorners; n++) {
10810 cerr <<
"corner: " << n << endl;
10811 for(
MInt l = 0; l < 3; l++) {
10812 cerr <<
"cornersCell: " << cornersCell(n, l) << endl;
10816 for(
MInt n = 0; n < m_noCorners; n++) {
10817 cerr <<
"corner neighbor: " << n << endl;
10818 for(
MInt l = 0; l < 3; l++) {
10819 cerr <<
"cornersNeighbor: " << cornersNeighbor(n, l) << endl;
10823 for(
MInt l = 0; l < noCutPointsNeighbor; l++) {
10824 cerr <<
"----------------------------" << endl;
10825 cerr <<
"neighborcutpointnumber: " << l << endl;
10826 for(
MInt k = 0; k < 3; k++) {
10827 cerr << m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_cutCoordinates[l][k] << endl;
10833 divisor = cutPoint[divisorPosition];
10834 divisor = divisor / edgePointOne[divisorPosition];
10836 MBool continueing =
false;
10837 for(
MInt k = 0; k < 3; k++) {
10838 cutPoint[k] = cutPoint[k] / divisor;
10839 if(std::isnan(cutPoint[k])) {
10840 cerr <<
"ERROR: NAN. Divisor: " << divisor <<
" cut point k: " << cutPoint[k] <<
" zero: " << zero
10842 cerr <<
"k: " << k <<
" edgepointone: " << edgePointOne[k] <<
" edgepointtwo: " << edgePointTwo[k]
10844 cerr <<
"k: " << k <<
" cutpointone: " << cutPointOne[k] <<
" cutpointtwo: " << cutPointTwo[k]
10846 cerr <<
"divisorPosition: " << divisorPosition << endl;
10847 cerr <<
"dP0: " << dP[0] <<
"dP1: " << dP[1] <<
"dP2: " << dP[2] << endl;
10848 cerr <<
"cut points are probably parallel to the edge. continue";
10849 continueing =
true;
10852 if(continueing ==
true) {
10853 continueing =
false;
10858 for(
MInt l = 0; l < 3; l++) {
10859 cutPoint[l] = cutPoint[l] - 1;
10860 edgePointOne[l] = edgePointOne[l] - 1;
10865 if(newCutPointAdjustment ==
true) {
10866 for(
MInt m = 0; m < 3; m++) {
10867 if(abs(edgePointOne[m] - cutPoint[m]) < 0.00000001) {
10868 cutPoint[m] = edgePointOne[m];
10873 for(
MInt n = 0; n < 3; n++) {
10874 if(edgePointTwo[n] > edgePointOne[n] && abs(edgePointOne[n] - cutPoint[n]) > epsilon
10875 && (edgePointTwo[n] - edgePointOne[n]) > (edgePointTwo[n] - cutPoint[n])
10876 && (edgePointTwo[n] - cutPoint[n]) > 0) {
10878 newCutPoint =
true;
10880 if(edgePointTwo[n] < edgePointOne[n] && abs(edgePointOne[n] - cutPoint[n]) > epsilon
10881 && (edgePointOne[n] - edgePointTwo[n]) > (edgePointOne[n] - cutPoint[n])
10882 && (edgePointOne[n] - cutPoint[n]) > 0) {
10884 newCutPoint =
true;
10888 if(newCutPoint ==
false) {
10892 if(newEdgeCut[0] != -1) {
10893 newEdgeCut[1] = edge;
10895 if(newEdgeCut[0] == -1) {
10896 newEdgeCut[0] = edge;
10900 MInt cutPointNo = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
10901 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPointNo] = edge;
10902 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[cutPointNo] =
10903 m_bndryCells->a[nghbrbndryId]
10907 for(
MInt x = 0; x < nDim; x++) {
10908 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPointNo][x] = cutPoint[x];
10910 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints++;
10914 for(
MInt noOldEdge = 0; noOldEdge < 2; noOldEdge++) {
10915 MInt additionalCutEdge = -1;
10916 MFloat pointDifference[3] = {0, 0, 0};
10917 MFloat cutCoordinates[3] = {0, 0, 0};
10919 const MInt edgeFaceStencil[6][4] = {{8, 10, 0, 4}, {9, 11, 1, 5}, {2, 6, 8, 9},
10920 {3, 7, 10, 11}, {0, 1, 2, 3}, {4, 5, 6, 7}};
10922 const MInt edgeInCorner[8][3] = {{0, 2, 8}, {1, 2, 9}, {0, 3, 10}, {1, 3, 11},
10923 {4, 6, 8}, {5, 6, 9}, {4, 7, 10}, {5, 7, 11}};
10925 for(
MInt i = 0; i < 8; i++) {
10926 MInt additionalCutPoint = -1;
10928 for(
MInt j = 0; j < 3; j++) {
10930 if(edgesCutRm[noOldEdge] != newEdgeCut[0] && edgesCutRm[1 - noOldEdge] == newEdgeCut[1]) {
10931 if(edgeInCorner[i][j] == edgesCutRm[noOldEdge]) {
10934 if(edgeInCorner[i][j] == newEdgeCut[0]) {
10938 additionalCutPoint = 0;
10944 for(
MInt j = 0; j < 3; j++) {
10945 if(edgesCutRm[noOldEdge] != newEdgeCut[1] && edgesCutRm[1 - noOldEdge] == newEdgeCut[0]
10946 && additionalCutPoint == -1) {
10947 if(edgeInCorner[i][j] == edgesCutRm[noOldEdge]) {
10950 if(edgeInCorner[i][j] == newEdgeCut[1]) {
10954 additionalCutPoint = 1;
10960 for(
MInt j = 0; j < 3; j++) {
10961 if(edgeInCorner[i][j] != edgesCutRm[noOldEdge]
10962 && edgeInCorner[i][j] != newEdgeCut[additionalCutPoint]) {
10963 additionalCutEdge = edgeInCorner[i][j];
10967 if(edgesCutRm[0] == -1 && edgesCutRm[1] == -1 && noOldEdge == 1) {
10968 for(
MInt j = 0; j < 3; j++) {
10969 if(additionalCutPoint != -1) {
10970 cerr <<
"ERROR in the additional cut point computation" << endl;
10972 if(edgeInCorner[i][j] == newEdgeCut[0]) {
10975 if(edgeInCorner[i][j] == newEdgeCut[1]) {
10979 additionalCutPoint = 2;
10984 for(
MInt j = 0; j < 3; j++) {
10985 if(additionalCutPoint == 2 && edgeInCorner[i][j] != newEdgeCut[0]
10986 && edgeInCorner[i][j] != newEdgeCut[1]) {
10987 additionalCutEdge = edgeInCorner[i][j];
10991 if(additionalCutPoint != -1 && edgesCutRm[noOldEdge] != newEdgeCut[0]
10992 && edgesCutRm[noOldEdge] != newEdgeCut[1]) {
10995 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] = i;
10999 for(
MInt j = 0; j < 3; j++) {
11000 edgePointOne[j] = cornersCell(nodeStencil[0][additionalCutEdge], j);
11001 edgePointTwo[j] = cornersCell(nodeStencil[1][additionalCutEdge], j);
11002 pointDifference[j] = edgePointTwo[j] - edgePointOne[j];
11003 pointDifference[j] = pointDifference[j] / 2;
11004 cutCoordinates[j] = edgePointOne[j] + pointDifference[j];
11007 MBool skip =
false;
11010 for(
MInt x = 0; x < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; x++) {
11011 MBool removed =
false;
11013 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[x] == additionalCutEdge
11014 && additionalCutEdge != -1) {
11016 for(
MInt k = x; k < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; k++) {
11017 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[k] =
11018 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[k + 1];
11020 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[k] =
11021 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[k + 1];
11022 for(
MInt l = 0; l < 3; l++) {
11023 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[k][l] =
11024 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[k + 1][l];
11028 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints--;
11032 if(removed ==
true) {
11038 if(skip ==
false) {
11041 MInt cutPointNo = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
11042 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPointNo] = additionalCutEdge;
11043 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[cutPointNo] =
11044 m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_bodyId[0];
11045 for(
MInt x = 0; x < nDim; x++) {
11046 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPointNo][x] = cutCoordinates[x];
11048 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints++;
11052 for(
MInt k = 0; k < 6; k++) {
11054 MInt problemFace = -1;
11056 for(
MInt l = 0; l < 4; l++) {
11057 if(additionalCutEdge == edgeFaceStencil[k][l]) {
11060 if(edgesCutRm[0] == newEdgeCut[0] || edgesCutRm[1] == newEdgeCut[0]) {
11061 if(newEdgeCut[1] == edgeFaceStencil[k][l]) {
11065 if(edgesCutRm[0] == newEdgeCut[1] || edgesCutRm[1] == newEdgeCut[1]) {
11066 if(newEdgeCut[0] == edgeFaceStencil[k][l]) {
11072 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] != -1) {
11074 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] = k;
11078 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] == -1) {
11080 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] = k;
11083 cerr <<
"counter error 1: " << problemFace << endl;
11089 for(
MInt k = 0; k < 6; k++) {
11091 MInt problemFace = -1;
11093 for(
MInt l = 0; l < 4; l++) {
11094 if(additionalCutEdge == edgeFaceStencil[k][l]) {
11097 if(edgesCutRm[0] != newEdgeCut[0] && edgesCutRm[0] != newEdgeCut[1]) {
11098 if(edgesCutRm[0] == edgeFaceStencil[k][l]) {
11102 if(edgesCutRm[1] != newEdgeCut[0] && edgesCutRm[1] != newEdgeCut[1]) {
11103 if(edgesCutRm[1] == edgeFaceStencil[k][l]) {
11109 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] != -1) {
11111 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] = k;
11115 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] == -1) {
11117 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] = k;
11121 cerr <<
"counter ERROR 1: " << problemFace << endl;
11127 if(additionalCutPoint == 2) {
11128 for(
MInt k = 0; k < 6; k++) {
11130 MInt problemFace = -1;
11131 for(
MInt l = 0; l < 4; l++) {
11132 if(additionalCutEdge == edgeFaceStencil[k][l]) {
11136 for(
MInt l = 0; l < 4; l++) {
11138 if(newEdgeCut[0] == edgeFaceStencil[k][l]) {
11141 if(newEdgeCut[1] == edgeFaceStencil[k][l]) {
11147 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] != -1
11148 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] != -1) {
11149 cerr <<
"error: third face is found1; first face: "
11150 << m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0]
11151 <<
" second face: "
11152 << m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2]
11153 <<
" current face: " << k <<
" additionalcutedge: " << additionalCutEdge
11154 <<
" this should be ok if the additional cut edge is on the second face AND the current "
11160 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] != -1) {
11162 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] = k;
11167 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] == -1) {
11169 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] = k;
11174 cerr <<
"counter error 1: " << problemFace << endl;
11180 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] != -1
11181 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] != -1) {
11182 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3] != -1) {
11183 cerr <<
"a second direction is found: " << direction <<
" currently saved direction: "
11184 << m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3]
11186 << m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0]
11187 <<
" second face: "
11188 << m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2]
11190 << m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] << endl;
11192 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3] = direction;
11195 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0]
11196 == m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2]) {
11197 cerr <<
"ERROR: somehow a face is detected as a problem face twice" << endl;
11202 if(newEdgeCut[0] == -1 && newEdgeCut[1] == -1) {
11203 for(
MInt i = 0; i < 8; i++) {
11204 MInt additionalCutPoint = -1;
11207 additionalCutEdge = -1;
11208 for(
MInt j = 0; j < 3; j++) {
11209 if(edgeInCorner[i][j] == edgesCutRm[0]) {
11212 if(edgeInCorner[i][j] == edgesCutRm[1]) {
11216 additionalCutPoint = 1;
11220 if(additionalCutPoint == 1 && noOldEdge == 0) {
11221 for(
MInt j = 0; j < 3; j++) {
11222 if(edgeInCorner[i][j] != edgesCutRm[0] && edgeInCorner[i][j] != edgesCutRm[1]) {
11223 additionalCutEdge = edgeInCorner[i][j];
11226 for(
MInt j = 0; j < 3; j++) {
11227 edgePointOne[j] = cornersCell(nodeStencil[0][additionalCutEdge], j);
11228 edgePointTwo[j] = cornersCell(nodeStencil[1][additionalCutEdge], j);
11229 pointDifference[j] = edgePointTwo[j] - edgePointOne[j];
11230 pointDifference[j] = pointDifference[j] / 2;
11231 cutCoordinates[j] = edgePointOne[j] + pointDifference[j];
11234 if(additionalCutPoint != -1) {
11237 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] = i;
11240 for(
MInt k = 0; k < 6; k++) {
11242 MInt problemFace = -1;
11243 for(
MInt l = 0; l < 4; l++) {
11244 if(additionalCutEdge == edgeFaceStencil[k][l]) {
11248 for(
MInt l = 0; l < 4; l++) {
11250 if(newEdgeCut[0] == -1 && newEdgeCut[1] == -1) {
11251 if(edgesCutRm[1] == edgeFaceStencil[k][l] || edgesCutRm[0] == edgeFaceStencil[k][l]) {
11256 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] != -1) {
11258 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] = k;
11262 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] == -1) {
11264 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] = k;
11268 cerr << problemFace << endl;
11273 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] != -1
11274 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] != -1) {
11275 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3] = direction;
11278 MBool skip =
false;
11281 for(
MInt x = 0; x < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; x++) {
11282 MBool removed =
false;
11284 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[x] == additionalCutEdge
11285 && additionalCutEdge != -1) {
11287 for(
MInt k = x; k < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; k++) {
11288 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[k] =
11289 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[k + 1];
11291 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[k] =
11292 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[k + 1];
11293 for(
MInt l = 0; l < 3; l++) {
11294 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[k][l] =
11295 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[k + 1][l];
11299 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints--;
11303 if(removed ==
true) {
11313 if(skip ==
false) {
11316 MInt cutPointNo = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
11317 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPointNo] = additionalCutEdge;
11319 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[cutPointNo] =
11320 m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_bodyId[0];
11321 for(
MInt x = 0; x < nDim; x++) {
11322 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPointNo][x] = cutCoordinates[x];
11324 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints++;
11331 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints == 0
11332 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] != -1) {
11334 cerr <<
"bndry cell that is no longer cut is found."
11335 <<
" it is checked if it is inside or outside; cellId: " <<
cellId << endl;
11336 m_solver->a_bndryId(cellId) = -5;
11337 for(
MInt i = 0; i < 3; i++) {
11339 cornersCell(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1], i);
11343 m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel) =
11344 m_solver->m_geometry->pointIsInside2(testCorner);
11345 m_solver->a_hasProperty(cellId, SolverCell::IsInvalid) = !m_solver->m_geometry->pointIsInside2(testCorner);
11346 m_solver->a_bndryId(cellId) = -5;
11347 m_solver->a_isInterface(cellId) =
false;
11348 deleteBndryCell(bndryId);
11349 if(bndryId < m_bndryCells->size()) {
11350 m_solver->a_bndryId(m_bndryCells->a[bndryId].m_cellId) = bndryId;
11352 if(!m_solver->m_geometry->pointIsInside2(testCorner)) {
11355 if(edgesCutRm[0] == -1 && edgesCutRm[1] == -1 && newEdgeCut[0] == -1 && newEdgeCut[1] == -1) {
11357 MBool testBool =
false;
11358 for(
MInt j = 0; j < 4; j++) {
11359 for(
MInt i = 0; i < 3; i++) {
11360 testCorner[i] = cornersCell(nodeStencil[0][directionEdgesStencil[direction][j]], i);
11362 if(j > 0 && testBool != m_solver->m_geometry->pointIsInside2(testCorner)) {
11363 cerr <<
"ERROR: cell is not cut but it is not completely inside or completely"
11364 <<
" outside of the fluid region" << endl;
11366 testBool = m_solver->m_geometry->pointIsInside2(testCorner);
11368 if(m_solver->m_geometry->pointIsInside2(testCorner)) {
11371 m_solver->m_bndryRfnJumpInformation_[
cellId] = nghbrId;
11380 for(
MInt cell = 0; cell < m_solver->a_noCells(); cell++) {
11381 if(m_solver->a_bndryId(cell) > -1) {
11385 if(m_solver->c_noChildren(cell) != 0) {
11394 for(
MInt direction = 0; direction < m_noDirs; direction++) {
11395 MBool problemCell =
false;
11397 if(m_solver->a_hasNeighbor(cellId, direction) == 0) {
11398 MInt parentId = m_solver->c_parentId(cellId);
11399 if(parentId > -1) {
11400 if(m_solver->a_hasNeighbor(parentId, direction) == 1) {
11401 problemCell =
true;
11406 if(problemCell ==
true) {
11407 MInt parentId = m_solver->c_parentId(cellId);
11408 MInt nghbrId = m_solver->c_neighborId(parentId, direction);
11409 MInt nghbrbndryId = -1;
11410 MFloat cellHalfLengthParent = F1B2 * m_solver->c_cellLengthAtCell(parentId);
11414 nghbrbndryId = m_solver->a_bndryId(nghbrId);
11415 if(nghbrbndryId == -1) {
11418 MInt noCutPointsNeighbor = m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_noCutPoints;
11419 if(noCutPointsNeighbor == 0)
continue;
11421 for(
MInt i = 0; i < nDim; i++)
11422 centerParent[i] = m_solver->a_coordinate(parentId, i);
11424 for(
MInt n = 0; n < m_noCorners; n++)
11425 for(
MInt i = 0; i < nDim; i++)
11426 cornersParent(n, i) = centerParent[i] + signStencil[n][i] * cellHalfLengthParent;
11428 MFloat cellHalfLengthNeighbor = F1B2 * m_solver->c_cellLengthAtCell(nghbrId);
11432 for(
MInt i = 0; i < nDim; i++)
11433 centerNeighbor[i] = m_solver->a_coordinate(nghbrId, i);
11434 for(
MInt n = 0; n < m_noCorners; n++)
11435 for(
MInt i = 0; i < nDim; i++)
11436 cornersNeighbor(n, i) = centerNeighbor[i] + signStencil[n][i] * cellHalfLengthNeighbor;
11438 MFloat cellHalfLengthCell = F1B2 * m_solver->c_cellLengthAtCell(cellId);
11442 for(
MInt i = 0; i < nDim; i++)
11443 centerCell[i] = m_solver->a_coordinate(cellId, i);
11444 for(
MInt n = 0; n < m_noCorners; n++)
11445 for(
MInt i = 0; i < nDim; i++)
11446 cornersCell(n, i) = centerCell[i] + signStencil[n][i] * cellHalfLengthCell;
11447 const MInt cornerDirectionStencil[8][3] = {{0, 2, 4}, {1, 2, 4}, {0, 3, 4}, {1, 3, 4},
11448 {0, 2, 5}, {1, 2, 5}, {0, 3, 5}, {1, 3, 5}};
11449 const MFloat eps = 0.0000001;
11450 MBool directionMatchesCorner =
false;
11451 MInt cornerId = -1;
11452 for(
MInt n = 0; n < m_noCorners; n++) {
11453 if(abs(cornersParent(n, 0) - cornersCell(n, 0)) < eps && abs(cornersParent(n, 1) - cornersCell(n, 1)) < eps
11454 && abs(cornersParent(n, 2) - cornersCell(n, 2)) < eps) {
11458 for(
MInt i = 0; i < 3; i++) {
11459 if(cornerDirectionStencil[cornerId][i] == direction) {
11460 directionMatchesCorner =
true;
11463 if(directionMatchesCorner ==
false) {
11464 cerr <<
"direction: " << direction << endl;
11465 cerr <<
"direction doesnt match corner! This shouldn't be able to happen."
11466 <<
" Check your grid. Corner id: " << cornerId << endl;
11477 for(
MInt edge = 0; edge < m_noEdges; edge++) {
11478 for(
MInt i = 0; i < nDim; i++) {
11479 dParent[i] = cornersParent(nodeStencil[0][edge], i);
11480 eParent[i] = cornersParent(nodeStencil[1][edge], i);
11482 dNeighbor[i] = cornersNeighbor(nodeStencil[0][edge], i);
11483 eNeighbor[i] = cornersNeighbor(nodeStencil[1][edge], i);
11485 dCell[i] = cornersCell(nodeStencil[0][edge], i);
11486 eCell[i] = cornersCell(nodeStencil[1][edge], i);
11489 const MInt directionEdgesStencil[6][4] = {{0, 4, 8, 10}, {1, 5, 9, 11}, {2, 6, 8, 9},
11490 {3, 7, 10, 11}, {0, 1, 2, 3}, {4, 5, 6, 7}};
11491 const MInt directionEdgesStencilNeighbor[6][4] = {{1, 5, 9, 11}, {0, 4, 8, 10}, {3, 7, 10, 11},
11492 {2, 6, 8, 9}, {4, 5, 6, 7}, {0, 1, 2, 3}};
11493 MInt noEdgesCut = 0;
11494 MInt newEdgeCut[2] = {-1, -1};
11495 MFloat cutPointCoordinatesNeighbor[3][2] = {{0, 0}, {0, 0}, {0, 0}};
11496 for(
MInt i = 0; i < noCutPointsNeighbor; i++) {
11497 for(
MInt j = 0; j < 4; j++) {
11498 if(m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_cutEdge[i] == directionEdgesStencilNeighbor[direction][j]) {
11499 for(
MInt k = 0; k < 3; k++) {
11500 cutPointCoordinatesNeighbor[k][noEdgesCut] =
11501 m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_cutCoordinates[i][k];
11507 if(noEdgesCut == 2) {
11509 MFloat cutPointOne[3] = {0, 0, 0};
11510 MFloat cutPointTwo[3] = {0, 0, 0};
11511 MFloat edgePointOne[3] = {0, 0, 0};
11512 MFloat edgePointTwo[3] = {0, 0, 0};
11513 MInt divisorPosition = -1;
11514 MFloat lineOne[3] = {0, 0, 0};
11515 MFloat lineTwo[3] = {0, 0, 0};
11516 MFloat cutPoint[3] = {0, 0, 0};
11518 MInt noNewCutPoints = 0;
11519 for(
MInt i = 0; i < 3; i++) {
11520 cutPointOne[i] = cutPointCoordinatesNeighbor[i][0];
11521 cutPointTwo[i] = cutPointCoordinatesNeighbor[i][1];
11523 for(
MInt i = 0; i < 4; i++) {
11524 MBool newCutPoint =
false;
11525 MInt edge = directionEdgesStencil[direction][i];
11526 for(
MInt j = 0; j < 3; j++) {
11527 edgePointOne[j] = cornersCell(nodeStencil[0][edge], j);
11528 edgePointTwo[j] = cornersCell(nodeStencil[1][edge], j);
11530 MBool zero =
false;
11531 for(
MInt l = 0; l < 3; l++) {
11532 for(
MInt k = 0; k < 3; k++) {
11533 if(l == k)
continue;
11534 if(zero ==
true)
continue;
11535 if(abs(edgePointOne[l] - 0.0) < eps && abs(edgePointTwo[l] - 0.0) < eps
11536 && abs(edgePointOne[k] - edgePointTwo[k]) < eps
11537 && (!(abs(edgePointOne[k] - 0.0) < eps) || !(abs(edgePointTwo[k] - 0.0) < eps))) {
11539 divisorPosition = k;
11543 for(
MInt l = 0; l < 3; l++) {
11544 for(
MInt k = 0; k < 3; k++) {
11545 if(l == k)
continue;
11546 if(zero ==
true)
continue;
11547 if(abs(edgePointOne[l] - 0.0) < eps && abs(edgePointTwo[l] - 0.0) < eps
11548 && abs(edgePointOne[k] - edgePointTwo[k]) < eps
11549 && ((abs(edgePointOne[k] - 0.0) < eps) && (abs(edgePointTwo[k] - 0.0) < eps))) {
11551 divisorPosition = k;
11556 for(
MInt l = 0; l < 3; l++) {
11557 cutPointOne[l] = cutPointOne[l] + 1;
11558 cutPointTwo[l] = cutPointTwo[l] + 1;
11559 edgePointOne[l] = edgePointOne[l] + 1;
11560 edgePointTwo[l] = edgePointTwo[l] + 1;
11564 lineOne[0] = (cutPointOne[1] * cutPointTwo[2] - cutPointOne[2] * cutPointTwo[1]);
11565 lineOne[1] = (cutPointOne[2] * cutPointTwo[0] - cutPointOne[0] * cutPointTwo[2]);
11566 lineOne[2] = (cutPointOne[0] * cutPointTwo[1] - cutPointOne[1] * cutPointTwo[0]);
11568 lineTwo[0] = (edgePointOne[1] * edgePointTwo[2] - edgePointOne[2] * edgePointTwo[1]);
11569 lineTwo[1] = (edgePointOne[2] * edgePointTwo[0] - edgePointOne[0] * edgePointTwo[2]);
11570 lineTwo[2] = (edgePointOne[0] * edgePointTwo[1] - edgePointOne[1] * edgePointTwo[0]);
11572 cutPoint[0] = (lineOne[1] * lineTwo[2] - lineOne[2] * lineTwo[1]);
11573 cutPoint[1] = (lineOne[2] * lineTwo[0] - lineOne[0] * lineTwo[2]);
11574 cutPoint[2] = (lineOne[0] * lineTwo[1] - lineOne[1] * lineTwo[0]);
11577 for(
MInt l = 0; l < 3; l++) {
11578 cutPointOne[l] = cutPointOne[l] - 1;
11579 cutPointTwo[l] = cutPointTwo[l] - 1;
11580 edgePointTwo[l] = edgePointTwo[l] - 1;
11583 if(zero ==
false) {
11584 for(
MInt l = 0; l < 3; l++) {
11585 if(abs(cutPointOne[l] - cutPointTwo[l]) < eps && abs(cutPointOne[l] - edgePointOne[l]) < eps
11586 && abs(cutPointOne[l] - edgePointTwo[l]) < eps && abs(cutPointTwo[l] - edgePointTwo[l]) < eps) {
11587 divisorPosition = l;
11591 if(divisorPosition == -1) {
11592 cerr <<
"divisorPosition,new is -1; this shouldn't be possible" << endl;
11593 for(
MInt l = 0; l < 3; l++) {
11594 cerr << l <<
": coordinate;"
11595 <<
"cutPointOne: " << cutPointOne[l] <<
" -- cutPointTwo: " << cutPointTwo[l]
11596 <<
" -- edgePointOne: " << edgePointOne[l] <<
" -- edgePointTwo: " << edgePointTwo[l] << endl;
11598 cerr <<
"zero: " << zero << endl;
11599 cerr <<
"direction: " << direction << endl;
11601 divisor = cutPoint[divisorPosition];
11602 divisor = divisor / edgePointOne[divisorPosition];
11604 MBool continueing =
false;
11605 for(
MInt k = 0; k < 3; k++) {
11606 cutPoint[k] = cutPoint[k] / divisor;
11607 if(std::isnan(cutPoint[k])) {
11608 cerr <<
"ERROR: NAN. Divisor: " << divisor <<
" cut point k: " << cutPoint[k] <<
" zero: " << zero
11610 cerr <<
"k: " << k <<
" edgepointone: " << edgePointOne[k] <<
" edgepointtwo: " << edgePointTwo[k]
11612 cerr <<
"k: " << k <<
" cutpointone: " << cutPointOne[k] <<
" cutpointtwo: " << cutPointTwo[k]
11614 cerr <<
"divisorPosition: " << divisorPosition << endl;
11615 cerr <<
"cut points are probably parallel to the edge. continue";
11616 continueing =
true;
11619 if(continueing ==
true) {
11620 continueing =
false;
11625 for(
MInt l = 0; l < 3; l++) {
11626 cutPoint[l] = cutPoint[l] - 1;
11627 edgePointOne[l] = edgePointOne[l] - 1;
11630 if(newCutPointAdjustment ==
true) {
11631 for(
MInt m = 0; m < 3; m++) {
11632 if(abs(edgePointOne[m] - cutPoint[m]) < 0.00000001) {
11635 cutPoint[m] = edgePointOne[m];
11639 for(
MInt n = 0; n < 3; n++) {
11640 if(edgePointTwo[n] > edgePointOne[n] && abs(edgePointOne[n] - cutPoint[n]) > eps
11641 && (edgePointTwo[n] - edgePointOne[n]) > (edgePointTwo[n] - cutPoint[n])
11642 && (edgePointTwo[n] - cutPoint[n]) > 0) {
11644 newCutPoint =
true;
11646 if(edgePointTwo[n] < edgePointOne[n] && abs(edgePointOne[n] - cutPoint[n]) > eps
11647 && (edgePointOne[n] - edgePointTwo[n]) > (edgePointOne[n] - cutPoint[n])
11648 && (edgePointOne[n] - cutPoint[n]) > 0) {
11650 newCutPoint =
true;
11654 if(newCutPoint ==
false) {
11657 cerr <<
"(this is not an error) a non boundary cell with cut points has been found. parentId: " << parentId
11658 <<
" cellId: " <<
cellId << endl;
11660 bndryId = m_bndryCells->size() - 1;
11661 if(m_bndryCells->a[bndryId].m_cellId != cellId) {
11662 cerr <<
"(this is not an error) creating a new boundary cell; cellId: " <<
cellId
11663 <<
" bndryCellId: " << m_bndryCells->a[bndryId].m_cellId << endl;
11665 MInt size = m_bndryCells->size();
11666 cerr << size << endl;
11667 m_bndryCells->resetSize(size + 1);
11671 m_solver->a_isInterface(cellId) =
true;
11672 m_solver->a_bndryId(cellId) = bndryId;
11673 m_bndryCells->a[bndryId].m_cellId =
cellId;
11674 m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel) =
true;
11675 m_solver->a_hasProperty(cellId, SolverCell::IsInvalid) =
false;
11676 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] = -1;
11677 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] = -1;
11678 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] = -1;
11679 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3] = -1;
11682 if(m_bndryCells->a[bndryId].m_cellId == cellId) {
11684 cerr <<
"(this is not an error) cut point is saved in the new boundary cell; cellId: " <<
cellId
11685 <<
" bndryId: " << bndryId << endl;
11686 if(newEdgeCut[0] != -1) {
11687 newEdgeCut[1] = edge;
11689 if(newEdgeCut[0] == -1) {
11690 newEdgeCut[0] = edge;
11694 MInt cutPointNo = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
11695 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPointNo] = edge;
11697 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[cutPointNo] =
11698 m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_bodyId[0];
11699 for(
MInt x = 0; x < nDim; x++) {
11700 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPointNo][x] = cutPoint[x];
11702 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints++;
11703 m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId =
11704 m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_bndryCndId;
11705 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints == 2) {
11707 MFloat pointDifference[3] = {0, 0, 0};
11708 MFloat cutCoordinates[3] = {0, 0, 0};
11709 const MInt edgeInCorner[8][3] = {{0, 2, 8}, {1, 2, 9}, {0, 3, 10}, {1, 3, 11},
11710 {4, 6, 8}, {5, 6, 9}, {4, 7, 10}, {5, 7, 11}};
11711 MInt additionalCutEdge = -1;
11712 for(
MInt x = 0; x < 8; x++) {
11713 for(
MInt z = 0; z < 3; z++) {
11714 if(edgeInCorner[x][z] == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[0]) {
11717 if(edgeInCorner[x][z] == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[1]) {
11722 for(
MInt y = 0;
y < 3;
y++) {
11723 if(edgeInCorner[x][
y] != m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[0]
11724 && edgeInCorner[x][
y] != m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[1]) {
11725 additionalCutEdge = edgeInCorner[x][
y];
11731 for(
MInt j = 0; j < 3; j++) {
11732 edgePointOne[j] = cornersCell(nodeStencil[0][additionalCutEdge], j);
11733 edgePointTwo[j] = cornersCell(nodeStencil[1][additionalCutEdge], j);
11734 pointDifference[j] = edgePointTwo[j] - edgePointOne[j];
11735 pointDifference[j] = pointDifference[j] / 2;
11736 cutCoordinates[j] = edgePointOne[j] + pointDifference[j];
11739 MInt cutPointNo3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
11740 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPointNo3] = additionalCutEdge;
11742 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[cutPointNo3] =
11743 m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_bodyId[0];
11744 for(
MInt x = 0; x < nDim; x++) {
11745 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPointNo3][x] = cutCoordinates[x];
11747 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints++;
11749 cerr <<
"(this is not an error) number of cut points (should first be 1 and then 3): "
11750 << m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints << endl;
11754 if(newEdgeCut[0] != -1 && newEdgeCut[1] != -1) {
11755 bndryId = m_bndryCells->size() - 1;
11756 MInt additionalCutEdge = -1;
11757 MFloat pointDifference[3] = {0, 0, 0};
11758 MFloat cutCoordinates[3] = {0, 0, 0};
11759 const MInt edgeFaceStencil[6][4] = {{8, 10, 0, 4}, {9, 11, 1, 5}, {2, 6, 8, 9},
11760 {3, 7, 10, 11}, {0, 1, 2, 3}, {4, 5, 6, 7}};
11761 const MInt edgeInCorner[8][3] = {{0, 2, 8}, {1, 2, 9}, {0, 3, 10}, {1, 3, 11},
11762 {4, 6, 8}, {5, 6, 9}, {4, 7, 10}, {5, 7, 11}};
11763 for(
MInt i = 0; i < 8; i++) {
11764 MInt additionalCutPoint = -1;
11766 additionalCutEdge = -1;
11767 for(
MInt j = 0; j < 3; j++) {
11768 if(edgeInCorner[i][j] == newEdgeCut[0]) {
11771 if(edgeInCorner[i][j] == newEdgeCut[1]) {
11775 additionalCutPoint = 1;
11777 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] = i;
11782 if(additionalCutPoint == 1) {
11783 for(
MInt j = 0; j < 3; j++) {
11784 if(edgeInCorner[i][j] != newEdgeCut[0] && edgeInCorner[i][j] != newEdgeCut[1]) {
11785 additionalCutEdge = edgeInCorner[i][j];
11788 for(
MInt j = 0; j < 3; j++) {
11789 edgePointOne[j] = cornersCell(nodeStencil[0][additionalCutEdge], j);
11790 edgePointTwo[j] = cornersCell(nodeStencil[1][additionalCutEdge], j);
11791 pointDifference[j] = edgePointTwo[j] - edgePointOne[j];
11792 pointDifference[j] = pointDifference[j] / 2;
11793 cutCoordinates[j] = edgePointOne[j] + pointDifference[j];
11796 for(
MInt k = 0; k < 6; k++) {
11798 MInt problemFace = -1;
11799 for(
MInt l = 0; l < 4; l++) {
11800 if(additionalCutEdge == edgeFaceStencil[k][l]) {
11804 for(
MInt l = 0; l < 4; l++) {
11806 if(newEdgeCut[0] != -1 && newEdgeCut[1] != -1) {
11807 if(newEdgeCut[1] == edgeFaceStencil[k][l] || newEdgeCut[0] == edgeFaceStencil[k][l]) {
11812 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] != -1) {
11814 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] = k;
11817 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] == -1) {
11819 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] = k;
11823 cerr << problemFace << endl;
11828 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] != -1
11829 && m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] != -1) {
11830 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3] = direction;
11832 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints == 50) {
11835 MInt cutPointNo = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
11836 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPointNo] = additionalCutEdge;
11838 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[cutPointNo] =
11839 m_bndryCells->a[nghbrbndryId].m_srfcs[0]->m_bodyId[0];
11840 for(
MInt x = 0; x < nDim; x++) {
11841 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPointNo][x] = cutCoordinates[x];
11843 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints++;
11854 checkCutPointsValidity();
11863 if(m_solver->a_bndryId(cellId) == -1 && !checkInside(cellId)) {
11867 m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel) =
false;
11868 m_solver->a_hasProperty(cellId, SolverCell::IsInvalid) =
true;
11870 if(m_solver->a_bndryId(cellId) == -5) {
11871 m_solver->a_bndryId(cellId) = -1;
11889template <MInt nDim,
class SysEqn>
11893 const MInt noCells = m_bndryCells->size();
11896 for(
MInt bndryId = noCells - 1; bndryId > -1; bndryId--) {
11897 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
11898 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints < nDim) {
11900 m_log <<
"cell " << cellId <<
" on level " << m_solver->a_level(cellId) <<
" with globalId "
11901 << m_solver->c_globalId(cellId) <<
" has less than " << nDim <<
" cut points! deleting bndryCell! " << endl;
11904 m_solver->a_isInterface(cellId) =
false;
11905 m_solver->a_hasProperty(cellId, SolverCell::IsMovingBnd) =
false;
11906 m_solver->a_bndryId(cellId) = -1;
11907 m_solver->a_bndryId(m_bndryCells->a[bndryId].m_cellId) = -1;
11908 deleteBndryCell(bndryId);
11912 if(bndryId < m_bndryCells->size()) {
11913 m_solver->a_bndryId(m_bndryCells->a[bndryId].m_cellId) = bndryId;
11919 if(!checkInside(cellId)) {
11921 if(m_solver->c_noChildren(cellId) == 0) {
11922 cerr << domainId() <<
": cell deactivated"
11923 <<
", cellId " << cellId <<
", globalId " << m_solver->c_globalId(cellId) <<
", level "
11924 << m_solver->a_level(cellId) << endl;
11927 m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel) =
false;
11928 m_solver->a_hasProperty(cellId, SolverCell::IsInvalid) =
true;
11930 MInt parentId = m_solver->c_parentId(cellId);
11932 while(parentId > -1) {
11933 m_solver->a_hasProperty(parentId, SolverCell::IsOnCurrentMGLevel) =
false;
11934 m_solver->a_hasProperty(parentId, SolverCell::IsInvalid) =
true;
11937 parentId = m_solver->c_parentId(parentId);
11939 if(itCnt > m_solver->maxLevel() - m_solver->minLevel()) {
11940 mTerm(1, AT_,
"Invalid parent relations.");
11959template <MInt nDim,
class SysEqn>
11964 const MInt noCells = m_bndryCells->size();
11965 const MInt* traverseOrder = traverseCorners2D;
11966 IF_CONSTEXPR(nDim == 3) traverseOrder = traverseCorners3D;
11969 MInt noShares = noCorners - 1;
11971 MIntScratchSpace sharedCorners(noCorners, noShares, AT_,
"sharedCorners");
11972 for(
MInt c = 0; c < noCorners; c++) {
11973 for(
MInt s = 0; s < noShares; s++) {
11974 IF_CONSTEXPR(nDim == 2) { sharedCorners(c, s) = sharedCornerNeighs2D[c][s]; }
11976 sharedCorners(c, s) = sharedCornerNeighs3D[c][s];
11983 vector<MInt> missing;
11988 for(
MInt bndryId = noCells - 1; bndryId > -1; bndryId--) {
11989 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints < nDim) {
11990 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
11991 MBool found =
false;
11992 MInt insidePt = -1;
11995 for(
MInt corner = 0; corner <
IPOW2(nDim); corner++) {
11996 for(
MInt s = 0; s < noShares; s++) {
11997 MInt dir = sharedCorners(corner, s);
11998 if(m_solver->a_hasNeighbor(cellId, dir)
11999 && !m_solver->a_hasProperty(m_solver->c_neighborId(cellId, dir), SolverCell::IsInterface)) {
12012 cout << insidePt <<
" " << traverseOrder << endl;
12044 if(!missing.empty()) {
12047 for(
MInt bndryId = noCells - 1; bndryId > -1; bndryId--) {
12048 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
12050 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints < nDim) {
12052 m_log <<
"cell " << cellId <<
" on level " << m_solver->a_level(cellId) <<
" with globalId "
12053 << m_solver->c_globalId(cellId) <<
" has less than " << nDim <<
" cut points! deleting bndryCell! " << endl;
12056 m_solver->a_isInterface(cellId) =
false;
12057 m_solver->a_bndryId(cellId) = -1;
12058 m_solver->a_bndryId(m_bndryCells->a[bndryId].m_cellId) = -1;
12059 deleteBndryCell(bndryId);
12063 if(bndryId < m_bndryCells->size()) {
12064 m_solver->a_bndryId(m_bndryCells->a[bndryId].m_cellId) = bndryId;
12070 if(!checkInside(cellId)) {
12072 if(m_solver->c_noChildren(cellId) == 0)
12073 cerr << domainId() <<
": cell deactivated"
12074 <<
", cellId " << cellId <<
", globalId " << m_solver->c_globalId(cellId) <<
", level "
12075 << m_solver->a_level(cellId) << endl;
12078 m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel) =
false;
12079 m_solver->a_hasProperty(cellId, SolverCell::IsInvalid) =
true;
12081 MInt parentId = m_solver->c_parentId(cellId);
12082 while(parentId > -1) {
12083 m_solver->a_hasProperty(parentId, SolverCell::IsOnCurrentMGLevel) =
false;
12084 m_solver->a_hasProperty(parentId, SolverCell::IsInvalid) =
true;
12086 parentId = m_solver->c_parentId(parentId);
12098template <MInt nDim,
class SysEqn>
12101 MBool bndryRfnJump =
false;
12102 bndryRfnJump = Context::getSolverProperty<MBool>(
"bndryRfnJump", m_solverId, AT_, &bndryRfnJump);
12104 if(bndryRfnJump == 0) {
12107 m_log <<
"processing MInts " << endl;
12108 MIntScratchSpace idSendRecBuffers(m_solver->a_noCells() * 12, AT_,
"idSendRecBuffers");
12109 idSendRecBuffers.
fill(0);
12112 for(
MInt cellId = 0; cellId < m_solver->a_noCells(); cellId++) {
12113 if(m_solver->a_bndryId(cellId) < 0) {
12116 MInt bndryId = m_solver->a_bndryId(cellId);
12117 idSendRecBuffers[cellId * 12 + 0] = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
12118 idSendRecBuffers[cellId * 12 + 1] = m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[0];
12119 idSendRecBuffers[cellId * 12 + 2] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[0];
12120 idSendRecBuffers[cellId * 12 + 3] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[1];
12121 idSendRecBuffers[cellId * 12 + 4] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[2];
12122 idSendRecBuffers[cellId * 12 + 5] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[3];
12123 idSendRecBuffers[cellId * 12 + 6] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[4];
12124 idSendRecBuffers[cellId * 12 + 7] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[5];
12125 idSendRecBuffers[cellId * 12 + 8] = m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0];
12126 idSendRecBuffers[cellId * 12 + 9] = m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1];
12127 idSendRecBuffers[cellId * 12 + 10] = m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2];
12128 idSendRecBuffers[cellId * 12 + 11] = m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3];
12130 if(idSendRecBuffers[cellId * 12 + 0] > 0 && m_solver->a_isWindow(cellId)) {
12134 m_log <<
"... " << cnt <<
" window boundary cells to exchange to all domains ... (Ids) " << endl;
12136 m_solver->exchangeData(&idSendRecBuffers[0], 12);
12138 for(
MInt i = 0; i < m_solver->noNeighborDomains(); i++) {
12139 for(
MInt j = 0; j < m_solver->noHaloCells(i); j++) {
12140 MInt thishaloCellId = m_solver->haloCellId(i, j);
12141 MInt bndryId = m_solver->a_bndryId(thishaloCellId);
12142 if(m_solver->a_bndryId(thishaloCellId) < 0) {
12145 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints = idSendRecBuffers[thishaloCellId * 12 + 0];
12146 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[0] = idSendRecBuffers[thishaloCellId * 12 + 1];
12147 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[1] = idSendRecBuffers[thishaloCellId * 12 + 1];
12148 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[2] = idSendRecBuffers[thishaloCellId * 12 + 1];
12149 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[3] = idSendRecBuffers[thishaloCellId * 12 + 1];
12150 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[4] = idSendRecBuffers[thishaloCellId * 12 + 1];
12151 m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[5] = idSendRecBuffers[thishaloCellId * 12 + 1];
12152 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[0] = idSendRecBuffers[thishaloCellId * 12 + 2];
12153 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[1] = idSendRecBuffers[thishaloCellId * 12 + 3];
12154 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[2] = idSendRecBuffers[thishaloCellId * 12 + 4];
12155 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[3] = idSendRecBuffers[thishaloCellId * 12 + 5];
12156 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[4] = idSendRecBuffers[thishaloCellId * 12 + 6];
12157 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[5] = idSendRecBuffers[thishaloCellId * 12 + 7];
12158 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] =
12159 idSendRecBuffers[thishaloCellId * 12 + 8];
12160 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] =
12161 idSendRecBuffers[thishaloCellId * 12 + 9];
12162 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] =
12163 idSendRecBuffers[thishaloCellId * 12 + 10];
12164 m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3] =
12165 idSendRecBuffers[thishaloCellId * 12 + 11];
12168 m_log <<
" finished. " << endl;
12170 m_log <<
"processing MFloats " << endl;
12171 MFloatScratchSpace floatSendRecBuffers(m_solver->a_noCells() * 18, AT_,
"floatSendRecBuffers");
12172 floatSendRecBuffers.
fill(0);
12175 for(
MInt cellId = 0; cellId < m_solver->a_noCells(); cellId++) {
12176 if(m_solver->a_bndryId(cellId) < 0) {
12179 MInt bndryId = m_solver->a_bndryId(cellId);
12181 floatSendRecBuffers[cellId * 18 + 0] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[0][0];
12182 floatSendRecBuffers[cellId * 18 + 1] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[0][1];
12183 floatSendRecBuffers[cellId * 18 + 2] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[0][2];
12184 floatSendRecBuffers[cellId * 18 + 3] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[1][0];
12185 floatSendRecBuffers[cellId * 18 + 4] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[1][1];
12186 floatSendRecBuffers[cellId * 18 + 5] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[1][2];
12187 floatSendRecBuffers[cellId * 18 + 6] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[2][0];
12188 floatSendRecBuffers[cellId * 18 + 7] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[2][1];
12189 floatSendRecBuffers[cellId * 18 + 8] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[2][2];
12190 floatSendRecBuffers[cellId * 18 + 9] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[3][0];
12191 floatSendRecBuffers[cellId * 18 + 10] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[3][1];
12192 floatSendRecBuffers[cellId * 18 + 11] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[3][2];
12193 floatSendRecBuffers[cellId * 18 + 12] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[4][0];
12194 floatSendRecBuffers[cellId * 18 + 13] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[4][1];
12195 floatSendRecBuffers[cellId * 18 + 14] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[4][2];
12196 floatSendRecBuffers[cellId * 18 + 15] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[5][0];
12197 floatSendRecBuffers[cellId * 18 + 16] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[5][1];
12198 floatSendRecBuffers[cellId * 18 + 17] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[5][2];
12199 if((floatSendRecBuffers[cellId * 18 + 0] > 0 || floatSendRecBuffers[cellId * 18 + 1] > 0
12200 || floatSendRecBuffers[cellId * 18 + 2] > 0 || floatSendRecBuffers[cellId * 18 + 3] > 0
12201 || floatSendRecBuffers[cellId * 18 + 4] > 0 || floatSendRecBuffers[cellId * 18 + 5] > 0
12202 || floatSendRecBuffers[cellId * 18 + 6] > 0 || floatSendRecBuffers[cellId * 18 + 7] > 0
12203 || floatSendRecBuffers[cellId * 18 + 8] > 0 || floatSendRecBuffers[cellId * 18 + 9] > 0
12204 || floatSendRecBuffers[cellId * 18 + 10] > 0 || floatSendRecBuffers[cellId * 18 + 11] > 0
12205 || floatSendRecBuffers[cellId * 18 + 12] > 0 || floatSendRecBuffers[cellId * 18 + 13] > 0
12206 || floatSendRecBuffers[cellId * 18 + 14] > 0 || floatSendRecBuffers[cellId * 18 + 15] > 0
12207 || floatSendRecBuffers[cellId * 18 + 16] > 0 || floatSendRecBuffers[cellId * 18 + 17] > 0
12208 || floatSendRecBuffers[cellId * 18 + 0] < 0 || floatSendRecBuffers[cellId * 18 + 1] < 0
12209 || floatSendRecBuffers[cellId * 18 + 2] < 0 || floatSendRecBuffers[cellId * 18 + 3] < 0
12210 || floatSendRecBuffers[cellId * 18 + 4] < 0 || floatSendRecBuffers[cellId * 18 + 5] < 0
12211 || floatSendRecBuffers[cellId * 18 + 6] < 0 || floatSendRecBuffers[cellId * 18 + 7] < 0
12212 || floatSendRecBuffers[cellId * 18 + 8] < 0 || floatSendRecBuffers[cellId * 18 + 9] < 0
12213 || floatSendRecBuffers[cellId * 18 + 10] < 0 || floatSendRecBuffers[cellId * 18 + 11] < 0
12214 || floatSendRecBuffers[cellId * 18 + 12] < 0 || floatSendRecBuffers[cellId * 18 + 13] < 0
12215 || floatSendRecBuffers[cellId * 18 + 14] < 0 || floatSendRecBuffers[cellId * 18 + 15] < 0
12216 || floatSendRecBuffers[cellId * 18 + 16] < 0 || floatSendRecBuffers[cellId * 18 + 17] < 0)
12217 && m_solver->a_isWindow(cellId)) {
12221 m_log <<
"... " << cnt <<
" window boundary cells to exchange to all domains ... (Floats) " << endl;
12224 m_solver->exchangeData(&floatSendRecBuffers[0], 18);
12225 for(
MInt i = 0; i < m_solver->noNeighborDomains(); i++) {
12226 for(
MInt j = 0; j < m_solver->noHaloCells(i); j++) {
12227 MInt thishaloCellId = m_solver->haloCellId(i, j);
12228 MInt bndryId = m_solver->a_bndryId(thishaloCellId);
12229 if(m_solver->a_bndryId(thishaloCellId) < 0) {
12233 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[0][0] = floatSendRecBuffers[thishaloCellId * 18 + 0];
12234 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[0][1] = floatSendRecBuffers[thishaloCellId * 18 + 1];
12235 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[0][2] = floatSendRecBuffers[thishaloCellId * 18 + 2];
12236 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[1][0] = floatSendRecBuffers[thishaloCellId * 18 + 3];
12237 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[1][1] = floatSendRecBuffers[thishaloCellId * 18 + 4];
12238 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[1][2] = floatSendRecBuffers[thishaloCellId * 18 + 5];
12239 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[2][0] = floatSendRecBuffers[thishaloCellId * 18 + 6];
12240 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[2][1] = floatSendRecBuffers[thishaloCellId * 18 + 7];
12241 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[2][2] = floatSendRecBuffers[thishaloCellId * 18 + 8];
12242 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[3][0] = floatSendRecBuffers[thishaloCellId * 18 + 9];
12243 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[3][1] = floatSendRecBuffers[thishaloCellId * 18 + 10];
12244 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[3][2] = floatSendRecBuffers[thishaloCellId * 18 + 11];
12245 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[4][0] = floatSendRecBuffers[thishaloCellId * 18 + 12];
12246 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[4][1] = floatSendRecBuffers[thishaloCellId * 18 + 13];
12247 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[4][2] = floatSendRecBuffers[thishaloCellId * 18 + 14];
12248 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[5][0] = floatSendRecBuffers[thishaloCellId * 18 + 15];
12249 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[5][1] = floatSendRecBuffers[thishaloCellId * 18 + 16];
12250 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[5][2] = floatSendRecBuffers[thishaloCellId * 18 + 17];
12253 m_log <<
" finished. " << endl;
12261template <MInt nDim,
class SysEqn>
12265 const MChar* fileName =
"AllCutPoints_";
12266 stringstream fileName2;
12267 fileName2 << fileName << domainId() <<
".vtk";
12269 ofl.open((fileName2.str()).c_str(), ofstream::trunc);
12271 MInt noCutPoints = 0;
12272 const MInt noCells = m_bndryCells->size();
12277 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
12278 noCutPoints += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
12282 ofl.setf(ios::fixed);
12285 ofl <<
"# vtk DataFile Version 3.0" << endl
12286 <<
"MAIAD intersectionPoints file" << endl
12288 <<
"DATASET POLYDATA" << endl
12289 <<
"POINTS " << noCutPoints <<
" float" << endl;
12292 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
12293 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints > 0) {
12294 for(
MInt edge = 0; edge < m_noEdges; edge++) {
12295 for(
MInt n = 0; n < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; n++) {
12296 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[n] == edge) {
12297 for(
MInt i = 0; i < nDim; i++) {
12298 ofl << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[n][i] <<
" ";
12300 IF_CONSTEXPR(nDim == 2) ofl << F0 <<
" ";
12308 ofl <<
"VERTICES " << noCutPoints <<
" " << noCutPoints * 2 << endl;
12309 for(
MInt i = 0; i < noCutPoints; i++) {
12310 ofl <<
"1 " << i << endl;
12323template <MInt nDim,
class SysEqn>
12325 MFloat* referencePoint) {
12327 for(
MInt i = F0; i < nDim; i++) {
12328 referencePoint[i] = F0;
12331 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
12332 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
12334 if(m_solver->a_isHalo(cellId))
continue;
12335 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
12336 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
12338 const MInt bndryId = m_solver->a_bndryId(cellId);
12344 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
12346 area = m_solver->a_surfaceArea(srfcId);
12348 for(
MInt dir = 0; dir < m_noDirs; dir++) {
12349 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dir];
12350 if(srfcId > -1)
break;
12353 cerr <<
"[" << domainId() <<
"]: did not find associated surface in dir " << dirN <<
" for cell " << cellId
12355 writeStlFileOfCell(cellId,
"cell.stl");
12356 mTerm(1, AT_,
"something went wrong!");
12358 area = m_solver->a_surfaceArea(srfcId);
12361 IF_CONSTEXPR(nDim == 2) { area = m_solver->c_cellLengthAtCell(cellId); }
12363 area =
POW2(m_solver->c_cellLengthAtCell(cellId));
12366 inflowArea += area;
12368 for(
MInt i = 0; i < nDim; i++) {
12369 referencePoint[i] += m_solver->a_coordinate(cellId, i) * area;
12373 MInt minDom = domainId();
12375 if(noDomains() > 1) {
12376 const MInt noExchangeData = 1 + nDim;
12378 comm_buff[0] = inflowArea;
12379 for(
MInt i = 0; i < nDim; i++) {
12380 comm_buff[i + 1] = referencePoint[i];
12383 MPI_Allreduce(MPI_IN_PLACE, &comm_buff[0], noExchangeData, MPI_DOUBLE, MPI_SUM,
12384 m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
"MPI_IN_PLACE",
"comm_buff[0]");
12385 MPI_Allreduce(MPI_IN_PLACE, &minDom, 1, MPI_INT, MPI_MIN, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
12386 "MPI_IN_PLACE",
"minDom");
12388 inflowArea = comm_buff[0];
12389 for(
MInt i = 0; i < nDim; i++) {
12390 referencePoint[i] = comm_buff[i + 1];
12394 for(
MInt i = 0; i < nDim; i++) {
12395 referencePoint[i] /= inflowArea;
12398 stringstream referencePointOutputStream;
12399 referencePointOutputStream << referencePoint[0] <<
" " << referencePoint[1] <<
" ";
12400 IF_CONSTEXPR(nDim == 3) referencePointOutputStream << referencePoint[2] <<
" ";
12402 if(domainId() == minDom) {
12403 cerr <<
" [" << domainId() <<
"]: bndryId: " << bcId <<
" refPoint: " << referencePointOutputStream.str()
12404 <<
", area: " << inflowArea << endl;
12415template <MInt nDim,
class SysEqn>
12419 MInt noCells = m_solver->a_noCells();
12420 MInt noDirs = 2 * nDim;
12423 m_bndryCells->resetSize(0);
12425 for(
MInt cellId = 0; cellId < noCells; cellId++) {
12426 if(m_solver->a_isInterface(cellId)) {
12427 if(isCutOffInterface(cellId)) {
12430 MInt bndryId = m_bndryCells->size();
12431 m_bndryCells->append();
12432 m_bndryCells->a[bndryId].m_cellId = cellId;
12433 m_bndryCells->a[bndryId].m_linkedCellId = -1;
12434 for(
MInt face = 0; face < noDirs; face++) {
12435 m_bndryCells->a[bndryId].m_associatedSrfc[face] = -1;
12437 for(
MInt i = 0; i < nDim; i++) {
12438 m_bndryCells->a[bndryId].m_coordinates[i] = F0;
12450template <MInt nDim,
class SysEqn>
12454 createBndryCells();
12456 computeReverseMap();
12458 computeCutPoints();
12461 exchangeComputedCutPoints();
12463 if(m_multipleGhostCells || m_solver->m_useCreateCutFaceMGC) {
12464 createCutFaceMGC();
12466 cerr <<
"cut faces created! " << endl;
12473 if(m_multipleGhostCells) {
12476 MFloat* normal = normal_scratch.getPointer();
12477 MFloat* referencePoint = referencePoint_scratch.getPointer();
12478 MInt noInflowCorrectionBoundaries = 0;
12480 MBool normalsCentersSpecified =
false;
12495 if(noInflowCorrectionBoundaries) {
12498 normalsCentersSpecified =
true;
12513 cerr <<
" Warning in FvBndryCnd3D::generateBndryCells: property inflowCorrectionNormals has not enough "
12514 "entries! Go on without normals specified. Please check!"
12516 normalsCentersSpecified =
false;
12519 cerr <<
" Warning in FvBndryCnd3D::generateBndryCells: property inflowCorrectionCenters has not enough "
12520 "entries! Go on without normals specified. Please check!"
12522 normalsCentersSpecified =
false;
12526 for(
MInt i = 0; i < noInflowCorrectionBoundaries; i++) {
12527 bcId = Context::getSolverProperty<MInt>(
"inflowCorrectionBoundaries", m_solverId, AT_, i);
12528 if(normalsCentersSpecified) {
12529 cerr <<
" reading normal and reference point for bndry " << i <<
" with bcId " << bcId << endl;
12530 for(
MInt d = 0; d < nDim; d++) {
12531 normal[d] = Context::getSolverProperty<MFloat>(
"inflowCorrectionNormals", m_solverId, AT_, i * nDim + d);
12532 referencePoint[d] =
12533 Context::getSolverProperty<MFloat>(
"inflowCorrectionCenters", m_solverId, AT_, i * nDim + d);
12535 cerr <<
" normal: " << normal[0] <<
" " << normal[1] <<
" " << normal[2] <<
", refPOint: " << referencePoint[0]
12536 <<
" " << referencePoint[1] <<
" " << referencePoint[2] << endl;
12537 correctInflowBoundary(bcId, normal, referencePoint);
12539 correctInflowBoundary(bcId);
12544 ASSERT(!m_cellCoordinatesCorrected,
"");
12545 for(
MInt bndryId = 0; bndryId < m_bndryCells->size(); bndryId++) {
12546 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
12547 if(m_solver->a_hasProperty(cellId, SolverCell::IsInvalid))
continue;
12548 m_bndryCells->a[bndryId].m_gapDistance = std::numeric_limits<MFloat>::max();
12549 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
12550 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance = F0;
12551 for(
MInt i = 0; i < nDim; i++) {
12552 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVectorCentroid[i] =
12553 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
12554 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance +=
12555 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]
12556 * (m_solver->a_coordinate(cellId, i) + m_bndryCells->a[bndryId].m_coordinates[i]
12557 - m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i]);
12559 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance =
12560 mMax(F0, m_bndryCells->a[bndryId].m_srfcs[srfc]->m_centroidDistance);
12565 if(m_createBoundaryAtCutoff) createBoundaryAtCutoff();
12567 createBndryCndHandler();
12569 createSortedBndryCellList();
12571 if(m_createSpongeBoundary) createSpongeAtSpongeBndryCnds();
12573 checkBoundaryCells();
12578 initBndryCommunications();
12581 for(
MInt bcId = 0; bcId < m_noCutOffBndryCndIds; bcId++) {
12582 if(m_sortedCutOffCells[bcId]->size() > 0) {
12583 MInt noTotalCutOffCellsCheck = m_sortedCutOffCells[bcId]->size();
12584 MPI_Allreduce(MPI_IN_PLACE, &noTotalCutOffCellsCheck, 1, MPI_INT, MPI_SUM,
12585 m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
"INPLACE",
"noTotalCutOffCellsCheck");
12598template <MInt nDim,
class SysEqn>
12603 const MInt noCells = m_bndryCells->size();
12604 for(
MInt id = 0;
id < noCells;
id++) {
12605 for(
MInt srfc = 0; srfc < m_bndryCells->a[
id].m_noSrfcs; srfc++) {
12606 const MInt cellId = m_bndryCells->a[
id].m_cellId;
12607 if(!m_multipleGhostCells) {
12608 if(m_solver->c_noChildren(cellId) > 0 || (!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))) {
12612 MFloat testVector0[nDim]{};
12613 MInt component[nDim - 1]{};
12616 if(fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[0])
12617 < fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[1])) {
12618 IF_CONSTEXPR(nDim == 3) {
12619 if(fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[0])
12620 < fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[2])) {
12622 if(fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[1])
12623 < fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[2])) {
12633 else IF_CONSTEXPR(nDim == 2) {
12637 IF_CONSTEXPR(nDim == 3) {
12638 if(fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[1])
12639 < fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[2])) {
12641 if(fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[0])
12642 < fabs(m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[2])) {
12652 else IF_CONSTEXPR(nDim == 2) {
12656 testVector0[component[0]] = F1;
12661 for(
MInt i = 0; i < nDim; i++) {
12662 sp[0] += testVector0[i] * m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[i];
12665 for(
MInt i = 0; i < nDim; i++) {
12666 m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[i] =
12667 testVector0[i] - sp[0] * m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[i];
12671 for(
MInt i = 0; i < nDim; i++) {
12672 sp[0] +=
POW2(m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[i]);
12674 sp[0] = F1 / sqrt(sp[0]);
12675 for(
MInt i = 0; i < nDim; i++) {
12676 m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[i] *= sp[0];
12678 IF_CONSTEXPR(nDim == 3) {
12680 MFloat testVector1[nDim]{};
12681 testVector1[component[1]] = F1;
12684 for(
MInt i = 0; i < nDim; i++) {
12685 sp[0] += testVector1[i] * m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[i];
12689 for(
MInt i = 0; i < nDim; i++) {
12690 sp[1] += testVector1[i] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[i];
12693 for(
MInt i = 0; i < nDim; i++) {
12694 m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector1[i] =
12695 testVector1[i] - sp[0] * m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[i]
12696 - sp[1] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[i];
12700 for(
MInt i = 0; i < nDim; i++) {
12701 sp[0] +=
POW2(m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector1[i]);
12703 sp[0] = F1 / sqrt(sp[0]);
12704 for(
MInt i = 0; i < nDim; i++) {
12705 m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector1[i] *= sp[0];
12709 MFloat normalVector[nDim];
12710 if(m_multipleGhostCells) {
12712 for(
MInt i = 0; i < nDim; i++) {
12713 normalVector[i] = m_bndryCells->a[
id].m_srfcs[srfc]->m_normalVector[i];
12716 const MInt ghostCellId = m_bndryCells->a[
id].m_srfcVariables[srfc]->m_ghostCellId;
12719 MFloat coordinates[nDim];
12721 for(
MInt i = 0; i < nDim; i++) {
12722 coordinates[i] = m_solver->a_coordinate(cellId, i) - m_solver->a_coordinate(ghostCellId, i);
12724 MFloat FtotalDistance = F0;
12725 for(
MInt i = 0; i < nDim; i++) {
12726 FtotalDistance +=
POW2(coordinates[i]);
12728 FtotalDistance = F1 / sqrt(FtotalDistance);
12729 for(
MInt i = 0; i < nDim; i++) {
12730 normalVector[i] = coordinates[i] * FtotalDistance;
12735 MFloat JacobianQuotient;
12737 IF_CONSTEXPR(nDim == 2) {
12738 JacobianQuotient = normalVector[0] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[1]
12739 - normalVector[1] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[0];
12741 else IF_CONSTEXPR(nDim == 3) {
12742 JacobianQuotient = normalVector[0] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[1]
12743 * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector1[2]
12744 + normalVector[1] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[2]
12745 * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector1[0]
12746 + normalVector[2] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[0]
12747 * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector1[1]
12748 - normalVector[0] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[2]
12749 * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector1[1]
12750 - normalVector[1] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[0]
12751 * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector1[2]
12752 - normalVector[2] * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector0[1]
12753 * m_bndryCells->a[
id].m_srfcs[srfc]->m_planeVector1[0];
12755 m_bndryCells->a[
id].m_srfcs[srfc]->m_FJacobian = F1 / JacobianQuotient;
12765template <MInt nDim,
class SysEqn>
12769 MInt size = m_bndryCells->size();
12771 mTerm(1, AT_,
"collector is empty.");
12776 char* rawMemory = m_bndryCells->getRawPointer();
12778 to = (
void*)(rawMemory + dataSize * (
MLong)
id);
12779 from = (
void*)(rawMemory + dataSize * (size - 1));
12782 if(size - 1 ==
id) {
12784 m_bndryCells->a[size - 1].allocateElements(from, (
void*)m_bndryCells->getRawPointer(), size - 1);
12786 m_bndryCells->setSize(size - 1);
12792 m_bndryCells->a[
id] = m_bndryCells->a[size - 1];
12795 memcpy(to, from, dataSize);
12799 m_bndryCells->a[
id].moveElements(to);
12802 m_bndryCells->a[size - 1].allocateElements(from, (
void*)m_bndryCells->getRawPointer(), size - 1);
12805 m_bndryCells->setSize(size - 1);
12815template <MInt nDim,
class SysEqn>
12822 MInt noSurfaces = m_solver->a_noSurfaces();
12823 MInt otherId[2] = {1, 0};
12827 for(
MInt srfcId = 0; srfcId < noSurfaces; srfcId++) {
12828 for(
MInt nghbrId = 0; nghbrId < 2; nghbrId++) {
12829 cellId = m_solver->a_surfaceNghbrCellId(srfcId, nghbrId);
12830 if(m_solver->a_bndryId(cellId) < 0) {
12834 bndryId = m_solver->a_bndryId(cellId);
12836 if(m_bndryCells->a[bndryId].m_linkedCellId == -1) {
12840 masterCellId = m_bndryCells->a[bndryId].m_linkedCellId;
12844 if(m_solver->a_surfaceNghbrCellId(srfcId, otherId[nghbrId]) == masterCellId) {
12846 cerr <<
" srfc: " << srfcId <<
" cellId: " << cellId <<
" master: " << masterCellId
12847 <<
" other neighbor: " << m_solver->a_surfaceNghbrCellId(srfcId, otherId[nghbrId]) << endl;
12848 mTerm(1, AT_,
"correctMasterSlaveSurfaces ERROR, exiting...");
12852 m_solver->a_surfaceNghbrCellId(srfcId, nghbrId) = masterCellId;
12866template <MInt nDim,
class SysEqn>
12870 const MInt noSmallCells = m_smallBndryCells->size();
12876 MInt noUnknowns = nDim;
12879 MBool bcCell =
false;
12883 for(
MInt bc = m_bndryCndCells[bcId]; bc < m_bndryCndCells[bcId + 1]; bc++) {
12884 bndryId = m_sortedBndryCells->a[bc];
12885 cellId = m_bndryCells->a[bndryId].m_cellId;
12886 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
12889 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient)) {
12892 if(m_bndryCells->a[bndryId].m_linkedCellId > -1) {
12895 if(m_solver->c_noChildren(cellId) > 0) {
12899 noNghbrIds = m_solver->a_noReconstructionNeighbors(cellId);
12902 for(
MInt cell = 0; cell < noNghbrIds; cell++) {
12903 id = m_solver->a_reconstructionNeighborId(cellId, cell);
12904 if(!m_solver->a_isBndryGhostCell(
id)) {
12905 for(
MInt i = 0; i < nDim; i++) {
12906 x[i] = m_solver->a_coordinate(
id, i);
12909 computeMirrorCoordinates(m_solver->a_bndryId(m_solver->getAssociatedInternalCell(
id)), x);
12912 for(
MInt i = 0; i < nDim; i++) {
12913 m_solver->m_A[cell][i] = x[i] - m_solver->a_coordinate(cellId, i);
12916 if(m_solver->m_orderOfReconstruction == 2) {
12917 for(
MInt i = 0; i < nDim; i++) {
12918 m_solver->m_A[cell][nDim + i] =
POW2(x[i] - m_solver->a_coordinate(cellId, i));
12920 m_solver->m_A[cell][2 * nDim + 1] =
12921 (x[0] - m_solver->a_coordinate(cellId, 0)) * (x[1] - m_solver->a_coordinate(cellId, 1));
12922 m_solver->m_A[cell][2 * nDim + 2] =
12923 (x[0] - m_solver->a_coordinate(cellId, 0)) * (x[2] - m_solver->a_coordinate(cellId, 2));
12924 m_solver->m_A[cell][2 * nDim + 3] =
12925 (x[1] - m_solver->a_coordinate(cellId, 1)) * (x[2] - m_solver->a_coordinate(cellId, 2));
12930 for(
MInt i = 0; i < noUnknowns; i++) {
12931 for(
MInt j = 0; j < noUnknowns; j++) {
12932 m_solver->m_ATA[i][j] = F0;
12933 for(
MInt k = 0; k < noNghbrIds; k++) {
12934 m_solver->m_ATA[i][j] += m_solver->m_A[k][i] * m_solver->m_A[k][j];
12940 const MFloat epsilon =
POW3(m_solver->c_cellLengthAtLevel(m_solver->maxRefinementLevel()) / (1000.0));
12944 for(
MInt i = 0; i < noUnknowns; i++) {
12945 for(
MInt j = 0; j < noNghbrIds; j++) {
12946 m_solver->m_ATA[i][j] = F0;
12947 for(
MInt k = 0; k < noUnknowns; k++) {
12948 m_solver->m_ATA[i][j] += m_solver->m_ATAi[i][k] * m_solver->m_A[j][k];
12954 for(
MInt nghbr = 0; nghbr < noNghbrIds; nghbr++) {
12955 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
12958 if(!m_solver->a_isBndryGhostCell(nghbrId)) {
12959 for(
MInt i = 0; i < nDim; i++) {
12960 m_reconstructionConstants[bndryId][nDim * nghbr + i] = m_solver->m_ATA[i][nghbr];
12963 for(
MInt i = 0; i < nDim; i++) {
12964 m_reconstructionConstants[bndryId][nDim * nghbr + i] = F0;
12971 for(
MInt sid = 0; sid < noSmallCells; sid++) {
12973 bndryId = m_smallBndryCells->a[sid];
12974 cellId = m_bndryCells->a[bndryId].m_linkedCellId;
12976 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
12978 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
12986 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
12989 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient)) {
12992 if(m_solver->a_bndryId(cellId) > -1) {
12997 noNghbrIds = m_solver->a_noReconstructionNeighbors(cellId);
13000 for(
MInt cell = 0; cell < noNghbrIds; cell++) {
13001 id = m_solver->a_reconstructionNeighborId(cellId, cell);
13002 if(!m_solver->a_isBndryGhostCell(
id)) {
13003 for(
MInt i = 0; i < nDim; i++) {
13004 x[i] = m_solver->a_coordinate(
id, i);
13007 computeMirrorCoordinates(m_solver->a_bndryId(m_solver->getAssociatedInternalCell(
id)), x);
13010 for(
MInt i = 0; i < nDim; i++) {
13011 m_solver->m_A[cell][i] = x[i] - m_solver->a_coordinate(cellId, i);
13014 if(m_solver->m_orderOfReconstruction == 2) {
13015 for(
MInt i = 0; i < nDim; i++) {
13016 m_solver->m_A[cell][nDim + i] =
POW2(x[i] - m_solver->a_coordinate(cellId, i));
13018 m_solver->m_A[cell][2 * nDim + 1] =
13019 (x[0] - m_solver->a_coordinate(cellId, 0)) * (x[1] - m_solver->a_coordinate(cellId, 1));
13020 m_solver->m_A[cell][2 * nDim + 2] =
13021 (x[0] - m_solver->a_coordinate(cellId, 0)) * (x[2] - m_solver->a_coordinate(cellId, 2));
13022 m_solver->m_A[cell][2 * nDim + 3] =
13023 (x[1] - m_solver->a_coordinate(cellId, 1)) * (x[2] - m_solver->a_coordinate(cellId, 2));
13028 for(
MInt i = 0; i < noUnknowns; i++) {
13029 for(
MInt j = 0; j < noUnknowns; j++) {
13030 m_solver->m_ATA[i][j] = F0;
13031 for(
MInt k = 0; k < noNghbrIds; k++) {
13032 m_solver->m_ATA[i][j] += m_solver->m_A[k][i] * m_solver->m_A[k][j];
13038 const MFloat epsilon =
POW3(m_solver->c_cellLengthAtLevel(m_solver->maxRefinementLevel()) / (1000.0));
13042 for(
MInt i = 0; i < noUnknowns; i++) {
13043 for(
MInt j = 0; j < noNghbrIds; j++) {
13044 m_solver->m_ATA[i][j] = F0;
13045 for(
MInt k = 0; k < noUnknowns; k++) {
13046 m_solver->m_ATA[i][j] += m_solver->m_ATAi[i][k] * m_solver->m_A[j][k];
13052 for(
MInt nghbr = 0; nghbr < noNghbrIds; nghbr++) {
13053 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
13056 if(!m_solver->a_isBndryGhostCell(nghbrId)) {
13057 for(
MInt i = 0; i < nDim; i++) {
13058 m_reconstructionConstants[bndryId][nDim * nghbr + i] = m_solver->m_ATA[i][nghbr];
13061 for(
MInt i = 0; i < nDim; i++) {
13062 m_reconstructionConstants[bndryId][nDim * nghbr + i] = F0;
13082template <MInt nDim,
class SysEqn>
13095 for(
MInt bndryId = 0; bndryId < m_bndryCells->size(); bndryId++) {
13096 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
13097 cellId = m_bndryCells->a[bndryId].m_cellId;
13098 linkedCell = m_bndryCells->a[bndryId].m_linkedCellId;
13099 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13100 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient)) {
13103 if(!m_solver->a_hasProperty(cellId, SolverCell::IsFlux)) {
13110 if(linkedCell > -1) {
13111 cellId = linkedCell;
13114 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient)) {
13117 if(!m_solver->a_hasProperty(cellId, SolverCell::IsFlux)) {
13125 for(
MInt i = 0; i < nDim; i++) {
13126 for(
MInt varId = 0; varId < PV->noVariables; varId++) {
13127 m_solver->a_slope(cellId, varId, i) = F0;
13132 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
13133 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
13136 if(m_solver->a_isBndryGhostCell(nghbrId)) {
13139 for(
MInt i = 0; i < nDim; i++) {
13140 for(
MInt varId = 0; varId < PV->noVariables; varId++) {
13141 m_solver->a_slope(cellId, varId, i) +=
13142 m_reconstructionConstants[bndryId][nghbr * nDim + i]
13143 * (m_solver->a_pvariable(nghbrId, varId) - m_solver->a_pvariable(cellId, varId));
13150 for(
MInt i = 0; i < nDim; i++) {
13152 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageCoordinates[i] - m_solver->a_coordinate(cellId, i);
13156 for(
MInt varId = 0; varId < PV->noVariables; varId++) {
13158 oldVar = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[varId];
13161 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[varId] =
13162 m_solver->a_pvariable(cellId, varId);
13163 for(
MInt i = 0; i < nDim; i++) {
13164 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[varId] +=
13165 dx[i] * m_solver->a_slope(cellId, varId, i);
13168 diff = abs((oldVar - m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[varId])
13169 / m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[varId]);
13186template <MInt nDim,
class SysEqn>
13190 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"Info: untested for 3D."); }
13198 MFloat thermalProfileStartFactor = m_solver->m_thermalProfileStartFactor;
13199 const MFloat TInfinity =
13200 m_solver->m_burntUnburntTemperatureRatio * m_solver->m_temperatureFlameTube * thermalProfileStartFactor;
13203 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13204 bndryId = m_sortedBndryCells->a[
id];
13205 cellId = m_bndryCells->a[bndryId].m_cellId;
13206 linkedCell = m_bndryCells->a[bndryId].m_linkedCellId;
13207 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
13208 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13209 if(linkedCell > -1) {
13210 cellId = linkedCell;
13212 if(linkedCell == -1 || m_solver->a_bndryId(linkedCell) == -1) {
13214 for(
MInt i = 0; i < nDim; i++) {
13215 m_solver->a_slope(cellId, PV->P, i) = F0;
13218 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
13219 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
13220 for(
MInt i = 0; i < nDim; i++) {
13221 m_solver->a_slope(cellId, PV->P, i) +=
13222 m_reconstructionConstants[bndryId][nghbr * nDim + i]
13223 * (m_solver->a_pvariable(nghbrId, PV->P) - m_solver->a_pvariable(cellId, PV->P));
13228 for(
MInt i = 0; i < nDim; i++) {
13229 dx.
p[i] = m_solver->a_coordinate(ghostCellId, i) - m_solver->a_coordinate(cellId, i);
13233 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
13234 for(
MInt i = 0; i < nDim; i++) {
13235 m_solver->a_pvariable(ghostCellId, PV->P) += dx.
p[i] * m_solver->a_slope(cellId, PV->P, i);
13239 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13240 sysEqn().density_ES(m_solver->a_pvariable(ghostCellId, PV->P), TInfinity);
13252template <MInt nDim,
class SysEqn>
13256 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"Info: untested for 3D."); }
13264 MFloat deltaX = m_solver->m_deltaXtemperatureProfile;
13265 MFloat xOffsetTemperatureRise = m_radiusFlameTube + F1B2 * m_solver->m_flameRadiusOffset;
13267 MFloat thermalProfileStartFactor = m_solver->m_thermalProfileStartFactor;
13270 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13271 bndryId = m_sortedBndryCells->a[
id];
13272 cellId = m_bndryCells->a[bndryId].m_cellId;
13273 linkedCell = m_bndryCells->a[bndryId].m_linkedCellId;
13274 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
13275 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13276 if(linkedCell > -1) {
13277 cellId = linkedCell;
13279 if(linkedCell == -1 || m_solver->a_bndryId(linkedCell) == -1) {
13281 for(
MInt i = 0; i < nDim; i++) {
13282 m_solver->a_slope(cellId, PV->P, i) = F0;
13285 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
13286 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
13287 for(
MInt i = 0; i < nDim; i++) {
13288 m_solver->a_slope(cellId, PV->P, i) +=
13289 m_reconstructionConstants[bndryId][nghbr * nDim + i]
13290 * (m_solver->a_pvariable(nghbrId, PV->P) - m_solver->a_pvariable(cellId, PV->P));
13295 for(
MInt i = 0; i < nDim; i++) {
13296 dx.
p[i] = m_solver->a_coordinate(ghostCellId, i) - m_solver->a_coordinate(cellId, i);
13300 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
13301 for(
MInt i = 0; i < nDim; i++) {
13302 m_solver->a_pvariable(ghostCellId, PV->P) += dx.
p[i] * m_solver->a_slope(cellId, PV->P, i);
13305 MFloat temperatureProfile;
13306 if(m_solver->a_coordinate(cellId, 0) > F0) {
13307 temperatureProfile =
13308 (m_solver->m_temperatureFlameTube * thermalProfileStartFactor
13309 + (m_solver->m_burntUnburntTemperatureRatio
13310 - m_solver->m_temperatureFlameTube * thermalProfileStartFactor)
13311 * (tanh(5.0) - F1B2 * tanh(5.0)
13313 * tanh((F2 * (m_solver->a_coordinate(cellId, 0) - xOffsetTemperatureRise) - deltaX) * 5.0
13316 temperatureProfile =
13317 (m_solver->m_temperatureFlameTube * thermalProfileStartFactor
13318 + (m_solver->m_burntUnburntTemperatureRatio
13319 - m_solver->m_temperatureFlameTube * thermalProfileStartFactor)
13320 * (tanh(5.0) - F1B2 * tanh(5.0)
13322 * tanh((neg2 * (m_solver->a_coordinate(cellId, 0) + xOffsetTemperatureRise) - deltaX)
13327 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13328 sysEqn().density_ES(m_solver->a_pvariable(ghostCellId, PV->P), temperatureProfile);
13340template <MInt nDim,
class SysEqn>
13344 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"Info: untested for 3D."); }
13352 MFloat deltaX = m_solver->m_deltaXtemperatureProfile;
13353 MFloat xOffsetTemperatureRise = m_radiusFlameTube + F1B2 * m_solver->m_flameRadiusOffset;
13354 MFloat thermalProfileStartFactor = m_solver->m_thermalProfileStartFactor;
13355 MFloat tempHalfBurnt = m_solver->m_temperatureFlameTube * F1B2 * m_solver->m_burntUnburntTemperatureRatio;
13357 m_solver->m_temperatureFlameTube * m_solver->m_burntUnburntTemperatureRatio * thermalProfileStartFactor;
13361 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13362 bndryId = m_sortedBndryCells->a[
id];
13363 cellId = m_bndryCells->a[bndryId].m_cellId;
13364 linkedCell = m_bndryCells->a[bndryId].m_linkedCellId;
13365 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
13366 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13367 if(linkedCell > -1) {
13368 cellId = linkedCell;
13370 if(linkedCell == -1 || m_solver->a_bndryId(linkedCell) == -1) {
13372 for(
MInt i = 0; i < nDim; i++) {
13373 m_solver->a_slope(cellId, PV->P, i) = F0;
13376 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
13377 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
13378 for(
MInt i = 0; i < nDim; i++) {
13379 m_solver->a_slope(cellId, PV->P, i) +=
13380 m_reconstructionConstants[bndryId][nghbr * nDim + i]
13381 * (m_solver->a_pvariable(nghbrId, PV->P) - m_solver->a_pvariable(cellId, PV->P));
13386 for(
MInt i = 0; i < nDim; i++) {
13387 dx.
p[i] = m_solver->a_coordinate(ghostCellId, i) - m_solver->a_coordinate(cellId, i);
13391 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
13392 for(
MInt i = 0; i < nDim; i++) {
13393 m_solver->a_pvariable(ghostCellId, PV->P) += dx.
p[i] * m_solver->a_slope(cellId, PV->P, i);
13396 MFloat temperatureProfile;
13397 if(m_solver->a_coordinate(cellId, 0) > F0) {
13398 temperatureProfile =
13400 + (tempBurnt - tempHalfBurnt)
13401 * (tanh(5.0) - F1B2 * tanh(5.0)
13403 * tanh((F2 * (m_solver->a_coordinate(cellId, 0) - xOffsetTemperatureRise) - deltaX) * 5.0
13406 temperatureProfile =
13408 + (tempBurnt - tempHalfBurnt)
13409 * (tanh(5.0) - F1B2 * tanh(5.0)
13411 * tanh((neg2 * (m_solver->a_coordinate(cellId, 0) + xOffsetTemperatureRise) - deltaX) * 5.0
13416 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13417 sysEqn().density_ES(m_solver->a_pvariable(ghostCellId, PV->P), temperatureProfile);
13429template <MInt nDim,
class SysEqn>
13433 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"Info: untested for 3D."); }
13441 MFloat deltaY = m_solver->m_deltaYtemperatureProfile;
13442 MFloat yOffsetTemperatureRise = m_solver->m_yOffsetFlameTube - deltaY;
13445 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13446 bndryId = m_sortedBndryCells->a[
id];
13447 cellId = m_bndryCells->a[bndryId].m_cellId;
13448 linkedCell = m_bndryCells->a[bndryId].m_linkedCellId;
13449 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
13450 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13451 if(linkedCell > -1) {
13452 cellId = linkedCell;
13454 if(linkedCell == -1 || m_solver->a_bndryId(linkedCell) == -1) {
13456 for(
MInt i = 0; i < nDim; i++) {
13457 m_solver->a_slope(cellId, PV->P, i) = F0;
13460 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
13461 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
13462 for(
MInt i = 0; i < nDim; i++) {
13463 m_solver->a_slope(cellId, PV->P, i) +=
13464 m_reconstructionConstants[bndryId][nghbr * nDim + i]
13465 * (m_solver->a_pvariable(nghbrId, PV->P) - m_solver->a_pvariable(cellId, PV->P));
13470 for(
MInt i = 0; i < nDim; i++) {
13471 dx.
p[i] = m_solver->a_coordinate(ghostCellId, i) - m_solver->a_coordinate(cellId, i);
13475 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
13476 for(
MInt i = 0; i < nDim; i++) {
13477 m_solver->a_pvariable(ghostCellId, PV->P) += dx.
p[i] * m_solver->a_slope(cellId, PV->P, i);
13480 const MFloat temperatureProfile =
13481 ((m_solver->m_temperatureFlameTube
13482 + (m_solver->m_burntUnburntTemperatureRatio - m_solver->m_temperatureFlameTube)
13483 * (tanh(5.0) - F1B2 * tanh(5.0)
13485 * tanh((F2 * (m_solver->a_coordinate(cellId, 1) - yOffsetTemperatureRise) - deltaY) * 5.0
13489 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13490 sysEqn().density_ES(m_solver->a_pvariable(ghostCellId, PV->P), temperatureProfile);
13502template <MInt nDim,
class SysEqn>
13506 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"Info: untested for 3D."); }
13514 MFloat deltaY = m_solver->m_deltaYtemperatureProfile;
13515 MFloat yOffsetTemperatureRise = m_solver->m_yOffsetFlameTube - deltaY;
13518 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13519 bndryId = m_sortedBndryCells->a[
id];
13520 cellId = m_bndryCells->a[bndryId].m_cellId;
13521 linkedCell = m_bndryCells->a[bndryId].m_linkedCellId;
13522 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
13523 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13524 if(linkedCell > -1) {
13525 cellId = linkedCell;
13527 if(linkedCell == -1 || m_solver->a_bndryId(linkedCell) == -1) {
13529 for(
MInt i = 0; i < nDim; i++) {
13530 m_solver->a_slope(cellId, PV->P, i) = F0;
13533 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
13534 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
13535 for(
MInt i = 0; i < nDim; i++) {
13536 m_solver->a_slope(cellId, PV->P, i) +=
13537 m_reconstructionConstants[bndryId][nghbr * nDim + i]
13538 * (m_solver->a_pvariable(nghbrId, PV->P) - m_solver->a_pvariable(cellId, PV->P));
13543 for(
MInt i = 0; i < nDim; i++) {
13544 dx.
p[i] = m_solver->a_coordinate(ghostCellId, i) - m_solver->a_coordinate(cellId, i);
13548 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
13549 for(
MInt i = 0; i < nDim; i++) {
13550 m_solver->a_pvariable(ghostCellId, PV->P) += dx.
p[i] * m_solver->a_slope(cellId, PV->P, i);
13554 const MFloat temperatureProfile =
13555 (m_solver->m_temperatureFlameTube
13556 + (F1B2 * m_solver->m_burntUnburntTemperatureRatio - m_solver->m_temperatureFlameTube)
13557 * (tanh(5.0) - F1B2 * tanh(5.0)
13559 * tanh((F2 * (m_solver->a_coordinate(cellId, 1) - yOffsetTemperatureRise) - deltaY) * 5.0
13563 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13564 sysEqn().density_ES(m_solver->a_pvariable(ghostCellId, PV->P), temperatureProfile);
13576template <MInt nDim,
class SysEqn>
13580 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"Info: untested for 3D."); }
13588 const MFloat TInfinityUnburnt = m_solver->m_temperatureFlameTube;
13591 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13592 bndryId = m_sortedBndryCells->a[
id];
13593 cellId = m_bndryCells->a[bndryId].m_cellId;
13594 linkedCell = m_bndryCells->a[bndryId].m_linkedCellId;
13595 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
13596 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13597 if(linkedCell > -1) {
13598 cellId = linkedCell;
13600 if(linkedCell == -1 || m_solver->a_bndryId(linkedCell) == -1) {
13602 for(
MInt i = 0; i < nDim; i++) {
13603 m_solver->a_slope(cellId, PV->P, i) = F0;
13606 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
13607 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
13608 for(
MInt i = 0; i < nDim; i++) {
13609 m_solver->a_slope(cellId, PV->P, i) +=
13610 m_reconstructionConstants[bndryId][nghbr * nDim + i]
13611 * (m_solver->a_pvariable(nghbrId, PV->P) - m_solver->a_pvariable(cellId, PV->P));
13616 for(
MInt i = 0; i < nDim; i++) {
13617 dx.
p[i] = m_solver->a_coordinate(ghostCellId, i) - m_solver->a_coordinate(cellId, i);
13621 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
13622 for(
MInt i = 0; i < nDim; i++) {
13623 m_solver->a_pvariable(ghostCellId, PV->P) += dx.
p[i] * m_solver->a_slope(cellId, PV->P, i);
13627 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13628 sysEqn().density_ES(m_solver->a_pvariable(ghostCellId, PV->P), TInfinityUnburnt);
13637template <MInt nDim,
class SysEqn>
13643 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13644 const MInt bndryId = m_sortedBndryCells->a[
id];
13645 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
13647 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13648 const MBool gapCell = m_solver->a_hasProperty(cellId, SolverCell::IsGapCell);
13650 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
13651 MInt k = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bodyId[0];
13652 ASSERT(k > -1 && k < m_solver->m_noEmbeddedBodies + m_solver->m_noPeriodicGhostBodies,
"");
13653 if(k < 0 || k >= m_solver->m_noEmbeddedBodies + m_solver->m_noPeriodicGhostBodies) {
13654 mTerm(1, AT_,
"Invalid body id: " + to_string(k));
13657 MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
13659 MFloat delta[3] = {F0, F0, F0};
13660 MFloat dr[3] = {F0, F0, F0};
13661 MFloat dw[3] = {F0, F0, F0};
13662 MFloat dg[3] = {F0, F0, F0};
13663 MFloat du[3] = {F0, F0, F0};
13664 MFloat dv[3] = {F0, F0, F0};
13666 for(
MInt i = 0; i < nDim; i++) {
13667 normal[i] = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
13668 dr[i] = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i] - m_solver->m_bodyCenter[k * nDim + i];
13669 du[i] = m_solver->m_bodyAcceleration[k * nDim + i];
13670 dv[i] = m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->VV[i]]
13671 - m_solver->m_bodyVelocity[k * nDim + i];
13672 dn += (m_solver->a_coordinate(cellId, i) - m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i])
13675 if(gapCell && m_solver->m_gapInitMethod > 0) {
13681 for(
MInt i = 0; i < 3; i++) {
13682 dw[i] = m_solver->m_bodyAngularAcceleration[k * 3 + i];
13683 dg[i] = m_solver->m_bodyAngularVelocity[k * 3 + i];
13686 delta[0] = du[0] + dw[1] * dr[2] - dw[2] * dr[1] + dg[1] * dv[2] - dg[2] * dv[1];
13687 delta[1] = du[1] + dw[2] * dr[0] - dw[0] * dr[2] + dg[2] * dv[0] - dg[0] * dv[2];
13688 delta[2] = du[2] + dw[0] * dr[1] - dw[1] * dr[0] + dg[0] * dv[1] - dg[1] * dv[0];
13692 for(
MInt i = 0; i < nDim; i++) {
13693 an += normal[i] * delta[i];
13697 sysEqn().temperature_ES(m_solver->a_pvariable(cellId, PV->RHO), m_solver->a_pvariable(cellId, PV->P));
13698 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == 3008
13699 || m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == 3010) {
13700 surfTemp = m_solver->m_bodyTemperature[m_solver->m_internalBodyId[k]];
13703 if(m_solver->m_engineSetup && m_solver->m_noGapRegions >= 1 && k == 0) {
13704 if(m_solver->a_coordinate(cellId, 1) > 0) {
13706 }
else if(m_solver->a_coordinate(cellId, 1) > -0.1 && m_solver->a_coordinate(cellId, 1) < 0) {
13708 surfTemp = 1 + m_solver->a_coordinate(cellId, 1) / -0.1 * (surfTemp - 1);
13713 const MFloat beta = sysEqn().gamma_Ref() * an / surfTemp;
13714 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_robinFactor = beta;
13716 if(fabs(F1 - beta * dn) < 1e-3) {
13717 cerr <<
"Warning: small denom Robin BC: " << k <<
" " << m_solver->m_internalBodyId[k] <<
" " << beta <<
" "
13718 << dn <<
" " << an <<
" " << surfTemp <<
" " << srfc << endl;
13720 const MFloat fac = (F1 + beta * dn) / (F1 - beta * dn);
13722 m_solver->a_pvariable(ghostCellId, PV->P) = fac * m_solver->a_pvariable(cellId, PV->P);
13723 m_solver->a_pvariable(ghostCellId, PV->RHO) = fac * m_solver->a_pvariable(cellId, PV->RHO);
13726 for(
MInt s = 0; s < m_noSpecies; s++) {
13727 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
13730 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
13731 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
13732 m_solver->a_pvariable(ghostCellId, PV->NN[r]) = -m_solver->a_pvariable(cellId, PV->NN[r]);
13736 MFloat pressure = F1B2 * (m_solver->a_pvariable(cellId, PV->P) + m_solver->a_pvariable(ghostCellId, PV->P));
13737 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->P] = pressure;
13739 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == 3007) {
13740 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO] =
13741 m_solver->a_pvariable(cellId, PV->RHO)
13742 * pow(pressure / m_solver->a_pvariable(cellId, PV->P), sysEqn().gamma_Ref());
13743 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13744 F2 * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO]
13745 - m_solver->a_pvariable(cellId, PV->RHO);
13746 }
else if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == 3008
13747 || m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == 3010) {
13748 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO] = sysEqn().density_ES(pressure, surfTemp);
13749 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13750 F2 * m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO]
13751 - m_solver->a_pvariable(cellId, PV->RHO);
13753 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->RHO] =
13754 F1B2 * (m_solver->a_pvariable(cellId, PV->RHO) + m_solver->a_pvariable(ghostCellId, PV->RHO));
13773template <MInt nDim,
class SysEqn>
13778#pragma omp parallel for
13781 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13782 const MInt cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
13783 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13784 const MInt ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[0]->m_ghostCellId;
13787 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13788 2.0 * m_solver->m_rhoInfinity - m_solver->a_pvariable(cellId, PV->RHO);
13792 for(
MInt i = 0; i < nDim; i++) {
13793 m_solver->a_pvariable(ghostCellId, PV->VV[i]) =
13794 2.0 * m_solver->m_VVInfinity[i] - m_solver->a_pvariable(cellId, PV->VV[i]);
13798 m_solver->a_pvariable(ghostCellId, PV->P) = 2.0 * m_solver->m_PInfinity;
13811template <MInt nDim,
class SysEqn>
13816#pragma omp parallel for
13819 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13820 const MInt cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
13821 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13822 const MInt ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[0]->m_ghostCellId;
13825 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
13828 for(
MInt i = 0; i < nDim; i++) {
13829 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = -m_solver->a_pvariable(cellId, PV->VV[i]);
13833 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
13835 for(
MInt s = 0; s < m_noSpecies; s++) {
13836 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
13852template <MInt nDim,
class SysEqn>
13857#pragma omp parallel for
13860 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13861 const MInt cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
13862 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13863 const MInt ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[0]->m_ghostCellId;
13866 m_solver->a_pvariable(ghostCellId, PV->RHO) =
13867 2.0 * m_solver->m_rhoInfinity - m_solver->a_pvariable(cellId, PV->RHO);
13870 for(
MInt i = 0; i < nDim; i++) {
13871 m_solver->a_pvariable(ghostCellId, PV->VV[i]) =
13872 F2 * m_solver->m_VVInfinity[i] - m_solver->a_pvariable(cellId, PV->VV[i]);
13876 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
13879 m_solver->a_pvariable(ghostCellId, PV->C) = -m_solver->a_pvariable(cellId, PV->C);
13882 IF_CONSTEXPR(isDetChem<SysEqn>) {
13883 for(
MInt s = 0; s < m_noSpecies; s++) {
13884 m_solver->a_pvariable(ghostCellId, PV->Y[s]) =
13885 2.0 * m_solver->m_YInfinity[s] - m_solver->a_pvariable(cellId, PV->Y[s]);
13890 m_solver->a_pvariable(ghostCellId, PV->Y[0]) =
13891 2.0 * m_solver->m_EEGas.alphaIn - m_solver->a_pvariable(cellId, PV->Y[0]);
13893 for(
MInt s = 0; s < m_noSpecies; s++) {
13894 m_solver->a_pvariable(cellId, PV->Y[s]) = 1.0;
13898 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
13899 IF_CONSTEXPR(SysEqn::m_ransModel ==
RANS_SA_DV || SysEqn::m_ransModel ==
RANS_FS) {
13900 m_solver->a_pvariable(ghostCellId, PV->N) =
13901 2.0 * m_solver->m_nuTildeInfinity - m_solver->a_pvariable(cellId, PV->N);
13904 m_solver->a_pvariable(ghostCellId, PV->K) =
13905 2.0 * m_solver->m_kInfinity - m_solver->a_pvariable(cellId, PV->K);
13906 m_solver->a_pvariable(ghostCellId, PV->OMEGA) =
13907 2.0 * m_solver->m_omegaInfinity - m_solver->a_pvariable(cellId, PV->OMEGA);
13924template <MInt nDim,
class SysEqn>
13929#pragma omp parallel for
13931 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13932 const MInt cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
13933 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13934 const MInt ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[0]->m_ghostCellId;
13937 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
13940 for(
MInt i = 0; i < nDim; i++) {
13941 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = m_solver->a_pvariable(cellId, PV->VV[i]);
13945 m_solver->a_pvariable(ghostCellId, PV->P) = 2.0 * m_solver->m_PInfinity - m_solver->a_pvariable(cellId, PV->P);
13947 if(isDetChem<SysEqn> || m_isEEGas) {
13948 for(
MInt s = 0; s < m_noSpecies; s++) {
13949 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
13952 for(
MInt s = 0; s < m_noSpecies; s++) {
13953 m_solver->a_pvariable(cellId, PV->Y[s]) = 0.0;
13958 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
13959 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
13960 m_solver->a_pvariable(ghostCellId, PV->NN[r]) = m_solver->a_pvariable(cellId, PV->NN[r]);
13976template <MInt nDim,
class SysEqn>
13981#pragma omp parallel for
13984 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
13985 const MInt cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
13986 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
13987 const MInt ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[0]->m_ghostCellId;
13990 m_solver->a_pvariable(ghostCellId, PV->RHO) = 2.0 * m_solver->m_rhoCg - m_solver->a_pvariable(cellId, PV->RHO);
13993 m_solver->a_pvariable(ghostCellId, PV->VV[0]) = 2.0 * m_solver->m_UCg - m_solver->a_pvariable(cellId, PV->U);
13994 m_solver->a_pvariable(ghostCellId, PV->VV[1]) = 2.0 * m_solver->m_VCg - m_solver->a_pvariable(cellId, PV->V);
13995 m_solver->a_pvariable(ghostCellId, PV->VV[2]) = 2.0 * m_solver->m_WCg - m_solver->a_pvariable(cellId, PV->W);
13998 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
14002 for(
MInt s = 0; s < m_noSpecies; s++) {
14003 m_solver->a_pvariable(cellId, PV->Y[s]) = 1.0;
14008 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
14009 IF_CONSTEXPR(SysEqn::m_ransModel ==
RANS_SA_DV || SysEqn::m_ransModel ==
RANS_FS) {
14010 m_solver->a_pvariable(ghostCellId, PV->N) =
14011 2.0 * m_solver->m_nuTildeInfinity - m_solver->a_pvariable(cellId, PV->N);
14014 m_solver->a_pvariable(ghostCellId, PV->K) =
14015 2.0 * m_solver->m_kInfinity - m_solver->a_pvariable(cellId, PV->K);
14016 m_solver->a_pvariable(ghostCellId, PV->OMEGA) =
14017 2.0 * m_solver->m_omegaInfinity - m_solver->a_pvariable(cellId, PV->OMEGA);
14028template <MInt nDim,
class SysEqn>
14030 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bcInit1050 is untested for 2D!"); }
14033 MInt noCells = m_bndryCells->size();
14034 MFloat eps = 0.0001 /
FPOW2(m_solver->maxRefinementLevel());
14039#pragma omp parallel for
14041 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
14042 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId == 1051) {
14043 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
14044 MFloat coordinates[nDim];
14045 MFloat coordinatesP[nDim];
14046 for(
MInt i = 0; i < nDim; i++) {
14047 coordinates[i] = m_solver->a_coordinate(cellId, i) - m_bndryCells->a[bndryId].m_coordinates[i];
14049 for(
MInt bndryId2 = 0; bndryId2 < noCells; bndryId2++) {
14050 if(m_bndryCells->a[bndryId2].m_srfcs[0]->m_bndryCndId == 1052) {
14051 MInt periodicCellId = m_bndryCells->a[bndryId2].m_cellId;
14052 for(
MInt i = 0; i < nDim; i++) {
14053 coordinatesP[i] = m_solver->a_coordinate(periodicCellId, i) - m_bndryCells->a[bndryId2].m_coordinates[i];
14055 if(fabs(coordinates[0] - coordinatesP[0]) < eps && fabs(coordinates[1] - coordinatesP[1]) < eps) {
14056 m_bndryCells->a[bndryId].m_periodicCellId = periodicCellId;
14057 m_bndryCells->a[bndryId2].m_periodicCellId = cellId;
14083template <MInt nDim,
class SysEqn>
14085 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc1091 is untested for 2D!"); }
14097 MFloat referencePoint[3] = {0.0, 0.0, 0.0};
14098 MFloat normal[3] = {0.0, 0.0, 0.0};
14105 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
14106 cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
14107 bndryId = m_solver->a_bndryId(cellId);
14108 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
14109 for(
MInt srfc = 0; srfc < m_bndryCells->a[m_sortedBndryCells->a[
id]].m_noSrfcs; srfc++) {
14111 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
14113 massflux -= (((m_solver->a_pvariable(cellId, PV->U)) * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
14114 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[0]
14115 + (m_solver->a_pvariable(cellId, PV->V)) * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
14116 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[1]
14117 + (m_solver->a_pvariable(cellId, PV->W)) * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
14118 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[2])
14119 * (m_solver->a_pvariable(cellId, PV->RHO)));
14120 inflowArea += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area;
14123 for(
MInt i = 0; i < 3; i++) {
14124 referencePoint[i] += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i]
14125 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area;
14126 normal[i] += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]
14127 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area;
14133 for(
MInt i = 0; i < 3; i++) {
14134 referencePoint[i] /= inflowArea;
14135 normal[i] /= inflowArea;
14139 massflux /= inflowArea;
14142 pressure = sysEqn().p_Ref();
14143 for(
MInt i = 0; i < 20; i++) {
14144 pressure = sysEqn().pressure_IRit(pressure, massflux);
14146 pressure = pressure * sysEqn().p_Ref();
14147 density = sysEqn().density_IR_P(pressure);
14149 localVel = massflux / density;
14151 R = sqrt(inflowArea / PI);
14155 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
14156 cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
14157 bndryId = m_solver->a_bndryId(cellId);
14158 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
14159 for(
MInt srfc = 0; srfc < m_bndryCells->a[m_sortedBndryCells->a[
id]].m_noSrfcs; srfc++) {
14161 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
14162 ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[srfc]->m_ghostCellId;
14165 radius =
POW2(m_solver->a_coordinate(cellId, 0) - referencePoint[0])
14166 +
POW2(m_solver->a_coordinate(cellId, 1) - referencePoint[1])
14167 +
POW2(m_solver->a_coordinate(cellId, 2) - referencePoint[2]);
14168 velocity = 2.0 * localVel * (1 - radius /
POW2(R));
14172 m_solver->a_pvariable(ghostCellId, PV->RHO) = F2 * density - m_solver->a_pvariable(cellId, PV->RHO);
14173 m_solver->a_pvariable(ghostCellId, PV->P) = F2 * pressure - m_solver->a_pvariable(cellId, PV->P);
14174 m_solver->a_pvariable(ghostCellId, PV->U) =
14175 -F2 * velocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[0]
14176 - m_solver->a_pvariable(cellId, PV->U);
14177 m_solver->a_pvariable(ghostCellId, PV->V) =
14178 -F2 * velocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[1]
14179 - m_solver->a_pvariable(cellId, PV->V);
14180 m_solver->a_pvariable(ghostCellId, PV->W) =
14181 -F2 * velocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[2]
14182 - m_solver->a_pvariable(cellId, PV->W);
14196template <MInt nDim,
class SysEqn>
14198 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function bc1101 is untested for 3D!"); }
14204 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
14205 const MInt bndryId = m_sortedBndryCells->a[
id];
14206 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
14207 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
14208 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
14211 m_solver->a_variable(ghostCellId, CV->RHO) = F2 * m_solver->m_rhoInfinity - m_solver->a_variable(cellId, CV->RHO);
14212 const MFloat fRho = F1 / m_solver->a_variable(cellId, CV->RHO);
14215 m_solver->a_variable(ghostCellId, CV->RHO_VV[0]) =
14216 m_solver->a_variable(ghostCellId, CV->RHO)
14217 * (F2 * m_solver->m_UInfinity - m_solver->a_variable(cellId, CV->RHO_VV[0]) * fRho);
14219 m_solver->a_variable(ghostCellId, CV->RHO_VV[1]) =
14220 m_solver->a_variable(ghostCellId, CV->RHO)
14221 * (F2 * m_solver->m_VInfinity - m_solver->a_variable(cellId, CV->RHO_VV[1]) * fRho);
14224 POW2(m_solver->a_variable(cellId, CV->RHO_VV[0])) +
POW2(m_solver->a_variable(cellId, CV->RHO_VV[1]));
14225 IF_CONSTEXPR(nDim == 3) { rhoU +=
POW2(m_solver->a_variable(cellId, CV->RHO_VV[2])); }
14227 MFloat rhoUGC =
POW2(m_solver->a_variable(ghostCellId, CV->RHO_VV[0]))
14228 +
POW2(m_solver->a_variable(ghostCellId, CV->RHO_VV[1]));
14229 IF_CONSTEXPR(nDim == 3) { rhoUGC +=
POW2(m_solver->a_variable(ghostCellId, CV->RHO_VV[2])); }
14231 const MFloat pressureBC =
14232 sysEqn().pressure(m_solver->a_variable(cellId, CV->RHO), rhoU, m_solver->a_variable(cellId, CV->RHO_E));
14234 const MFloat pressureGC = pressureBC;
14236 const MFloat vel = rhoUGC /
POW2(m_solver->a_variable(ghostCellId, CV->RHO));
14238 m_solver->a_variable(ghostCellId, CV->RHO_E) =
14239 sysEqn().internalEnergy(pressureGC, m_solver->a_variable(ghostCellId, CV->RHO), vel);
14261template <MInt nDim,
class SysEqn>
14263 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function bc1102 is untested for 3D!"); }
14268 const MFloat deltaP = 0.0;
14271 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
14272 const MInt bndryId = m_sortedBndryCells->a[
id];
14273 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
14274 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
14275 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
14278 m_solver->a_variable(ghostCellId, CV->RHO) = m_solver->a_variable(cellId, CV->RHO);
14281 m_solver->a_variable(ghostCellId, CV->RHO_VV[0]) = m_solver->a_variable(cellId, CV->RHO_VV[0]);
14282 m_solver->a_variable(ghostCellId, CV->RHO_VV[1]) = m_solver->a_variable(cellId, CV->RHO_VV[1]);
14283 IF_CONSTEXPR(nDim == 3) {
14284 m_solver->a_variable(ghostCellId, CV->RHO_VV[2]) = m_solver->a_variable(cellId, CV->RHO_VV[2]);
14288 POW2(m_solver->a_variable(cellId, CV->RHO_VV[0])) +
POW2(m_solver->a_variable(cellId, CV->RHO_VV[1]));
14289 IF_CONSTEXPR(nDim == 3) { rhoU +=
POW2(m_solver->a_variable(cellId, CV->RHO_VV[2])); }
14291 const MFloat pressureBC =
14292 sysEqn().pressure(m_solver->a_variable(cellId, CV->RHO), rhoU, m_solver->a_variable(cellId, CV->RHO_E));
14293 const MFloat pressureGC = F2 * (m_solver->m_PInfinity - deltaP) - pressureBC;
14294 const MFloat vel = rhoU / m_solver->a_variable(ghostCellId, CV->RHO);
14297 m_solver->a_variable(ghostCellId, CV->RHO_E) =
14298 sysEqn().internalEnergy(pressureGC, m_solver->a_variable(cellId, CV->RHO), vel);
14323template <MInt nDim,
class SysEqn>
14325 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc1156 is untested for 2D!"); }
14335 switch(m_cutOffBndryCndIds[bcId]) {
14346 stringstream errorMessage;
14347 errorMessage <<
"ERROR: Switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
14348 <<
" not matching any case." << endl;
14349 mTerm(1, AT_, errorMessage.str());
14353 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
14354 cellId = m_sortedCutOffCells[bcId]->a[
id];
14355 nghbrId = m_solver->c_neighborId(cellId, d);
14358 for(
MInt i = 0; i < nDim; i++) {
14359 if(i != d / 2) radius +=
POW2(m_solver->a_coordinate(cellId, i));
14361 radius = sqrt(radius);
14364 jet = (F1 / 0.90 - F1) * F1B2 * (1 + tanh((m_primaryJetRadius - radius) / (2 * m_momentumThickness)))
14365 + F1B2 * (1 + tanh((m_secondaryJetRadius - radius) / (2 * m_momentumThickness)));
14368 m_solver->a_pvariable(cellId, PV->VV[0]) = jet * m_targetVelocityFactor * m_targetVelocityFactor;
14369 m_solver->a_pvariable(cellId, PV->VV[1]) = F0;
14370 m_solver->a_pvariable(cellId, PV->VV[2]) = F0;
14371 if(radius <= m_primaryJetRadius) {
14375 m_solver->a_pvariable(cellId, PV->RHO) =
14376 m_solver->m_rhoInfinity * (1 / sysEqn().CroccoBusemann(m_Ma, jet)) / m_solver->m_densityRatio;
14378 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
14379 }
else if(radius <= m_secondaryJetRadius && m_primaryJetRadius <= radius) {
14384 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity * (1 / sysEqn().CroccoBusemann(m_Ma, jet));
14386 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
14409template <MInt nDim,
class SysEqn>
14411 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc1601 is untested for 2D!"); }
14414 if(m_sortedCutOffCells[bcId]->size() == 0) {
14427 MFloat spongeCorrection;
14430 dummyTime = m_solver->m_time / m_bc1601->m_tau_b;
14432 m_bc1601->checkRegeneration(dummyTime);
14434 that = 2.0 * PI * dummyTime;
14435 twopioverlb = 2.0 * PI / m_bc1601->m_l_b;
14437 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
14438 cellId = m_sortedCutOffCells[bcId]->a[
id];
14439 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
14440 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
14442 nghbrId = m_solver->c_neighborId(cellId, 1);
14444 xhat = twopioverlb * m_solver->a_coordinate(cellId, 0);
14445 yhat = twopioverlb * m_solver->a_coordinate(cellId, 1);
14446 zhat = twopioverlb * m_solver->a_coordinate(cellId, 2);
14448 m_bc1601->calculateFlucts(that, xhat, yhat, zhat, fluctChol);
14452 spongeCorrection = 1.0;
14453 if(m_solver->m_noSpongeFactors > 0) {
14454 spongeCorrection = 1.0 - m_solver->a_spongeFactor(cellId) * m_bc1601->m_invSigmaSponge;
14457 m_solver->a_pvariable(cellId, PV->VV[0]) = m_solver->m_UInfinity + fluctChol[0] * spongeCorrection;
14458 m_solver->a_pvariable(cellId, PV->VV[1]) = m_solver->m_VInfinity + fluctChol[1] * spongeCorrection;
14459 m_solver->a_pvariable(cellId, PV->VV[2]) = m_solver->m_WInfinity + fluctChol[2] * spongeCorrection;
14462 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
14465 if(m_solver->checkNeighborActive(cellId, 1)) {
14466 nghbrId = m_solver->c_neighborId(cellId, 1);
14468 cutOffBcMissingNeighbor(cellId,
"bc1601");
14470 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
14473 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_PInfinity;
14477 for(
MInt s = 0; s < m_noSpecies; s++) {
14478 m_solver->a_pvariable(cellId, PV->Y[s]) = 1.0;
14489template <MInt nDim,
class SysEqn>
14491 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bcInit1601 is untested for 2D!"); }
14496 m_bc1601_bcId = bcId;
14499 const MInt noBc1601Cells = m_sortedCutOffCells[bcId]->size();
14503 MPI_Allgather(&noBc1601Cells, 1, MPI_INT, &bc1601CellsPerDomain[0], 1, MPI_INT, mpiComm(), AT_,
"noBc1601Cells ",
14504 "bc1601CellsPerDomain");
14507 const MInt totalNoBc1601Cells = std::accumulate(&bc1601CellsPerDomain[0], &bc1601CellsPerDomain[0] + noDomains(), 0);
14508 m_log <<
"BC1601 inflow boundary total number of cells: " << totalNoBc1601Cells << std::endl;
14509 if(domainId() == 0) {
14510 std::cerr <<
"BC1601 inflow boundary total number of cells: " << totalNoBc1601Cells << std::endl;
14513 MInt noInvolvedRanks = 0;
14516 for(
MInt i = 0; i < noDomains(); i++) {
14517 if(bc1601CellsPerDomain[i] > 0) {
14518 involvedRanks[noInvolvedRanks] = i;
14525 MPI_Group newgroup;
14527 MPI_Group_incl(group, noInvolvedRanks, &involvedRanks[0], &newgroup, AT_);
14535 if(noBc1601Cells == 0) {
14540 MFloat u_total = sysEqn().temperature_IR(m_solver->m_Ma);
14541 u_total = m_solver->m_Ma * sqrt(u_total);
14543 MFloat invSigmaSponge = 1.0;
14544 if(m_solver->m_noSpongeFactors > 0) {
14545 if(m_solver->m_sigmaSponge > 0.0) invSigmaSponge = 1.0 / m_solver->m_sigmaSponge;
14548 if(m_bc1601 !=
nullptr) {
14554 m_bc1601 =
new Bc1601Class<nDim>(newcomm, m_solverId, domainId(), u_total, invSigmaSponge);
14566 m_bc1601MoveGenOutOfSponge =
false;
14567 m_bc1601MoveGenOutOfSponge =
14568 Context::getSolverProperty<MBool>(
"bc1601MoveGenOutOfSponge", m_solverId, AT_, &m_bc1601MoveGenOutOfSponge);
14569 if(m_bc1601MoveGenOutOfSponge) {
14571 MInt noCellsToMove;
14574 noCellsToMove = ceil(m_spongeLayerThickness * m_spongeFactor[0]
14575 / m_solver->c_cellLengthAtLevel(m_solver->maxRefinementLevel()));
14577 <<
"Move bc1601 by " << noCellsToMove <<
" rows into the domain, because of initial Sponge layer " << endl
14579 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
14580 nghbrId = m_sortedCutOffCells[bcId]->a[
id];
14581 for(
MInt i = 0; i < noCellsToMove; i++) {
14582 nghbrId = m_solver->c_neighborId(nghbrId, 1);
14584 m_sortedCutOffCells[bcId]->a[
id] = nghbrId;
14600template <MInt nDim,
class SysEqn>
14602 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc1602 is untested for 2D!"); }
14620 b1 = m_shearLayerThickness;
14621 b2 = m_shearLayerThickness;
14623 MFloat jetInflowArea = F0;
14626 m_log <<
"computing mass flux " << endl;
14628 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
14629 ghost1 = m_sortedCutOffCells[bcId]->a[
id];
14630 if(m_solver->a_isHalo(ghost1))
continue;
14632 MFloat jetArea =
POW2(m_solver->c_cellLengthAtCell(ghost1));
14633 factor1 = m_solver->a_coordinate(ghost1, 0);
14634 factor2 = m_solver->a_coordinate(ghost1, 2);
14636 velocity = m_solver->m_Ma
14637 * (F1B2 * (1 + tanh(b1 * (factor1 + m_solver->m_jetHalfWidth)))
14638 * (1 - tanh(b1 * (factor1 - m_solver->m_jetHalfWidth)))
14640 * (F1B2 * (1 + tanh(b2 * (factor2 + m_solver->m_jetHalfLength)))
14641 * (1 - tanh(b2 * (factor2 - m_solver->m_jetHalfLength)))
14643 massflux += m_solver->a_variable(ghost1, PV->RHO) * velocity * jetArea;
14644 jetInflowArea += jetArea;
14646 MPI_Allreduce(MPI_IN_PLACE, &massflux, 1, MPI_DOUBLE, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
"massflux");
14647 MPI_Allreduce(MPI_IN_PLACE, &jetInflowArea, 1, MPI_DOUBLE, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
14653 massflux /= jetInflowArea;
14654 m_solver->m_jetPressure = m_solver->m_PInfinity;
14655 m_solver->m_jetDensity = m_solver->m_rhoInfinity;
14656 m_solver->m_jetTemperature = sysEqn().temperature_ES(m_solver->m_jetDensity, m_solver->m_jetPressure);
14657 m_log <<
"calculated pressure" << m_solver->m_jetPressure << endl;
14658 m_log <<
"calculated density" << m_solver->m_jetDensity << endl;
14659 m_log <<
"calculated temperature at inflow " << m_solver->m_jetTemperature << endl;
14660 m_log <<
"calculated massflux" << massflux << endl;
14664 if(m_sortedCutOffCells[bcId]->size() == 0) {
14668 dummyTime = m_solver->m_time / m_bc1601->m_tau_b;
14670 m_bc1601->checkRegeneration(dummyTime);
14672 that = 2.0 * PI * dummyTime;
14673 twopioverlb = 2.0 * PI / m_bc1601->m_l_b;
14675 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
14676 ghost1 = m_sortedCutOffCells[bcId]->a[
id];
14677 in1 = m_solver->c_neighborId(ghost1, d);
14679 factor1 = m_solver->a_coordinate(ghost1, 0);
14680 factor2 = m_solver->a_coordinate(ghost1, 2);
14682 xhat = twopioverlb * m_solver->a_coordinate(ghost1, 0);
14683 yhat = twopioverlb * m_solver->a_coordinate(ghost1, 1);
14684 zhat = twopioverlb * m_solver->a_coordinate(ghost1, 2);
14688 m_bc1601->calculateFlucts(that, xhat, yhat, zhat, fluctChol);
14723 fluctChol[0] *= (F1B2 * (1 + tanh(b1 * (factor1 + m_solver->m_jetHalfWidth)))
14724 * (1 - tanh(b1 * (factor1 - m_solver->m_jetHalfWidth)))
14726 fluctChol[0] *= (F1B2 * (1 + tanh(b2 * (factor2 + m_solver->m_jetHalfLength)))
14727 * (1 - tanh(b2 * (factor2 - m_solver->m_jetHalfLength)))
14730 fluctChol[2] *= (F1B2 * (1 + tanh(b1 * (factor1 + m_solver->m_jetHalfWidth)))
14731 * (1 - tanh(b1 * (factor1 - m_solver->m_jetHalfWidth)))
14733 fluctChol[2] *= (F1B2 * (1 + tanh(b2 * (factor2 + m_solver->m_jetHalfLength)))
14734 * (1 - tanh(b2 * (factor2 - m_solver->m_jetHalfLength)))
14737 m_solver->a_pvariable(ghost1, PV->U) = F2 * fluctChol[0] - m_solver->a_pvariable(in1, PV->U);
14738 velocity = m_solver->m_Ma;
14740 m_solver->a_pvariable(ghost1, PV->V) = F2 * (velocity + fluctChol[1])
14741 * (F1B2 * (1 + tanh(b1 * (factor1 + m_solver->m_jetHalfWidth)))
14742 * (1 - tanh(b1 * (factor1 - m_solver->m_jetHalfWidth)))
14744 * (F1B2 * (1 + tanh(b2 * (factor2 + m_solver->m_jetHalfLength)))
14745 * (1 - tanh(b2 * (factor2 - m_solver->m_jetHalfLength)))
14747 - m_solver->a_pvariable(in1, PV->V);
14749 m_solver->a_pvariable(ghost1, PV->W) = F2 * fluctChol[2] - m_solver->a_pvariable(in1, PV->W);
14753 m_solver->a_pvariable(ghost1, PV->P) = m_solver->a_pvariable(in1, PV->P);
14756 m_solver->a_pvariable(ghost1, PV->RHO) = F2 * m_solver->m_jetDensity - m_solver->a_pvariable(in1, PV->RHO);
14760 m_solver->a_pvariable(ghost1, PV->C) = F0;
14776template <MInt nDim,
class SysEqn>
14778 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc1603 is untested for 2D!"); }
14781 if(m_sortedCutOffCells[bcId]->size() == 0) {
14790 if(m_jetInletTurbulence) {
14791 const MFloat dummyTime = m_solver->m_time / m_bc1601->m_tau_b;
14792 m_bc1601->checkRegeneration(dummyTime);
14793 that = 2.0 * PI * dummyTime;
14794 twopioverlb = 2.0 * PI / m_bc1601->m_l_b;
14796 MFloat fluctChol[3] = {0., 0., 0.};
14798 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
14799 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
14800 const MInt nghbrId = m_solver->c_neighborId(cellId, 1);
14801 const MFloat radius = sqrt(
POW2(m_solver->a_coordinate(cellId, 1)) +
POW2(m_solver->a_coordinate(cellId, 2)));
14804 if(radius <= F1B2) {
14805 if(m_jetInletTurbulence) {
14806 xhat = twopioverlb * m_solver->a_coordinate(cellId, 0);
14807 yhat = twopioverlb * m_solver->a_coordinate(cellId, 1);
14808 zhat = twopioverlb * m_solver->a_coordinate(cellId, 2);
14809 m_bc1601->calculateFlucts(that, xhat, yhat, zhat, fluctChol);
14813 m_solver->a_pvariable(cellId, PV->VV[0]) = F1B2 * m_Ma * (1 + tanh((radius) / (0.05))) + fluctChol[0];
14814 m_solver->a_pvariable(cellId, PV->VV[1]) = m_solver->m_VInfinity + fluctChol[1];
14815 m_solver->a_pvariable(cellId, PV->VV[2]) = m_solver->m_WInfinity + fluctChol[2];
14818 profil = F1B2 * (1 + tanh((radius) / (0.05)));
14828 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity * (1 / sysEqn().CroccoBusemann(m_Ma, profil));
14830 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
14832 m_solver->a_pvariable(cellId, PV->VV[0]) = F0;
14833 m_solver->a_pvariable(cellId, PV->VV[1]) = F0;
14834 m_solver->a_pvariable(cellId, PV->VV[2]) = F0;
14837 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
14839 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
14851template <MInt nDim,
class SysEqn>
14854 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc1604 is untested for 2D!"); }
14856 if(m_sortedCutOffCells[bcId]->size() == 0) {
14865 if(m_jetInletTurbulence) {
14866 const MFloat dummyTime = m_solver->m_time / m_bc1601->m_tau_b;
14867 m_bc1601->checkRegeneration(dummyTime);
14868 that = 2.0 * PI * dummyTime;
14869 twopioverlb = 2.0 * PI / m_bc1601->m_l_b;
14871 MFloat fluctChol[3] = {0.0, 0.0, 0.0};
14873 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
14874 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
14875 const MInt nghbrId = m_solver->c_neighborId(cellId, 1);
14877 cutOffBcMissingNeighbor(cellId,
"bc1604");
14881 const MFloat radius = sqrt(
POW2(m_solver->a_coordinate(cellId, 1)) +
POW2(m_solver->a_coordinate(cellId, 2)));
14884 <= 1.5 * m_jetHeight) {
14885 if(m_jetInletTurbulence) {
14886 xhat = twopioverlb * m_solver->a_coordinate(cellId, 0);
14887 yhat = twopioverlb * m_solver->a_coordinate(cellId, 1);
14888 zhat = twopioverlb * m_solver->a_coordinate(cellId, 2);
14889 m_bc1601->calculateFlucts(that, xhat, yhat, zhat, fluctChol);
14892 const MFloat jet = 0.5 * (1.0 + tanh((m_jetHeight - radius) / (2 * m_momentumThickness)));
14895 m_solver->a_pvariable(cellId, PV->VV[0]) = jet * m_solver->m_VVInfinity[0] + fluctChol[0];
14896 m_solver->a_pvariable(cellId, PV->VV[1]) = m_solver->m_VVInfinity[1] + fluctChol[1];
14897 m_solver->a_pvariable(cellId, PV->VV[2]) = m_solver->m_VVInfinity[2] + fluctChol[2];
14900 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity / sysEqn().CroccoBusemann(m_Ma, jet);
14902 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
14904 m_solver->a_pvariable(cellId, PV->VV[0]) = F0;
14905 m_solver->a_pvariable(cellId, PV->VV[1]) = F0;
14906 m_solver->a_pvariable(cellId, PV->VV[2]) = F0;
14907 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
14909 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
14924template <MInt nDim,
class SysEqn>
14927 IF_CONSTEXPR(nDim == 2) { TERMM(1,
"bc1606 not useful in 2D"); }
14929 if(m_sortedCutOffCells[bcId]->size() == 0) {
14935 const MFloat dummyTime = m_solver->m_time / m_bc1601->m_tau_b;
14936 m_bc1601->checkRegeneration(dummyTime);
14938 const MFloat that = 2.0 * PI * dummyTime;
14939 const MFloat twopioverlb = 2.0 * PI / m_bc1601->m_l_b;
14940 const MFloat jetTurbulence = (m_jetInletTurbulence) ? 1.0 : 0.0;
14941 const MFloat inletRadius = m_solver->m_inletRadius;
14942 const MFloat deltaMomentum = m_momentumThickness * inletRadius;
14944 const MFloat densityAmbient = m_solver->m_rhoInfinity;
14945 const MFloat density_i = m_solver->m_nozzleInletRho;
14948 const MFloat u_i = m_solver->m_nozzleInletU;
14949 const MFloat Ma_i = m_solver->m_maNozzleInlet;
14951 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
14952 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
14953 const MInt nghbrId = m_solver->c_neighborId(cellId, 1);
14955 cutOffBcMissingNeighbor(cellId,
"bc1606");
14960 sqrt(
POW2(m_solver->a_coordinate(cellId, 1) - 0.0) +
POW2(m_solver->a_coordinate(cellId, 2) - 0.0));
14962 if(radius <= inletRadius) {
14963 const MFloat xhat = twopioverlb * m_solver->a_coordinate(cellId, 0);
14964 const MFloat yhat = twopioverlb * m_solver->a_coordinate(cellId, 1);
14965 const MFloat zhat = twopioverlb * m_solver->a_coordinate(cellId, 2);
14967 m_bc1601->calculateFlucts(that, xhat, yhat, zhat, fluctChol);
14970 const MFloat jet = tanh((inletRadius - radius) / (2.0 * deltaMomentum));
14976 m_solver->a_pvariable(cellId, PV->RHO) = density_i / sysEqn().CroccoBusemann(Ma_i, jet);
14978 m_solver->a_pvariable(cellId, PV->VV[0]) = u_i * jet + fluctChol[0] * jetTurbulence;
14979 m_solver->a_pvariable(cellId, PV->VV[1]) = fluctChol[1] * jetTurbulence;
14980 m_solver->a_pvariable(cellId, PV->VV[2]) = fluctChol[2] * jetTurbulence;
14983 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
14985 m_solver->a_pvariable(cellId, PV->VV[0]) = 0.0;
14986 m_solver->a_pvariable(cellId, PV->VV[1]) = 0.0;
14987 m_solver->a_pvariable(cellId, PV->VV[2]) = 0.0;
14989 m_solver->a_pvariable(cellId, PV->RHO) = densityAmbient;
14992 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
15004template <MInt nDim,
class SysEqn>
15006 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc1792 is untested for 2D!"); }
15017 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
15018 cellId = m_sortedCutOffCells[bcId]->a[
id];
15021 nghbrId = m_solver->c_neighborId(cellId, d);
15023 radius_1 = sqrt((m_solver->a_coordinate(cellId, 1) - 200.0) * (m_solver->a_coordinate(cellId, 1) - 200.0)
15024 + (m_solver->a_coordinate(cellId, 2) - 200.0) * (m_solver->a_coordinate(cellId, 2) - 200.0));
15025 if((m_solver->a_coordinate(cellId, 1) - 200.0) >= 0 && (m_solver->a_coordinate(cellId, 2) - 200.0) >= 0) {
15026 phi_1 = asin((m_solver->a_coordinate(cellId, 1) - 200.0) / radius_1);
15027 }
else if((m_solver->a_coordinate(cellId, 1) - 200.0) >= 0 && (m_solver->a_coordinate(cellId, 2) - 200.0) < 0) {
15028 phi_1 = PI - asin((m_solver->a_coordinate(cellId, 1) - 200.0) / radius_1);
15029 }
else if((m_solver->a_coordinate(cellId, 1) - 200.0) < 0 && (m_solver->a_coordinate(cellId, 2) - 200.0) < 0) {
15030 phi_1 = PI - asin((m_solver->a_coordinate(cellId, 1) - 200.0) / radius_1);
15032 phi_1 = 2 * PI + asin((m_solver->a_coordinate(cellId, 1) - 200.0) / radius_1);
15036 m_solver->a_pvariable(cellId, PV->U) = m_solver->m_UInfinity;
15037 m_solver->a_pvariable(cellId, PV->V) = m_solver->m_VInfinity * cos(phi_1) / 29.0 * radius_1;
15038 m_solver->a_pvariable(cellId, PV->W) = -m_solver->m_VInfinity * sin(phi_1) / 29.0 * radius_1;
15040 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
15041 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
15052template <MInt nDim,
class SysEqn>
15054 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc1952 is untested for 2D!"); }
15062 switch(m_cutOffBndryCndIds[bcId]) {
15070 stringstream errorMessage;
15071 errorMessage <<
"ERROR: Switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
15072 <<
" not matching any case." << endl;
15073 mTerm(1, AT_, errorMessage.str());
15077 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
15078 cellId = m_sortedCutOffCells[bcId]->a[
id];
15079 nghbrId = m_solver->c_neighborId(cellId, d);
15082 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
15085 for(
MInt i = 0; i < nDim; i++) {
15086 m_solver->a_pvariable(cellId, PV->VV[i]) = m_solver->a_pvariable(nghbrId, PV->VV[i]);
15090 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_PInfinity;
15093 for(
MInt s = 0; s < m_noSpecies; s++) {
15094 m_solver->a_pvariable(cellId, PV->Y[s]) = m_solver->a_pvariable(nghbrId, PV->Y[s]);
15107template <MInt nDim,
class SysEqn>
15112#pragma omp parallel for
15115 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
15116 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
15118 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
15120 for(
MInt dim = 0; dim < m_solver->nDim; dim++) {
15121 m_solver->a_pvariable(cellId, PV->VV[dim]) = m_solver->m_VVInfinity[dim];
15124 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_PInfinity;
15128 if(m_besselModes) {
15130 if(!m_solver->m_RKStep) {
15131 precomputeBesselTrigonometry(bcId);
15134 addBesselModes(bcId);
15147template <MInt nDim,
class SysEqn>
15162 m_besselModes = Context::getSolverProperty<MInt>(
"besselModes", m_solverId, AT_, &m_besselModes);
15164 if(m_besselModes) {
15165 initBesselModes(bcId);
15187template <MInt nDim,
class SysEqn>
15190 m_log << endl <<
"bcInit2770 for bcId " << bcId << endl;
15205 m_noShockBcCells = 21;
15206 m_noShockBcCells = Context::getSolverProperty<MInt>(
"noShockBcCells", m_solverId, AT_, &m_noShockBcCells);
15219 m_shockFromInnerSolution =
false;
15220 m_shockFromInnerSolution =
15221 Context::getSolverProperty<MBool>(
"shockFromInnerSolution", m_solverId, AT_, &m_shockFromInnerSolution);
15235 m_sigmaShock = Context::getSolverProperty<MFloat>(
"sigmaShock", m_solverId, AT_, &m_sigmaShock);
15236 m_sigmaShock *= PI / 180.0;
15250 m_ys = Context::getSolverProperty<MFloat>(
"ys", m_solverId, AT_);
15266 srf = Context::getSolverProperty<MFloat>(
"srf", m_solverId, AT_, &srf);
15269 tmpTargetCells.fill(-1);
15271 MFloatScratchSpace tmpSrcVars(m_noShockBcCells, PV->noVariables, AT_,
"tmpSrcVars");
15272 tmpSrcVars.fill(-std::numeric_limits<MFloat>::max());
15276 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
15278 const MFloat cellLength = m_solver->c_cellLengthAtCell(cellId);
15280 if(m_solver->a_isHalo(cellId)) {
15283 if(m_solver->a_coordinate(cellId, 1) + cellLength / F2 >= m_ys + m_noShockBcCells / 2 * cellLength
15284 && m_solver->a_coordinate(cellId, 1) - cellLength / F2 < m_ys + m_noShockBcCells / 2 * cellLength) {
15286 tmpTargetCells[0] =
cellId;
15287 for(
MInt dim = 0; dim < nDim; dim++) {
15288 tmpTargetCoords[dim] = m_solver->a_coordinate(cellId, dim);
15295 MPI_Allreduce(MPI_IN_PLACE, &dom, 1, MPI_INT, MPI_MAX, mpiComm(), AT_,
"MPI_IN_PLACE",
"dom");
15296 MPI_Bcast(tmpTargetCoords.begin(), nDim, MPI_DOUBLE, dom, mpiComm(), AT_,
"tmpTargetCoords.begin()");
15299 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
15301 const MFloat cellLength = m_solver->c_cellLengthAtCell(cellId);
15303 if(m_solver->a_isHalo(cellId)) {
15307 MFloat y_coord = tmpTargetCoords[1];
15308 for(
MInt i = 1; i < m_noShockBcCells; i++) {
15309 y_coord -= cellLength;
15310 if(m_solver->a_coordinate(cellId, 1) + cellLength / F2 >= y_coord
15311 && m_solver->a_coordinate(cellId, 1) - cellLength / F2 < y_coord) {
15312 tmpTargetCells[i] =
cellId;
15318 if(m_solver->m_restart) {
15319 if(m_shockFromInnerSolution) {
15320 m_log <<
"using shock solution from inside of the domain" << endl;
15323 tmpSrcCoords[0] = tmpTargetCoords[0]
15325 tmpSrcCoords[1] = tmpTargetCoords[1] + (tan(m_solver->m_angle[0] + m_sigmaShock) * 0.8);
15326 for(
MInt id = 0;
id < m_solver->noInternalCells();
id++) {
15327 const MFloat cellLength = m_solver->c_cellLengthAtCell(
id);
15328 if(m_solver->c_noChildren(
id) > 0) {
15331 MFloat y_src_coord = tmpSrcCoords[1];
15332 for(
MInt i = 0; i < m_noShockBcCells; i++) {
15333 if(m_solver->a_coordinate(
id, 0) + cellLength / F2 >= tmpSrcCoords[0]
15334 && m_solver->a_coordinate(
id, 0) - cellLength / F2 < tmpSrcCoords[0]
15335 && m_solver->a_coordinate(
id, 1) + cellLength / F2 >= y_src_coord
15336 && m_solver->a_coordinate(
id, 1) - cellLength / F2 < y_src_coord) {
15338 tmpSrcVars(i, PV->RHO) = m_solver->a_pvariable(
id, PV->RHO);
15340 for(
MInt dim = 0; dim < m_solver->nDim; dim++) {
15341 tmpSrcVars(i, PV->VV[dim]) = m_solver->a_pvariable(
id, PV->VV[dim]);
15344 tmpSrcVars(i, PV->P) = m_solver->a_pvariable(
id, PV->P);
15346 MFloat y_src = y_src_coord - cellLength;
15347 y_src_coord = y_src;
15351 MPI_Allreduce(MPI_IN_PLACE, tmpSrcVars.begin(), m_noShockBcCells * PV->noVariables, MPI_DOUBLE, MPI_MAX,
15352 mpiComm(), AT_,
"MPI_IN_PLACE",
"tmpSrcVars.begin()");
15355 m_log <<
"using shock solution from the inlet boundary of the domain" << endl;
15357 for(
MInt i = 0; i < m_noShockBcCells; i++) {
15361 tmpSrcVars(i, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
15363 for(
MInt dim = 0; dim < m_solver->nDim; dim++) {
15364 tmpSrcVars(i, PV->VV[dim]) = m_solver->a_pvariable(cellId, PV->VV[dim]);
15367 tmpSrcVars(i, PV->P) = m_solver->a_pvariable(cellId, PV->P);
15372 m_log <<
"using analytic shock solution" << endl;
15375 const MFloat gamma = sysEqn().gamma_Ref();
15376 const MFloat gammaPlusOne = gamma + F1;
15377 const MFloat gammaMinusOne = gamma - F1;
15378 const MFloat Ma = m_solver->m_Ma;
15379 const MFloat Ma_ns =
POW2(Ma * sin(m_sigmaShock));
15380 const MFloat fact_pressure = F1 + (F2 * gamma / gammaPlusOne) * (Ma_ns - F1);
15381 const MFloat fact_density = (gammaPlusOne * Ma_ns) / (gammaMinusOne * Ma_ns + F2);
15383 const MFloat angle = PI / F2 - m_sigmaShock;
15384 const MFloat un1 = m_solver->m_VVInfinity[0] *
cos(angle) - m_solver->m_VVInfinity[1] * sin(angle);
15385 const MFloat ut1 = m_solver->m_VVInfinity[0] * sin(angle) + m_solver->m_VVInfinity[1] *
cos(angle);
15387 const MFloat un2 = un1 / fact_density;
15390 const MFloat ux2 = un2 *
cos(angle) + ut2 * sin(angle);
15391 const MFloat uy2 = -un2 * sin(angle) + ut2 *
cos(angle);
15394 sysEqn().speedOfSound(m_solver->m_rhoInfinity * fact_density, m_solver->m_PInfinity * fact_pressure);
15395 m_log <<
"Ma_2x = " << ux2 / a2 <<
", Ma_2y = " << uy2 / a2 << endl;
15399 for(
MInt i = 0; i < m_noShockBcCells; i++) {
15403 MFloat fb =
mMax(
mMin(((
MFloat)i / (m_noShockBcCells - 1) - F1B2) * srf, F1B2), -F1B2) + F1B2;
15404 m_log <<
"fb ( " << i <<
") = " << fb << endl;
15407 tmpSrcVars(i, PV->RHO) = m_solver->m_rhoInfinity * ((F1 - fb) + fb * fact_density);
15409 tmpSrcVars(i, PV->VV[0]) = (F1 - fb) * m_solver->m_VVInfinity[0] + fb * ux2;
15410 tmpSrcVars(i, PV->VV[1]) = (F1 - fb) * m_solver->m_VVInfinity[1] + fb * uy2;
15412 tmpSrcVars(i, PV->P) = m_solver->m_PInfinity * ((F1 - fb) + fb * fact_pressure);
15417 MInt noShockBcCellsInDomain = 0;
15418 for(
MInt i = 0; i < m_noShockBcCells; i++) {
15419 if(tmpTargetCells[i] != -1) {
15420 noShockBcCellsInDomain++;
15425 mAlloc(m_Bc2770TargetCells, noShockBcCellsInDomain,
"Bc2770TargetCells", AT_);
15426 mAlloc(m_shockBcVars, noShockBcCellsInDomain, PV->noVariables,
"m_shockBcVars", AT_);
15430 for(
MInt i = 0; i < m_noShockBcCells; i++) {
15431 if(tmpTargetCells[i] != -1) {
15432 m_Bc2770TargetCells[k] = tmpTargetCells[i];
15433 for(
MInt var = 0; var < PV->noVariables; var++) {
15434 m_shockBcVars[k][var] = tmpSrcVars(i, var);
15439 m_noShockBcCells = noShockBcCellsInDomain;
15443 m_log <<
"initialization of bc2770 done" << endl;
15454template <MInt nDim,
class SysEqn>
15458 MInt direction = m_cutOffBndryCndIds[bcId] - 2710;
15460 if(direction % 2) {
15466 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
15467 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
15468 if(m_solver->a_hasProperty(cellId, SolverCell::IsPeriodicWithRot)) {
15471 MLong nghbrId = m_solver->c_neighborId(cellId, direction);
15476 if(m_solver->c_noChildren(nghbrId) > 0) {
15477 MFloat coCoord = m_solver->a_coordinate(cellId, direction / 2);
15480 for(
MInt i = 0; i < PV->noVariables; i++) {
15481 m_solver->a_pvariable(cellId, i) = F0;
15484 for(
MInt child = 0; child <
IPOW2(nDim); child++) {
15485 MLong childId = m_solver->c_childId(nghbrId, child);
15489 if(abs(m_solver->a_coordinate(childId, direction / 2) - coCoord) > m_solver->c_cellLengthAtCell(cellId)) {
15493 for(
MInt i = 0; i < PV->noVariables; i++) {
15494 m_solver->a_pvariable(cellId, i) += m_solver->a_pvariable(childId, i);
15498 for(
MInt i = 0; i < PV->noVariables; i++) {
15499 m_solver->a_pvariable(cellId, i) /= (
MFloat)childCnt;
15502 for(
MInt i = 0; i < PV->noVariables; i++) {
15503 m_solver->a_pvariable(cellId, i) = m_solver->a_pvariable(nghbrId, i);
15517template <MInt nDim,
class SysEqn>
15521 MInt direction = m_cutOffBndryCndIds[bcId] - 2720;
15523 if(direction % 2) {
15529 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
15530 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
15531 if(m_solver->a_hasProperty(cellId, SolverCell::IsPeriodicWithRot)) {
15534 MLong nghbrId = m_solver->c_neighborId(cellId, direction);
15539 if(m_solver->c_noChildren(nghbrId) > 0) {
15540 MFloat coCoord = m_solver->a_coordinate(cellId, direction / 2);
15543 for(
MInt i = 0; i < PV->noVariables; i++) {
15544 m_solver->a_pvariable(cellId, i) = F0;
15547 for(
MInt child = 0; child <
IPOW2(nDim); child++) {
15548 MLong childId = m_solver->c_childId(nghbrId, child);
15552 if(abs(m_solver->a_coordinate(childId, direction / 2) - coCoord) > m_solver->c_cellLengthAtCell(cellId)) {
15556 for(
MInt i = 0; i < PV->noVariables; i++) {
15557 m_solver->a_pvariable(cellId, i) += m_solver->a_pvariable(childId, i);
15561 for(
MInt i = 0; i < PV->noVariables; i++) {
15562 m_solver->a_pvariable(cellId, i) /= (
MFloat)childCnt;
15565 m_solver->a_pvariable(cellId, PV->P) = F2 * m_solver->m_postShockPV[PV->P] - m_solver->a_pvariable(cellId, PV->P);
15567 for(
MInt i = 0; i < PV->P; i++) {
15568 m_solver->a_pvariable(cellId, i) = m_solver->a_pvariable(nghbrId, i);
15571 m_solver->a_pvariable(cellId, PV->P) =
15572 F2 * m_solver->m_postShockPV[PV->P] - m_solver->a_pvariable(nghbrId, PV->P);
15574 for(
MInt i = PV->P + 1; i < PV->noVariables; i++) {
15575 m_solver->a_pvariable(cellId, i) = m_solver->a_pvariable(nghbrId, i);
15589template <MInt nDim,
class SysEqn>
15591 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc2907 is untested for 2D!"); }
15597 MFloat TInfinity = m_solver->m_TInfinity;
15598 if(m_combustion) TInfinity = m_solver->m_burntUnburntTemperatureRatio;
15602 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
15603 bndryId = m_sortedBndryCells->a[
id];
15604 cellId = m_bndryCells->a[bndryId].m_cellId;
15605 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
15606 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
15609 if(abs(m_solver->a_coordinate(cellId, 0)) >= m_solver->m_jetCoflowOffset
15611 abs(m_solver->a_coordinate(cellId, 0)) <= m_solver->m_jetCoflowEndOffset
15613 abs(m_solver->a_coordinate(cellId, 2)) <= m_solver->m_jetHalfLength) {
15615 m_solver->a_pvariable(ghostCellId, PV->V) = F2 * m_solver->m_MaCoflow - m_solver->a_pvariable(cellId, PV->V);
15616 m_solver->a_pvariable(ghostCellId, PV->U) = -m_solver->a_pvariable(cellId, PV->U);
15617 m_solver->a_pvariable(ghostCellId, PV->W) = -m_solver->a_pvariable(cellId, PV->W);
15620 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
15625 m_solver->a_pvariable(ghostCellId, PV->RHO) =
15626 sysEqn().density_ES(m_solver->a_pvariable(cellId, PV->P), TInfinity);
15629 for(
MInt s = 0; s < m_noSpecies; s++) {
15630 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
15634 m_solver->a_pvariable(ghostCellId, PV->V) = -m_solver->a_pvariable(cellId, PV->V);
15635 m_solver->a_pvariable(ghostCellId, PV->U) = -m_solver->a_pvariable(cellId, PV->U);
15636 m_solver->a_pvariable(ghostCellId, PV->W) = -m_solver->a_pvariable(cellId, PV->W);
15640 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
15642 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
15645 for(
MInt s = 0; s < m_noSpecies; s++) {
15646 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
15659template <MInt nDim,
class SysEqn>
15663 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
15664 MInt bndryId = m_sortedBndryCells->a[
id];
15665 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
15667 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
15668 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
15669 MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
15670 if(ghostCellId < 0 && ghostCellId >= m_solver->a_noCells()) {
15671 mTerm(1, AT_,
"Ghost cell: " + to_string(ghostCellId));
15673 MInt k = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bodyId[0];
15674 ASSERT(k > -1 && k < m_solver->m_noEmbeddedBodies + m_solver->m_noPeriodicGhostBodies,
"");
15675 if(k < 0 || k >= m_solver->m_noEmbeddedBodies + m_solver->m_noPeriodicGhostBodies) {
15676 mTerm(1, AT_,
"Invalid body id: " + to_string(k));
15680 MFloat vel[3] = {0.0, 0.0, 0.0};
15681 for(
MInt i = 0; i < nDim; i++) {
15682 vel[i] = m_solver->m_bodyVelocity[k * nDim + i];
15689 for(
MInt i = 0; i < nDim; i++) {
15690 dn += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]
15691 * (m_solver->a_coordinate(cellId, i) - m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i]);
15693 for(
MInt i = 0; i < nDim; i++) {
15694 dx[i] = m_solver->a_coordinate(cellId, i) - dn * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]
15695 - m_solver->m_bodyCenter[k * nDim + i];
15697 for(
MInt i = 0; i < 3; i++) {
15698 omega[i] = m_solver->m_bodyAngularVelocity[k * 3 + i];
15700 vrad[0] = omega[1] * dx[2] - omega[2] * dx[1];
15701 vrad[1] = omega[2] * dx[0] - omega[0] * dx[2];
15702 IF_CONSTEXPR(nDim == 3) vrad[2] = omega[0] * dx[1] - omega[1] * dx[0];
15704 for(
MInt i = 0; i < nDim; i++) {
15708 for(
MInt i = 0; i < nDim; i++) {
15709 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = F2 * vel[i] - m_solver->a_pvariable(cellId, PV->VV[i]);
15712 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
15713 for(
MInt r = 0; r < m_solver->m_noRansEquations; r++) {
15714 m_solver->a_pvariable(ghostCellId, PV->NN[r]) = -m_solver->a_pvariable(cellId, PV->NN[r]);
15719 for(
MInt s = 0; s < m_noSpecies; s++) {
15720 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
15727 if(m_solver->m_closeGaps && !m_solver->m_gapCells.empty()) {
15729 setGapGhostCellVariables(bcId);
15736template <MInt nDim,
class SysEqn>
15740 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
15741 const MInt bndryId = m_sortedBndryCells->a[
id];
15742 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
15744 if(!m_solver->a_isGapCell(cellId))
continue;
15746 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
15748 const MInt gapCellId = m_solver->m_gapCellId[cellId];
15749 ASSERT(gapCellId > -1,
"");
15750 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
15751 const MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
15752 for(
MInt i = 0; i < nDim; i++) {
15753 const MFloat vel = m_solver->m_gapCells[gapCellId].surfaceVelocity[i];
15754 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = F2 * vel - m_solver->a_pvariable(cellId, PV->VV[i]);
15767template <MInt nDim,
class SysEqn>
15770#pragma omp parallel for
15772 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
15773 const MInt bndryId = m_sortedBndryCells->a[
id];
15774 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
15776 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
15777 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
15778 MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
15780 MInt k = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bodyId[0];
15781 ASSERT(k > -1 && k < m_solver->m_noEmbeddedBodies + m_solver->m_noPeriodicGhostBodies,
"");
15782 if(k < 0 || k >= m_solver->m_noEmbeddedBodies + m_solver->m_noPeriodicGhostBodies) {
15783 mTerm(1, AT_,
"Invalid body id: " + to_string(k));
15788 for(
MInt i = 0; i < nDim; i++) {
15789 surfVel[i] = m_solver->m_bodyVelocity[k * nDim + i];
15791 MFloat dx[3] = {F0, F0, F0};
15792 MFloat omega[3] = {F0, F0, F0};
15793 MFloat vrad[3] = {F0, F0, F0};
15794 for(
MInt i = 0; i < nDim; i++) {
15795 dx[i] = m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i] - m_solver->m_bodyCenter[k * nDim + i];
15797 for(
MInt i = 0; i < 3; i++) {
15798 omega[i] = m_solver->m_bodyAngularVelocity[k * 3 + i];
15800 vrad[0] = omega[1] * dx[2] - omega[2] * dx[1];
15801 vrad[1] = omega[2] * dx[0] - omega[0] * dx[2];
15802 IF_CONSTEXPR(nDim == 3) vrad[2] = omega[0] * dx[1] - omega[1] * dx[0];
15804 for(
MInt i = 0; i < nDim; i++) {
15805 surfVel[i] += vrad[i];
15852 for(
MInt i = 0; i < nDim; i++) {
15853 vel[i] = m_solver->a_pvariable(cellId, PV->VV[i]);
15854 for(
MInt j = 0; j < nDim; j++) {
15855 vel[i] += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]
15856 * (surfVel[j] - m_solver->a_pvariable(cellId, PV->VV[j]))
15857 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[j];
15862 for(
MInt i = 0; i < nDim; i++) {
15863 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = F2 * vel[i] - m_solver->a_pvariable(cellId, PV->VV[i]);
15864 m_bndryCell[bndryId].m_srfcVariables[srfc]->m_primVars[PV->VV[i]] = vel[i];
15877template <MInt nDim,
class SysEqn>
15883 m_solver->m_geometry->getBoundingBox(bbox);
15884 const MFloat deltaY = bbox[1 + nDim] - bbox[1];
15886 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
15887 MInt bndryId = m_sortedBndryCells->a[
id];
15888 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
15889 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
15890 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
15891 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
15892 MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
15894 vel[0] = F2 * m_solver->m_UInfinity * m_bndryCell[bndryId].m_srfcs[0]->m_coordinates[1] / deltaY;
15895 for(
MInt i = 0; i < nDim; i++) {
15896 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = F2 * vel[i] - m_solver->a_pvariable(cellId, PV->VV[i]);
15899 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
15900 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
15914template <MInt nDim,
class SysEqn>
15918#pragma omp parallel for
15920 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
15921 MInt bndryId = m_sortedBndryCells->a[
id];
15922 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
15923 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
15924 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
15925 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
15926 MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
15927 for(
MInt i = 0; i < nDim; i++) {
15928 m_solver->a_pvariable(ghostCellId, PV->VV[i]) = -m_solver->a_pvariable(cellId, PV->VV[i]);
15940template <MInt nDim,
class SysEqn>
15945#pragma omp parallel for
15947 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
15948 MInt bndryId = m_sortedBndryCells->a[
id];
15949 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
15950 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
15951 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
15952 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
15953 MInt ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
15954 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
15955 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
15956 for(
MInt s = 0; s < m_noSpecies; s++) {
15957 m_solver->a_pvariable(ghostCellId, PV->Y[s]) = m_solver->a_pvariable(cellId, PV->Y[s]);
15971template <MInt nDim,
class SysEqn>
15975 if(m_sortedCutOffCells[bcId]->size() == 0)
return;
15977 const MInt otherDir[4] = {1, 0, 3, 2};
15979 if(m_firstUseBc10970) {
15982 if(noCutOffDirections != noCutOffBndryIds)
15984 "Wrong number of cut off directions. Must be identical to number of cut off bndryIds! Please check!");
15985 MInt cutOffBndryIdTmp, cutOffDirectionTmp;
15986 for(
MInt i = 0; i < noCutOffBndryIds; i++) {
15987 cutOffBndryIdTmp = Context::getSolverProperty<MInt>(
"cutOffBndryIds", m_solverId, AT_, i);
15988 cutOffDirectionTmp = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, i);
15989 if(cutOffBndryIdTmp == m_cutOffBndryCndIds[bcId]) {
15990 m_dirNBc10970 = otherDir[cutOffDirectionTmp];
15995 m_pModeBc10970 = 0;
15996 m_pModeBc10970 = Context::getSolverProperty<MInt>(
"BC10970Mode", m_solverId, AT_, &m_pModeBc10970);
15997 m_firstUseBc10970 =
false;
16001 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16002 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16003 MInt nghbrId = m_solver->c_neighborId(cellId, m_dirNBc10970);
16006 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
16009 for(
MInt i = 0; i < nDim; i++)
16010 m_solver->a_pvariable(cellId, PV->VV[i]) = m_solver->a_pvariable(nghbrId, PV->VV[i]);
16012 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
16013 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
16014 m_solver->a_pvariable(cellId, PV->NN[r]) = m_solver->a_pvariable(nghbrId, PV->NN[r]);
16019 if(m_pModeBc10970 == 0) {
16020 m_solver->a_pvariable(cellId, PV->P) = F2 * (m_solver->m_PInfinity) - m_solver->a_pvariable(nghbrId, PV->P);
16021 }
else if(m_pModeBc10970 == 1) {
16022 m_solver->a_pvariable(cellId, PV->P) = 0.9 * m_solver->m_PInfinity;
16024 mTerm(1, AT_,
"Unknown pressure mode in BC10970");
16035template <MInt nDim,
class SysEqn>
16037 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function bc10980 is untested for 3D!"); }
16041 if(m_sortedCutOffCells[bcId]->size() == 0)
return;
16043 const MInt otherDir[4] = {1, 0, 3, 2};
16045 if(m_firstUseBc10980) {
16048 if(noCutOffDirections != noCutOffBndryIds)
16050 "Wrong number of cut off directions. Must be identical to number of cut off bndryIds! Please check!");
16051 MInt cutOffBndryIdTmp, cutOffDirectionTmp;
16052 for(
MInt i = 0; i < noCutOffBndryIds; i++) {
16053 cutOffBndryIdTmp = Context::getSolverProperty<MInt>(
"cutOffBndryIds", m_solverId, AT_, i);
16054 cutOffDirectionTmp = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, i);
16055 if(cutOffBndryIdTmp == m_cutOffBndryCndIds[bcId]) {
16056 m_dirNBc10980 = otherDir[cutOffDirectionTmp];
16061 m_firstUseBc10980 =
false;
16065 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16066 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16067 MInt nghbrId = m_solver->c_neighborId(cellId, m_dirNBc10980);
16070 m_solver->a_pvariable(cellId, PV->RHO) = F2 * m_solver->m_rhoInfinity - m_solver->a_pvariable(nghbrId, PV->RHO);
16073 for(
MInt i = 0; i < nDim; i++)
16074 m_solver->a_pvariable(cellId, PV->VV[i]) =
16075 F2 * m_solver->m_VVInfinity[i] - m_solver->a_pvariable(nghbrId, PV->VV[i]);
16077 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
16078 IF_CONSTEXPR(SysEqn::m_ransModel ==
RANS_SA_DV || SysEqn::m_ransModel ==
RANS_FS) {
16079 m_solver->a_pvariable(cellId, PV->N) = F2 * m_solver->m_nuTildeInfinity - m_solver->a_pvariable(nghbrId, PV->N);
16082 m_solver->a_pvariable(cellId, PV->K) = F2 * m_solver->m_kInfinity - m_solver->a_pvariable(nghbrId, PV->K);
16083 m_solver->a_pvariable(cellId, PV->OMEGA) =
16084 F2 * m_solver->m_omegaInfinity - m_solver->a_pvariable(nghbrId, PV->OMEGA);
16089 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
16099template <MInt nDim,
class SysEqn>
16103 if(m_sortedCutOffCells[bcId]->size() == 0)
return;
16105 if(m_firstUseBc11110) {
16124 constexpr const MInt noVars = nDim + 2;
16126 mAlloc(m_targetValuesBC11110, m_sortedCutOffCells[bcId]->size(), noVars,
"m_targetValuesBC11110", AT_);
16127 mAlloc(m_dirNBc11110, m_sortedCutOffCells[bcId]->size(),
"m_dirNBc11110", AT_);
16129 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size(); ++
id) {
16130 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16131 MBool found =
false;
16132 for(
MInt dir = 0; dir < 2 * nDim; ++dir) {
16133 if(m_solver->a_hasNeighbor(cellId, dir) == 0) {
16134 m_dirNBc11110[
id] = dir;
16139 if(!found)
mTerm(1, AT_,
"");
16143 IF_CONSTEXPR(nDim == 2) {
16155 zCoord = Context::getSolverProperty<MFloat>(
"zCoordFor2DInterpolation", m_solverId, AT_, &zCoord);
16159 std::vector<std::vector<MFloat>> coords(3);
16160 for(
MInt d = 0; d < 3; ++d)
16161 coords[d].resize(m_sortedCutOffCells[bcId]->size());
16163 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size(); ++
id) {
16165 for(
MInt d = 0; d < nDim; ++d) {
16166 coords[d][
id] = m_solver->a_coordinate(cellId, d);
16169 IF_CONSTEXPR(nDim == 2) {
16170 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size(); ++
id) {
16172 coords[2][
id] = zCoord;
16178 std::vector<MFloat*> coords_ptr(nDim);
16179 for(
auto& c_ptr : coords)
16180 coords_ptr[c_++] = c_ptr.data();
16184 MInt temp[] = {m_sortedCutOffCells[bcId]->size(), 1, 1};
16189 std::array<
MString, noVars> pvariableNames;
16190 pvariableNames[PV->U] =
"u";
16191 pvariableNames[PV->V] =
"v";
16192 IF_CONSTEXPR(nDim == 3) pvariableNames[PV->W] = "w";
16193 pvariableNames[PV->P] = "p";
16194 pvariableNames[PV->RHO] = "rho";
16196 std::vector<
MFloat> vars(m_sortedCutOffCells[bcId]->size());
16197 for(
MInt var = 0; var < noVars ; var++) {
16199 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size(); ++
id) {
16201 m_targetValuesBC11110[
id][var] = vars[
id];
16205 m_firstUseBc11110 =
false;
16208 const MInt otherDir[6] = {1, 0, 3, 2, 5, 4};
16210 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16211 const MInt dimN = (
MInt)m_dirNBc11110[
id] / 2;
16212 const MInt dir = (m_dirNBc11110[
id] % 2) * 2 - 1;
16215 const MInt nghbrId = m_solver->c_neighborId(cellId, otherDir[m_dirNBc11110[
id]]);
16218 const MBool isOutflow = (m_targetValuesBC11110[
id][PV->VV[dimN]] * dir > 0) ?
true :
false;
16222 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
16225 for(
MInt i = 0; i < nDim; i++)
16226 m_solver->a_pvariable(cellId, PV->VV[i]) = m_solver->a_pvariable(nghbrId, PV->VV[i]);
16229 m_solver->a_pvariable(cellId, PV->P) =
16230 F2 * m_targetValuesBC11110[
id][PV->P] - m_solver->a_pvariable(nghbrId, PV->P);
16233 m_solver->a_pvariable(cellId, PV->RHO) =
16234 F2 * m_targetValuesBC11110[
id][PV->RHO] - m_solver->a_pvariable(nghbrId, PV->RHO);
16237 for(
MInt i = 0; i < nDim; i++)
16238 m_solver->a_pvariable(cellId, PV->VV[i]) =
16239 F2 * m_targetValuesBC11110[
id][PV->VV[i]] - m_solver->a_pvariable(nghbrId, PV->VV[i]);
16242 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
16248template <MInt nDim,
class SysEqn>
16250 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc16010 is untested for 2D!"); }
16253 if(m_sortedCutOffCells[bcId]->size() == 0) {
16258 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16259 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16261 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
16262 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
16264 if(m_solver->checkNeighborActive(cellId, d)) {
16265 const MInt nghbrId = m_solver->c_neighborId(cellId, d);
16267 cutOffBcMissingNeighbor(cellId,
"bc16010");
16270 m_solver->a_pvariable(cellId, PV->U) = m_solver->a_pvariable(nghbrId, PV->U);
16271 m_solver->a_pvariable(cellId, PV->V) = m_solver->a_pvariable(nghbrId, PV->V);
16272 m_solver->a_pvariable(cellId, PV->W) = m_solver->a_pvariable(nghbrId, PV->W);
16274 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
16276 m_solver->a_pvariable(cellId, PV->P) = F2 * m_solver->m_PInfinity - m_solver->a_pvariable(nghbrId, PV->P);
16278 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
16279 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
16280 m_solver->a_pvariable(cellId, PV->NN[r]) = m_solver->a_pvariable(nghbrId, PV->NN[r]);
16285 m_solver->a_pvariable(cellId, PV->U) = m_solver->m_UInfinity;
16286 m_solver->a_pvariable(cellId, PV->V) = m_solver->m_VInfinity;
16287 m_solver->a_pvariable(cellId, PV->W) = m_solver->m_WInfinity;
16288 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
16289 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_PInfinity;
16293 for(
MInt s = 0; s < m_noSpecies; s++) {
16294 m_solver->a_pvariable(cellId, PV->Y[s]) = F0;
16304template <MInt nDim,
class SysEqn>
16306 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc16011 is untested for 2D!"); }
16309 if(m_sortedCutOffCells[bcId]->size() == 0) {
16315 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16316 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16319 m_solver->a_pvariable(cellId, PV->U) = m_solver->m_UInfinity;
16320 m_solver->a_pvariable(cellId, PV->V) = m_solver->m_VInfinity;
16321 m_solver->a_pvariable(cellId, PV->W) = m_solver->m_WInfinity;
16323 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
16325 if(m_solver->checkNeighborActive(cellId, d)) {
16326 const MInt nghbrId = m_solver->c_neighborId(cellId, d);
16328 cutOffBcMissingNeighbor(cellId,
"bc16011");
16330 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
16333 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_PInfinity;
16336 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
16337 IF_CONSTEXPR(SysEqn::m_ransModel ==
RANS_SA_DV || SysEqn::m_ransModel ==
RANS_FS) {
16338 m_solver->a_pvariable(cellId, PV->N) = m_solver->m_nuTildeInfinity;
16341 m_solver->a_pvariable(cellId, PV->K) = m_solver->m_kInfinity;
16342 m_solver->a_pvariable(cellId, PV->OMEGA) = m_solver->m_omegaInfinity;
16347 for(
MInt s = 0; s < m_noSpecies; s++)
16348 m_solver->a_pvariable(cellId, PV->Y[s]) = 1.0;
16357template <MInt nDim,
class SysEqn>
16359 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc16012 is untested for 2D!"); }
16363 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16364 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16365 const MInt nghbrId = m_solver->c_neighborId(cellId, d);
16367 cutOffBcMissingNeighbor(cellId,
"bc16012");
16370 m_solver->a_pvariable(cellId, PV->U) = m_solver->a_pvariable(nghbrId, PV->U);
16371 m_solver->a_pvariable(cellId, PV->V) = -m_solver->a_pvariable(nghbrId, PV->V);
16372 m_solver->a_pvariable(cellId, PV->W) = m_solver->a_pvariable(nghbrId, PV->W);
16374 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
16376 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
16378 for(
MInt s = 0; s < m_noSpecies; s++)
16379 m_solver->a_pvariable(cellId, PV->Y[s]) = m_solver->a_pvariable(nghbrId, PV->Y[s]);
16389template <MInt nDim,
class SysEqn>
16391 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc16013 is untested for 2D!"); }
16396 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16397 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16398 const MInt nghbrId = m_solver->c_neighborId(cellId, d);
16400 cutOffBcMissingNeighbor(cellId,
"bc16013");
16403 m_solver->a_pvariable(cellId, PV->U) = m_solver->a_pvariable(nghbrId, PV->U);
16404 m_solver->a_pvariable(cellId, PV->V) = -m_solver->a_pvariable(nghbrId, PV->V);
16405 m_solver->a_pvariable(cellId, PV->W) = m_solver->a_pvariable(nghbrId, PV->W);
16407 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
16409 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
16411 for(
MInt s = 0; s < m_noSpecies; s++)
16412 m_solver->a_pvariable(cellId, PV->Y[s]) = m_solver->a_pvariable(nghbrId, PV->Y[s]);
16422template <MInt nDim,
class SysEqn>
16424 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc16014 is untested for 2D!"); }
16429 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16430 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16431 const MInt nghbrId = m_solver->c_neighborId(cellId, d);
16433 cutOffBcMissingNeighbor(cellId,
"bc16014");
16436 m_solver->a_pvariable(cellId, PV->U) = m_solver->a_pvariable(nghbrId, PV->U);
16437 m_solver->a_pvariable(cellId, PV->V) = m_solver->a_pvariable(nghbrId, PV->V);
16438 m_solver->a_pvariable(cellId, PV->W) = -m_solver->a_pvariable(nghbrId, PV->W);
16440 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
16442 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
16444 for(
MInt s = 0; s < m_noSpecies; s++)
16445 m_solver->a_pvariable(cellId, PV->Y[s]) = m_solver->a_pvariable(nghbrId, PV->Y[s]);
16455template <MInt nDim,
class SysEqn>
16457 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function bc16015 is untested for 2D!"); }
16462 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16463 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16464 const MInt nghbrId = m_solver->c_neighborId(cellId, d);
16466 cutOffBcMissingNeighbor(cellId,
"bc16015");
16469 m_solver->a_pvariable(cellId, PV->U) = m_solver->a_pvariable(nghbrId, PV->U);
16470 m_solver->a_pvariable(cellId, PV->V) = m_solver->a_pvariable(nghbrId, PV->V);
16471 m_solver->a_pvariable(cellId, PV->W) = -m_solver->a_pvariable(nghbrId, PV->W);
16473 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
16475 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
16477 for(
MInt s = 0; s < m_noSpecies; s++)
16478 m_solver->a_pvariable(cellId, PV->Y[s]) = m_solver->a_pvariable(nghbrId, PV->Y[s]);
16485template <MInt nDim,
class SysEqn>
16486template <class _, std::enable_if_t<hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
16490 m_log << endl <<
"::bcInit7901: ..." << endl;
16492 const MFloat eps = 1e-08;
16494 m_7901faceNormalDir = 0;
16496 m_7901periodicDir = 2;
16498 m_7901faceNormalDir = Context::getSolverProperty<MInt>(
"bc7901faceNormalDir", m_solverId, AT_);
16501 m_7901wallDir = Context::getSolverProperty<MInt>(
"bc7901wallDir", m_solverId, AT_);
16504 m_7901periodicDir = Context::getSolverProperty<MInt>(
"bc7901periodicDir", m_solverId, AT_);
16507 m_7901StartTimeStep = m_solver->m_stgStartTimeStep;
16510 MInt noBc7901Cells = 0;
16511 MInt noBc7901Locations = 0;
16513 MBool first =
true;
16516 m_7901wallNormalLocations.clear();
16521 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16522 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16523 MFloat halfCellLength = m_solver->grid().halfCellLength(cellId);
16525 periodicL = m_solver->a_coordinate(cellId, m_7901periodicDir);
16530 if(abs(m_solver->a_coordinate(cellId, m_7901periodicDir) + halfCellLength - eps - periodicL) < halfCellLength) {
16532 m_7901wallNormalLocations.push_back(m_solver->a_coordinate(cellId, m_7901wallDir));
16533 noBc7901Locations++;
16539 if(noBc7901Cells == 0)
return;
16692 m_log <<
"::bcInit7901: ... FINISHED" << endl;
16695template <MInt nDim,
class SysEqn>
16696template <class _, std::enable_if_t<hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
16700 m_log << endl <<
"::bcInit7902: ..." << endl;
16702 const MFloat eps = 1e-08;
16704 m_7902faceNormalDir = 1;
16706 m_7902periodicDir = 2;
16708 m_7902faceNormalDir = Context::getSolverProperty<MInt>(
"bc7902faceNormalDir", m_solverId, AT_);
16711 m_7902wallDir = Context::getSolverProperty<MInt>(
"bc7902wallDir", m_solverId, AT_);
16714 m_7902periodicDir = Context::getSolverProperty<MInt>(
"bc7902periodicDir", m_solverId, AT_);
16717 m_7902StartTimeStep = m_solver->m_rntStartTimeStep;
16720 MInt noBc7902Cells = 0;
16721 MInt noBc7902Locations = 0;
16723 MBool first =
true;
16726 m_7902wallNormalLocations.clear();
16731 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16732 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16733 MFloat halfCellLength = m_solver->grid().halfCellLength(cellId);
16735 periodicL = m_solver->a_coordinate(cellId, m_7902periodicDir);
16740 if(abs(m_solver->a_coordinate(cellId, m_7902periodicDir) + halfCellLength - eps - periodicL) < halfCellLength) {
16742 m_7902wallNormalLocations.push_back(m_solver->a_coordinate(cellId, m_7902wallDir));
16743 noBc7902Locations++;
16749 if(noBc7902Cells == 0)
return;
16754 m_log <<
" + ... building reconstructNut communicator ..." << endl;
16756 const MPI_Comm& comm7902 = m_comm_bcCo[m_bcCo_comm_pointer[bcId]];
16758 MPI_Comm_size(comm7902, &comm_size);
16759 MInt* rntRanks =
new MInt[comm_size];
16760 MInt myRntRank = m_solver->domainId();
16764 if(comm_size > 0) {
16765 MPI_Allgather(&myRntRank, 1, MPI_INT, rntRanks, 1, MPI_INT, comm7902, AT_,
"myRntRank",
"rntRanks");
16768 MInt rntRoot = rntRanks[0];
16769 MInt myCommRank = 0;
16770 for(
MInt r = 0; r < comm_size; r++) {
16771 if(myRntRank == rntRanks[r]) {
16777 m_rntRoot = rntRanks[0];
16782 MInt globalNoBc7902Locations = 0;
16784 if(comm_size > 0) {
16785 MPI_Allreduce(&noBc7902Locations, &globalNoBc7902Locations, 1, MPI_INT, MPI_SUM, comm7902, AT_,
"noBc7902Locations",
16786 "globalNoBc7902Locations");
16788 globalNoBc7902Locations = noBc7902Locations;
16791 ScratchSpace<MFloat> globalBc7902Locations(globalNoBc7902Locations,
"globalBc7902Locations", FUN_);
16793 if(comm_size > 0) {
16797 MPI_Gather(&noBc7902Locations, 1, MPI_INT, &recvbuf[0], 1, MPI_INT, 0, comm7902, AT_,
"noBc7902Locations",
16802 if(myRntRank == rntRoot) {
16804 for(
MInt dom = 0; dom < comm_size; dom++) {
16805 displs[dom] = offset;
16806 offset += recvbuf[dom];
16810 MPI_Gatherv(&m_7902wallNormalLocations[0], noBc7902Locations, MPI_DOUBLE, &globalBc7902Locations[0],
16811 &recvbuf[myCommRank], &displs[myCommRank], MPI_DOUBLE, 0, comm7902, AT_,
"m_7902wallNormalLocations",
16812 "globalBc7902Locations");
16814 MPI_Bcast(&globalBc7902Locations[0], globalNoBc7902Locations, MPI_DOUBLE, 0, comm7902, AT_,
16815 "globalBc7902Locations");
16817 m_7902globalWallNormalLocations.clear();
16819 for(
MInt i = 0; i < globalNoBc7902Locations; i++) {
16820 MFloat L = globalBc7902Locations[i];
16821 if(std::find(m_7902globalWallNormalLocations.begin(), m_7902globalWallNormalLocations.end(), L)
16822 == m_7902globalWallNormalLocations.end()) {
16823 m_7902globalWallNormalLocations.push_back(L);
16828 for(
MInt i = 0; i < globalNoBc7902Locations; i++) {
16829 MFloat L = m_7902wallNormalLocations[i];
16830 if(std::find(m_7902globalWallNormalLocations.begin(), m_7902globalWallNormalLocations.end(), L)
16831 == m_7902globalWallNormalLocations.end()) {
16832 m_7902globalWallNormalLocations.push_back(L);
16837 m_7902globalNoWallNormalLocations = (
MInt)m_7902globalWallNormalLocations.
size();
16839 std::sort(m_7902globalWallNormalLocations.begin(), m_7902globalWallNormalLocations.end());
16844 mAlloc(m_7902periodicLocations, m_7902globalNoWallNormalLocations,
"m_7902periodicLocations", FUN_);
16846 mAlloc(m_7902globalNoPeriodicLocations, m_7902globalNoWallNormalLocations,
"m_7902globalNoPeriodicLocations", 0,
16849 for(
MInt i = 0; i < m_7902globalNoWallNormalLocations; i++) {
16850 m_7902periodicLocations[i].clear();
16853 mAlloc(m_7902periodicIndex, noBc7902Cells,
"m_7902periodicIndex", FUN_);
16855 vector<MInt> noPeriodicLocations(m_7902globalNoWallNormalLocations, F0);
16857 for(
MInt i = 0; i < m_7902globalNoWallNormalLocations; i++) {
16859 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16860 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
16861 if(abs(m_solver->a_coordinate(cellId, m_7902wallDir) - m_7902globalWallNormalLocations[i]) < eps) {
16862 m_7902periodicIndex[
id] = i;
16863 if(!m_solver->a_isHalo(cellId)) {
16864 m_7902periodicLocations[i].push_back(cellId);
16865 ++noPeriodicLocations[i];
16871 if(comm_size > 0) {
16872 MPI_Allreduce(&noPeriodicLocations[0], &m_7902globalNoPeriodicLocations[0], m_7902globalNoWallNormalLocations,
16873 MPI_INT, MPI_SUM, comm7902, AT_,
"7902noPeriodicLocations",
"m_7902globalNoPeriodicLocations");
16880 mAlloc(m_7902LESAverage, PV->noVariables, m_7902globalNoWallNormalLocations,
"m_7902LESAverage", F0, FUN_);
16882 for(
MInt var = 0; var < PV->noVariables; var++) {
16883 for(
MInt i = 0; i < m_7902globalNoWallNormalLocations; i++) {
16884 for(
MInt p = 0; p < (
MInt)m_7902periodicLocations[i].size(); p++) {
16885 MInt cellId = m_7902periodicLocations[i][p];
16886 m_7902LESAverage[var][i] += m_solver->a_pvariable(cellId, var) / m_7902globalNoPeriodicLocations[i];
16892 for(
MInt var = 0; var < PV->noVariables; var++) {
16893 if(comm_size > 0) {
16894 MPI_Allreduce(MPI_IN_PLACE, m_7902LESAverage[var], m_7902globalNoWallNormalLocations, MPI_DOUBLE, MPI_SUM,
16895 m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
"MPI_IN_PLACE",
"m_7902LESAverage");
16899 m_log <<
"::bcInit7902: ... FINISHED" << endl;
16903template <MInt nDim,
class SysEqn>
16904template <class _, std::enable_if_t<hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
16908 m_log << endl <<
"::bcInit7905: ..." << endl;
16910 m_7902faceNormalDir = 1;
16912 m_7902periodicDir = 2;
16914 m_7902faceNormalDir = Context::getSolverProperty<MInt>(
"bc7902faceNormalDir", m_solverId, AT_);
16917 m_7902wallDir = Context::getSolverProperty<MInt>(
"bc7902wallDir", m_solverId, AT_);
16920 m_7902periodicDir = Context::getSolverProperty<MInt>(
"bc7902periodicDir", m_solverId, AT_);
16923 m_7902StartTimeStep = m_solver->m_rntStartTimeStep;
16925 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
16928 m_log <<
"::bcInit7902: ... FINISHED" << endl;
16932template <MInt nDim,
class SysEqn>
16933template <class _, std::enable_if_t<!hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
16937 m_log << endl <<
"::bcInit:" + to_string(m_bndryCndIds[bcId]) +
" ..." << endl;
16939 m_startSTGTimeStep = Context::getSolverProperty<MInt>(
"startSTGTimeStep", m_solverId, AT_, &m_startSTGTimeStep);
16941 IF_CONSTEXPR(!isEEGas<SysEqn> && !isDetChem<SysEqn>) {
16961 if(!m_solver->m_stgIsActive) TERMM(1,
"m_stgIsActive=false but BC 7909, 7910, ... exists!");
16970 ScratchSpace<MInt> stgBcCells(m_bndryCndCells[bcId + 1] - m_bndryCndCells[bcId], AT_,
"stgBcCells");
16972 MInt noBc7909Cells = 0;
16973 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
16974 const MInt bndryId = m_sortedBndryCells->a[
id];
16975 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
16977 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
16978 if(m_bndryCells->a[bndryId].m_noSrfcs > 1) {
16979 mTerm(1, AT_,
"Multiple ghost cells by now not supported by STG!");
16981 stgBcCells[noBc7909Cells++] = cellId;
16982 m_stgBcCells.push_back(cellId);
16986 m_stgLocal[bcId] = noBc7909Cells > 0;
16989 if(!m_stgLocal[bcId]) {
16990 cout <<
"RANK " << m_solver->domainId() <<
" has no 7909 cells, although it was entering bcInit7909 " << endl;
16997 m_log <<
"::bcInit" + to_string(m_bndryCndIds[bcId]) +
": ... building stg communicator ..." << endl;
16998 const MPI_Comm& comm7909 = m_comm_bc[m_bc_comm_pointer[bcId]];
17000 MPI_Comm_size(comm7909, &comm_size);
17001 MInt* bc7909CellsperDomain =
new MInt[comm_size];
17002 MInt* stgRanks =
new MInt[comm_size];
17003 MInt myStgRank = m_solver->domainId();
17005 if(noDomains() > 1) {
17006 MPI_Allgather(&noBc7909Cells, 1, MPI_INT, bc7909CellsperDomain, 1, MPI_INT, comm7909, AT_,
"noBc7909Cells ",
17007 "bc7909CellsperDomain");
17008 MPI_Allgather(&myStgRank, 1, MPI_INT, stgRanks, 1, MPI_INT, comm7909, AT_,
"myStgRank",
"stgRanks");
17011 MInt noInvolvedRanks = 0;
17012 MInt* involvedRanks =
new MInt[comm_size];
17013 for(
MInt i = 0; i < comm_size; i++) {
17014 if(bc7909CellsperDomain[i]) {
17015 involvedRanks[noInvolvedRanks] = i;
17021 MPI_Group group, groupStg;
17023 MPI_Group_incl(group, noInvolvedRanks, involvedRanks, &groupStg, AT_);
17026 m_commStg = commStg;
17029 if(!noBc7909Cells)
return;
17038 static constexpr const MFloat eps = 1e-8;
17039 std::vector<MInt> faces = {0, 0, 0, 0, 0, 0};
17040 for(
MInt i = 0; i < noBc7909Cells; ++i) {
17041 const MInt cellId = stgBcCells[i];
17042 const MInt bndryId = m_solver->a_bndryId(cellId);
17043 const MFloat*
const n = &m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[0];
17044 if(abs(n[0] - 1.0) < eps)
17046 else if(abs(n[0] + 1.0) < eps)
17048 else if(abs(n[1] - 1.0) < eps)
17050 else if(abs(n[1] + 1.0) < eps)
17052 else if(abs(n[2] - 1.0) < eps)
17054 else if(abs(n[2] + 1.0) < eps)
17058 const MInt stgFaceNormalDir = std::max_element(faces.begin(), faces.end()) - faces.
begin();
17059 for(
MInt i = 0; i < 2 * nDim; i++) {
17060 if(i != stgFaceNormalDir) {
17061 if(faces[i] != 0)
mTerm(1, AT_,
"Something went wrong, STG plane is only allowed in one direction!");
17065 MInt stgDir = stgFaceNormalDir;
17066 if(noDomains() > 1) {
17067 MPI_Allreduce(&stgFaceNormalDir, &stgDir, 1, MPI_INT, MPI_MIN, comm7909, AT_,
"dirN",
"stgDir");
17070 if(stgFaceNormalDir != stgDir) {
17071 mTerm(1, AT_,
"Something went wrong, STG plane is only allowed in one direction!");
17073 stgDir = stgFaceNormalDir / 2;
17076 MInt stgWallNormalDir = 3;
17078 for(
MInt i = 0; i < noCoords_; i++) {
17079 if(m_bndryCndIds[bcId] == 7909 + i) {
17080 stgWallNormalDir = Context::getBasicProperty<MFloat>(
"stgWallNormalDir", AT_, i);
17084 MInt wallDir = stgWallNormalDir / 2;
17089 m_log <<
"::bcInit7909: ... creating MSTG object ..." << endl;
17091 switch(
string2enum(m_solver->m_bc7909RANSSolverType)) {
17096 m_bndryCndIds[bcId],
17106 m_log <<
"::bcInit" + to_string(m_bndryCndIds[bcId]) +
": ... creating MSTG object finished..." << endl;
17116 m_bndryCndIds[bcId],
17126 m_log <<
"::bcInit" + to_string(m_bndryCndIds[bcId]) +
": ... creating MSTG object finished..." << endl;
17127 stgBCStrcd->
init(0);
17132 mTerm(1, AT_,
"Not yet implemented for solver " + m_solver->m_bc7909RANSSolverType);
17135 m_log <<
"::bcInit7909: ... FINISHED" << endl;
17140template <MInt nDim,
class SysEqn>
17141template <class _, std::enable_if_t<!hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
17145 m_log << endl <<
"::bcInit:" + to_string(m_cutOffBndryCndIds[bcId]) +
" ..." << endl;
17146 m_startSTGTimeStep = Context::getSolverProperty<MInt>(
"startSTGTimeStep", m_solverId, AT_, &m_startSTGTimeStep);
17148 IF_CONSTEXPR(!isEEGas<SysEqn> && !isDetChem<SysEqn>) {
17168 if(!m_solver->m_stgIsActive)
return;
17178 ScratchSpace<MInt> stgBcCells(m_sortedCutOffCells[bcId]->size(), AT_,
"stgBcCells");
17180 MInt noBc7909Cells = 0;
17181 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17182 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
17183 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
17184 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
17185 stgBcCells[noBc7909Cells++] = cellId;
17186 m_stgBcCells.push_back(cellId);
17190 m_stgLocal[bcId] = noBc7909Cells > 0;
17193 if(!(noBc7909Cells > 0))
return;
17196 if(!m_stgLocal[bcId]) {
17197 cout <<
"RANK " << m_solver->domainId() <<
" has no 7909 cells, although it was entering cbcInit7909 " << endl;
17204 m_log <<
"::bcInit" + to_string(m_cutOffBndryCndIds[bcId]) +
": ... building stg communicator ..." << endl;
17205 const MPI_Comm& comm7909 = m_comm_bcCo[m_bcCo_comm_pointer[bcId]];
17207 MPI_Comm_size(comm7909, &comm_size);
17208 MInt* bc7909CellsperDomain =
new MInt[comm_size];
17209 MInt* stgRanks =
new MInt[comm_size];
17210 MInt myStgRank = m_solver->domainId();
17212 if(noDomains() > 1) {
17213 MPI_Allgather(&noBc7909Cells, 1, MPI_INT, bc7909CellsperDomain, 1, MPI_INT, comm7909, AT_,
"noBc7909Cells ",
17214 "bc7909CellsperDomain");
17215 MPI_Allgather(&myStgRank, 1, MPI_INT, stgRanks, 1, MPI_INT, comm7909, AT_,
"myStgRank",
"stgRanks");
17218 MInt noInvolvedRanks = 0;
17219 MInt* involvedRanks =
new MInt[comm_size];
17220 for(
MInt i = 0; i < comm_size; i++) {
17221 if(bc7909CellsperDomain[i]) {
17222 involvedRanks[noInvolvedRanks] = i;
17228 MPI_Group group, groupStg;
17230 MPI_Group_incl(group, noInvolvedRanks, involvedRanks, &groupStg, AT_);
17233 m_commStg = commStg;
17243 std::vector<MInt> faces = {0, 0, 0, 0, 0, 0};
17244 for(
MInt i = 0; i < noBc7909Cells; ++i) {
17245 const MInt cellId = stgBcCells[i];
17247 for(
MInt d = 0; d < 2 * nDim; d++) {
17248 if(!m_solver->a_hasNeighbor(cellId, d,
false)) {
17268 const MInt stgFaceNormalDir = std::max_element(faces.begin(), faces.end()) - faces.
begin();
17279 MInt stgDir = stgFaceNormalDir;
17280 if(noDomains() > 1) {
17281 MPI_Allreduce(&stgFaceNormalDir, &stgDir, 1, MPI_INT, MPI_MIN, comm7909, AT_,
"dirN",
"stgDir");
17290 MInt stgWallNormalDir = 3;
17292 for(
MInt i = 0; i < noCoords_; i++) {
17293 if(m_cutOffBndryCndIds[bcId] == 7909 + i) {
17294 stgWallNormalDir = Context::getBasicProperty<MFloat>(
"stgWallNormalDir", AT_, i);
17298 MInt wallDir = stgWallNormalDir / 2;
17305 m_log <<
"::bcInit7909: ... creating MSTG object ..." << endl;
17307 switch(
string2enum(m_solver->m_bc7909RANSSolverType)) {
17312 m_cutOffBndryCndIds[bcId],
17322 m_log <<
"::bcInit" + to_string(m_cutOffBndryCndIds[bcId]) +
": ... creating MSTG object finished..." << endl;
17324 if(m_stgBC.find(bcId) != m_stgBC.end()) {
17325 if(m_solver->m_wasAdapted || m_solver->m_wasBalancedZonal) {
17327 m_stgBC[bcId]->saveStg();
17328 delete m_stgBC[bcId];
17329 m_stgBC.erase(bcId);
17333 cerr <<
"init bc7909 " << m_solver->m_wasAdapted <<
" " << m_solver->m_wasBalancedZonal << endl;
17344 mTerm(1, AT_,
"Not yet implemented for solver " + m_solver->m_bc7909RANSSolverType);
17347 m_log <<
"::bcInit7909: ... FINISHED" << endl;
17358template <MInt nDim,
class SysEqn>
17359template <class _, std::enable_if_t<hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
17363 if(m_sortedCutOffCells[bcId]->size() == 0) {
17367 MInt cellId, nghbrId, d = m_7901faceNormalDir;
17368 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17369 cellId = m_sortedCutOffCells[bcId]->a[
id];
17371 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
17372 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
17374 if(m_solver->checkNeighborActive(cellId, d)) {
17375 nghbrId = m_solver->c_neighborId(cellId, d);
17377 cutOffBcMissingNeighbor(cellId,
"bc7901");
17380 m_solver->a_pvariable(cellId, PV->U) = m_solver->a_pvariable(nghbrId, PV->U);
17381 m_solver->a_pvariable(cellId, PV->V) = m_solver->a_pvariable(nghbrId, PV->V);
17382 m_solver->a_pvariable(cellId, PV->W) = m_solver->a_pvariable(nghbrId, PV->W);
17384 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
17385 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
17386 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
17387 m_solver->a_pvariable(cellId, PV->NN[r]) = m_solver->a_pvariable(nghbrId, PV->NN[r]);
17391 MFloat pressureTarget = m_solver->m_PInfinity;
17393 m_solver->a_pvariable(cellId, PV->P) = pressureTarget;
17394 if(m_noSpecies > 0) {
17395 m_solver->a_pvariable(cellId, PV->Y[0]) = m_solver->m_LESValues[PV->Y[0]][cellId];
17399 m_solver->a_pvariable(cellId, PV->U) = m_solver->m_UInfinity;
17400 m_solver->a_pvariable(cellId, PV->V) = m_solver->m_VInfinity;
17401 m_solver->a_pvariable(cellId, PV->W) = m_solver->m_WInfinity;
17402 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
17403 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_PInfinity;
17414template <MInt nDim,
class SysEqn>
17415template <class _, std::enable_if_t<hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
17419 if(m_sortedCutOffCells[bcId]->size() == 0)
return;
17422 && m_solver->m_RKStep == 0) {
17423 for(
MInt var = 0; var < PV->noVariables; var++) {
17424 for(
MInt i = 0; i < m_7902globalNoWallNormalLocations; i++) {
17425 m_7902LESAverage[var][i] = F0;
17429 for(
MInt var = 0; var < PV->noVariables; var++) {
17430 for(
MInt i = 0; i < m_7902globalNoWallNormalLocations; i++) {
17431 for(
MInt p = 0; p < (
MInt)m_7902periodicLocations[i].size(); p++) {
17432 MInt cellId = m_7902periodicLocations[i][p];
17434 ASSERT(cellId < (
MInt)m_solver->m_LESValues[var].size(),
17435 "Trying to access data [" + to_string(var) +
"][" + to_string(cellId) +
"] in m_LESValues with length "
17436 + to_string(m_solver->m_LESValues[var].size()) +
", domainId: " + to_string(m_solver->domainId()));
17438 m_7902LESAverage[var][i] += m_solver->m_LESValues[var][cellId] / m_7902globalNoPeriodicLocations[i];
17443 if(noDomains() > 1) {
17444 for(
MInt var = 0; var < PV->noVariables; var++) {
17445 MPI_Allreduce(MPI_IN_PLACE, m_7902LESAverage[var], m_7902globalNoWallNormalLocations, MPI_DOUBLE, MPI_SUM,
17446 m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
"MPI_IN_PLACE",
"m_7902LESAverage");
17451 MInt cellId, nghbrId, d = m_7902faceNormalDir;
17453 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17454 cellId = m_sortedCutOffCells[bcId]->a[
id];
17459 m_solver->a_pvariable(cellId, PV->U) = m_solver->m_UInfinity;
17460 m_solver->a_pvariable(cellId, PV->V) = m_solver->m_VInfinity;
17461 m_solver->a_pvariable(cellId, PV->W) = m_solver->m_WInfinity;
17463 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
17465 m_solver->a_pvariable(cellId, PV->N) = m_solver->m_nuTildeInfinity;
17469 for(
MInt var = 0; var < PV->noVariables; var++) {
17470 MInt index = m_7902periodicIndex[
id];
17471 m_solver->a_pvariable(cellId, var) = m_7902LESAverage[var][index];
17476 if(m_solver->checkNeighborActive(cellId, d)) {
17477 nghbrId = m_solver->c_neighborId(cellId, d);
17479 cutOffBcMissingNeighbor(cellId,
"bc7902");
17481 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
17484 TERMM(1,
"ERROR in bc7902");
17495template <MInt nDim,
class SysEqn>
17496template <class _, std::enable_if_t<hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
17500 if(m_sortedCutOffCells[bcId]->size() == 0)
return;
17502 MInt cellId, nghbrId, d = m_7902faceNormalDir;
17504 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17505 cellId = m_sortedCutOffCells[bcId]->a[
id];
17507 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
17508 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
17513 m_solver->a_pvariable(cellId, PV->U) = m_solver->m_UInfinity;
17514 m_solver->a_pvariable(cellId, PV->V) = m_solver->m_VInfinity;
17515 m_solver->a_pvariable(cellId, PV->W) = m_solver->m_WInfinity;
17517 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
17519 m_solver->a_pvariable(cellId, PV->N) = m_solver->m_nuTildeInfinity;
17523 for(
MInt var = 0; var < PV->noVariables; var++) {
17524 m_solver->a_pvariable(cellId, var) = m_solver->m_LESValues[var][cellId];
17529 if(m_solver->checkNeighborActive(cellId, d)) {
17530 nghbrId = m_solver->c_neighborId(cellId, d);
17532 cutOffBcMissingNeighbor(cellId,
"bc7905");
17534 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
17537 TERMM(1,
"ERROR in bc7905");
17548template <MInt nDim,
class SysEqn>
17549template <class _, std::enable_if_t<!hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
17555 MInt cellId, nghbrId, d = 0;
17557 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17558 cellId = m_sortedCutOffCells[bcId]->a[
id];
17560 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
17561 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
17564 if(m_solver->checkNeighborActive(cellId, d)) {
17565 nghbrId = m_solver->c_neighborId(cellId, d);
17567 cutOffBcMissingNeighbor(cellId,
"bc7903");
17570 m_solver->a_pvariable(cellId, PV->U) = m_solver->a_pvariable(nghbrId, PV->U);
17571 m_solver->a_pvariable(cellId, PV->V) = m_solver->a_pvariable(nghbrId, PV->V);
17572 m_solver->a_pvariable(cellId, PV->W) = m_solver->a_pvariable(nghbrId, PV->W);
17574 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
17576 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_RANSValues[PV->P][cellId];
17578 for(
MInt s = 0; s < m_noSpecies; s++)
17579 m_solver->a_pvariable(cellId, PV->Y[s]) = m_solver->a_pvariable(nghbrId, PV->Y[s]);
17582 TERMM(1,
"ERROR in bc7903");
17593template <MInt nDim,
class SysEqn>
17594template <class _, std::enable_if_t<!hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
17598 IF_CONSTEXPR(isEEGas<SysEqn>)
17599 TERMM(1,
"bc7809 not working for AIAFvSysEqnEEGas");
17601 if(m_stgLocal[bcId]) {
17602 switch(
string2enum(m_solver->m_bc7909RANSSolverType)) {
17604 m_stgBC[bcId]->bc7909();
17608 m_stgBCStrcd[bcId]->bc7909();
17612 mTerm(1, AT_,
"Not yet implemented for solver " + m_solver->m_bc7909RANSSolverType);
17614 if(m_solver->m_noSpecies > 0) {
17615 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
17616 MInt bndryId = m_sortedBndryCells->a[
id];
17617 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
17618 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
17619 const MInt ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[0]->m_ghostCellId;
17620 for(
MInt i = 0; i < m_noSpecies; i++) {
17621 m_solver->a_pvariable(ghostCellId, PV->Y[i]) = F0;
17635template <MInt nDim,
class SysEqn>
17636template <class _, std::enable_if_t<!hasPV_N<SysEqn>::value, _*>, std::enable_if_t<nDim == 3, _*>>
17640 IF_CONSTEXPR(isEEGas<SysEqn>)
17641 TERMM(1,
"bc7809 not working for AIAFvSysEqnEEGas");
17643 if(m_sortedCutOffCells[bcId]->size() == 0) {
17649 if(!m_solver->m_stgIsActive) {
17650 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17651 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
17654 m_solver->a_pvariable(cellId, PV->U) = m_solver->m_RANSValues[PV->U][cellId];
17655 m_solver->a_pvariable(cellId, PV->V) = m_solver->m_RANSValues[PV->V][cellId];
17656 m_solver->a_pvariable(cellId, PV->W) = m_solver->m_RANSValues[PV->W][cellId];
17657 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_RANSValues[PV->RHO][cellId];
17661 if(m_stgLocal[bcId]) {
17662 switch(
string2enum(m_solver->m_bc7909RANSSolverType)) {
17664 m_stgBC[bcId]->bc7909();
17668 m_stgBCStrcd[bcId]->bc7909();
17673 mTerm(1, AT_,
"Not yet implemented for solver " + m_solver->m_bc7909RANSSolverType);
17677 if(m_solver->m_noSpecies > 0) {
17678 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17679 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
17680 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
17681 for(
MInt i = 0; i < m_noSpecies; i++) {
17682 m_solver->a_pvariable(cellId, PV->Y[i]) = F0;
17690 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17691 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
17692 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
17693 if(m_solver->checkNeighborActive(cellId, d)) {
17694 const MInt nghbrId = m_solver->c_neighborId(cellId, d);
17696 cutOffBcMissingNeighbor(cellId,
"bc7909");
17698 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
17701 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_PInfinity;
17712template <MInt nDim,
class SysEqn>
17716 IF_CONSTEXPR(isEEGas<SysEqn>)
17717 TERMM(1,
"bc7809 not working for AIAFvSysEqnEEGas");
17719 if(m_sortedCutOffCells[bcId]->size() == 0) {
17724 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17725 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
17726 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
17727 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
17728 if(m_solver->checkNeighborActive(cellId, d)) {
17729 const MInt nghbrId = m_solver->c_neighborId(cellId, d);
17731 cutOffBcMissingNeighbor(cellId,
"bc30022");
17733 m_solver->a_pvariable(cellId, PV->U) = m_solver->a_pvariable(nghbrId, PV->U);
17734 m_solver->a_pvariable(cellId, PV->V) = m_horTargetData[
id][1];
17735 m_solver->a_pvariable(cellId, PV->W) = m_solver->m_WInfinity;
17736 m_solver->a_pvariable(cellId, PV->RHO) = m_horTargetData[
id][2];
17737 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
17740 m_solver->a_pvariable(cellId, PV->U) = m_solver->m_UInfinity;
17741 m_solver->a_pvariable(cellId, PV->V) = m_solver->m_VInfinity;
17742 m_solver->a_pvariable(cellId, PV->W) = m_solver->m_WInfinity;
17743 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->m_rhoInfinity;
17744 m_solver->a_pvariable(cellId, PV->P) = m_solver->m_PInfinity;
17755template <MInt nDim,
class SysEqn>
17759 "Error in " + bcName +
": missing neighbor for (halo) cut-off cell only allowed in multisolver case (halo = "
17760 + to_string(m_solver->a_isHalo(cellId)) +
"; multisolver = " + to_string(
g_multiSolverGrid) +
")");
17762 std::ignore = bcName;
17764 const MFloat nanValue = std::numeric_limits<MFloat>::quiet_NaN();
17765 std::fill_n(&m_solver->a_pvariable(cellId, 0), PV->noVariables, nanValue);
17776template <MInt nDim,
class SysEqn>
17781#pragma omp parallel for
17784 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
17785 const MInt cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
17786 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
17787 const MInt ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[0]->m_ghostCellId;
17790 m_solver->a_pvariable(ghostCellId, PV->RHO) = m_solver->a_pvariable(cellId, PV->RHO);
17793 m_solver->a_pvariable(ghostCellId, PV->U) = m_solver->a_pvariable(cellId, PV->U);
17794 m_solver->a_pvariable(ghostCellId, PV->V) = -m_solver->a_pvariable(cellId, PV->V);
17797 m_solver->a_pvariable(ghostCellId, PV->P) = m_solver->a_pvariable(cellId, PV->P);
17799 IF_CONSTEXPR(SysEqn::m_noRansEquations > 0) {
17800 for(
MInt r = 0; r < m_solver->m_noRansEquations; ++r) {
17801 m_solver->a_pvariable(ghostCellId, PV->NN[r]) = m_solver->a_pvariable(cellId, PV->N);
17814template <MInt nDim,
class SysEqn>
17823 for(
MInt i = 0; i < nDim; i++) {
17826 switch(m_cutOffBndryCndIds[bcId]) {
17844 IF_CONSTEXPR(nDim == 2)
mTerm(1, AT_,
"bc29054: symmetry in z-direction not possible for 2D");
17849 IF_CONSTEXPR(nDim == 2)
mTerm(1, AT_,
"bc29054: symmetry in z-direction not possible for 2D");
17854 stringstream errorMessage;
17855 errorMessage <<
"ERROR: Switch variable 'm_cutOffBndryCndIds[ bcId ]' with value " << m_cutOffBndryCndIds[bcId]
17856 <<
" not matching any case." << endl;
17857 mTerm(1, AT_, errorMessage.str());
17862 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17863 cellId = m_sortedCutOffCells[bcId]->a[
id];
17864 nghbrId = m_solver->c_neighborId(cellId, d);
17867 m_solver->a_pvariable(cellId, PV->U) = Dir[0] * m_solver->a_pvariable(nghbrId, PV->U);
17868 m_solver->a_pvariable(cellId, PV->V) = Dir[1] * m_solver->a_pvariable(nghbrId, PV->V);
17869 IF_CONSTEXPR(nDim == 3) { m_solver->a_pvariable(cellId, PV->W) = Dir[2] * m_solver->a_pvariable(nghbrId, PV->W); }
17871 m_solver->a_pvariable(cellId, PV->RHO) = m_solver->a_pvariable(nghbrId, PV->RHO);
17874 m_solver->a_pvariable(cellId, PV->P) = m_solver->a_pvariable(nghbrId, PV->P);
17877 for(
MInt i = 0; i < m_noSpecies; i++) {
17878 m_solver->a_pvariable(cellId, PV->Y[i]) = m_solver->a_pvariable(nghbrId, PV->Y[i]);
17890template <MInt nDim,
class SysEqn>
17894 if(m_sortedCutOffCells[bcId]->size() == 0) {
17898 MInt cbcId = m_cbcBndryCndIds[bcId];
17900 MInt dirN = m_cbcDir[cbcId][0];
17901 MInt dimN = m_cbcDir[cbcId][1];
17902 MInt dimT1 = m_cbcDir[cbcId][2];
17903 MInt dimT2 = m_cbcDir[cbcId][nDim];
17905 MInt last = nDim + 1;
17919 MFloat mach[2] = {F0, F0};
17920 cbcMachCo(bcId, mach);
17924 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
17927 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
17930 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
17931 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
17933 MFloat T_target = sysEqn().temperature_IR(meanM);
17934 MFloat p_Target = sysEqn().pressure_IR(T_target);
17937 IF_CONSTEXPR(isDetChem<SysEqn>) {
17938 T_target = m_solver->m_detChem.infTemperature;
17939 p_Target = m_solver->m_detChem.infPressure;
17942 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
17943 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
17945 if(m_solver->a_isHalo(cellId))
continue;
17946 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
17947 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
17949 MInt bndryId = m_solver->a_bndryId(cellId);
17951 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
17954 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
17957 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
17959 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
17960 IF_CONSTEXPR(nDim == 3) gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0;
17962 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
17963 &cutOffStencilCellIds[0], &V[0]);
17966 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
17967 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
17968 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
17970 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
17971 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
17972 const MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
17973 MFloat temp = sysEqn().temperature_ES(rho, p);
17975 IF_CONSTEXPR(isDetChem<SysEqn>) {
17976 MFloat fMeanMolarWeight = F0;
17977 for(
MUint s = 0; s < PV->m_noSpecies; s++) {
17978 fMeanMolarWeight += m_solver->a_pvariable(cellId, PV->Y[s]) * m_solver->m_fMolarMass[s];
17980 MFloat meanMolarWeight = F1 / fMeanMolarWeight;
17981 temp = p / rho * meanMolarWeight / m_solver->m_gasConstant;
17984 const MFloat a = sysEqn().speedOfSound(rho, p);
17986 if(dirN % 2 == 0) {
17987 L[0] = K[0] * (p - p_Target) + (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
17989 L[last] = K[last] * (p - p_Target) + (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
17992 L[1] = K[1] * (temp - T_target) + (
a *
a * T[0] - T[last]) - V[last];
17994 L[2] = K[2] * ut1 + T[2] + V[2];
17996 IF_CONSTEXPR(nDim == 3) {
17997 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
17998 L[3] = K[3] * ut2 + T[3] + V[3];
18000 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
18001 MFloat y = m_solver->a_pvariable(cellId, sysEqn().PV->Y[s]);
18002 L[last + 1 + s] = K[last + 1 + s] * (
y - y_target);
18005 IF_CONSTEXPR(isDetChem<SysEqn>) {
18006 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
18007 MFloat y = m_solver->a_pvariable(cellId, sysEqn().PV->Y[s]);
18008 L[last + 1 + s] = K[last + 1 + s] * (
y - m_solver->m_YInfinity[s]);
18012 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
18022template <MInt nDim,
class SysEqn>
18026 if(m_sortedCutOffCells[bcId]->size() == 0) {
18030 MInt cbcId = m_cbcBndryCndIds[bcId];
18032 MInt dirN = m_cbcDir[cbcId][0];
18033 MInt dimN = m_cbcDir[cbcId][1];
18034 MInt dimT1 = m_cbcDir[cbcId][2];
18036 MInt last = nDim + 1;
18045 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
18048 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
18056 MFloat mach[2] = {F0, F0};
18057 cbcMachCo(bcId, mach);
18061 const MFloat gammaMinusOne = m_solver->m_gamma - 1.0;
18064 MBool solverProfile = Context::getSolverProperty<MBool>(
"solverProfile", m_solverId, AT_, &solverProfile);
18066 IF_CONSTEXPR(nDim == 3) { A = sqrt(m_cbcInflowArea[cbcId] / PI); }
18068 A = m_cbcInflowArea[cbcId] * F1B2;
18071 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18072 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18073 if(m_solver->a_isHalo(cellId))
continue;
18074 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
18075 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18076 MInt bndryId = m_solver->a_bndryId(cellId);
18080 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
18082 area = m_solver->a_surfaceArea(srfcId);
18084 mTerm(1, AT_,
"something went wrong!");
18087 IF_CONSTEXPR(nDim == 2) area = m_solver->c_cellLengthAtCell(cellId);
18088 IF_CONSTEXPR(nDim == 3) area =
POW2(m_solver->c_cellLengthAtCell(cellId));
18092 IF_CONSTEXPR(nDim == 2) {
18093 rsquare =
POW2((m_solver->a_coordinate(cellId, dimT1) - m_cbcReferencePoint[cbcId][dimT1]));
18096 rsquare =
POW2(m_solver->a_coordinate(cellId, 0) - m_cbcReferencePoint[cbcId][0])
18097 +
POW2(m_solver->a_coordinate(cellId, 1) - m_cbcReferencePoint[cbcId][1])
18098 +
POW2(m_solver->a_coordinate(cellId, 2) - m_cbcReferencePoint[cbcId][2]);
18100 testSum2 += area * rsquare;
18102 MPI_Allreduce(MPI_IN_PLACE, &testSum2, 3, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
18103 "testSum2",
"testSum2Result");
18107 IF_CONSTEXPR(nDim == 2) { massflux_test = F3B4 / A * (m_cbcInflowArea[cbcId] - F1 / (A * A) * testSum2); }
18109 massflux_test = F2 * (F1 - testSum2 / (m_cbcInflowArea[cbcId] * A * A));
18111 MFloat un_correctionFactor = F1;
18112 if(fabs(massflux_test) > m_solver->m_eps) {
18113 un_correctionFactor = F1 / massflux_test;
18119 massflux_target = m_solver->m_UInfinity * m_cbcInflowArea[cbcId]
18120 * sysEqn().density_ES(m_solver->m_PInfinity, m_solver->m_TInfinity);
18121 MFloat T_target = sysEqn().temperature_IR(meanM);
18123 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
18124 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
18126 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18127 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18129 if(m_solver->a_isHalo(cellId))
continue;
18130 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
18131 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18133 MInt bndryId = m_solver->a_bndryId(cellId);
18135 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
18138 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
18141 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
18142 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
18143 &cutOffStencilCellIds[0], &V[0]);
18146 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
18147 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
18148 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"velocity");
18150 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
18151 MFloat p = m_solver->a_pvariable(cellId, PV->P);
18152 MFloat a = sysEqn().speedOfSound(rho, p);
18157 rsquare =
POW2((m_solver->a_coordinate(cellId, dimT1) - m_cbcReferencePoint[cbcId][dimT1]));
18158 un_target = F3B4 * massflux_target / rho / A * (1 - rsquare / (A * A)) * un_correctionFactor;
18160 rsquare =
POW2(m_solver->a_coordinate(cellId, 0) - m_cbcReferencePoint[cbcId][0])
18161 +
POW2(m_solver->a_coordinate(cellId, 1) - m_cbcReferencePoint[cbcId][1])
18162 +
POW2(m_solver->a_coordinate(cellId, 2) - m_cbcReferencePoint[cbcId][2]);
18163 un_target = F2 * massflux_target / m_cbcInflowArea[cbcId] * (F1 - rsquare / (A * A)) / rho * un_correctionFactor;
18165 if(solverProfile) {
18166 un_target = massflux_target / m_cbcInflowArea[cbcId] / rho;
18176 if(dirN % 2 == 0) {
18177 L[0] = L[last] + (T[last] - rho *
a * T[1]);
18179 L[last] = L[0] + (T[last] + rho *
a * T[1]);
18182 L[1] = F1B2 * gammaMinusOne * (L[0] + L[last]) + (
a *
a * T[0] - T[last]);
18184 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
18186 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimN]) = F0;
18187 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT1]) = F0;
18188 m_solver->a_rightHandSide(cellId, CV->RHO_E) = F0;
18190 if(dirN % 2 == 0) {
18193 m_solver->a_pvariable(cellId, PV->VV[dimN]) = un_target * sign;
18194 m_solver->a_pvariable(cellId, PV->VV[dimT1]) = F0;
18195 m_solver->a_pvariable(cellId, PV->P) = T_target;
18196 IF_CONSTEXPR(nDim == 3) {
18197 MInt dimT2 = m_cbcDir[cbcId][nDim];
18198 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT2]) = F0;
18199 m_solver->a_pvariable(cellId, PV->VV[dimT1]) = F0;
18208template <MInt nDim,
class SysEqn>
18211 if(m_sortedCutOffCells[bcId]->size() == 0) {
18215 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18216 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18217 if(m_solver->a_isHalo(cellId))
continue;
18218 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18220 const MInt bndryId = m_solver->a_bndryId(cellId);
18223 if(m_bndryCells->a[bndryId].m_linkedCellId > -1) {
18229 const MFloat rho = m_solver->a_variable(cellId, CV->RHO);
18230 const MFloat u = m_solver->a_pvariable(cellId, PV->VV[0]);
18231 const MFloat v = m_solver->a_pvariable(cellId, PV->VV[1]);
18232 const MFloat T = m_solver->a_pvariable(cellId, PV->P);
18233 const MFloat p = sysEqn().pressure_ES(T, rho);
18234 MFloat velSquared = u * u + v * v;
18235 IF_CONSTEXPR(nDim == 3) {
18236 const MFloat w = m_solver->a_pvariable(cellId, PV->VV[2]);
18237 m_solver->a_variable(cellId, CV->RHO_VV[2]) = rho * w;
18238 velSquared += w * w;
18240 m_solver->a_variable(cellId, CV->RHO_E) = sysEqn().internalEnergy(p, rho, velSquared);
18241 m_solver->a_variable(cellId, CV->RHO_VV[0]) = rho * u;
18242 m_solver->a_variable(cellId, CV->RHO_VV[1]) = rho * v;
18254template <MInt nDim,
class SysEqn>
18258 if(m_sortedCutOffCells[bcId]->size() == 0) {
18262 MInt cbcId = m_cbcBndryCndIds[bcId];
18264 MInt dirN = m_cbcDir[cbcId][0];
18265 MInt dimN = m_cbcDir[cbcId][1];
18266 MInt dimT1 = m_cbcDir[cbcId][2];
18267 MInt dimT2 = m_cbcDir[cbcId][nDim];
18269 MInt last = nDim + 1;
18278 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
18281 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
18289 MFloat mach[2] = {F0, F0};
18290 cbcMachCo(bcId, mach);
18294 const MFloat gammaMinusOne = m_solver->m_gamma - 1.0;
18296 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
18297 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
18299 MFloat T_target = sysEqn().temperature_IR(meanM);
18300 MFloat p_Target = sysEqn().pressure_IR(T_target);
18302 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18303 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18305 if(m_solver->a_isHalo(cellId))
continue;
18306 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
18307 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18309 MInt bndryId = m_solver->a_bndryId(cellId);
18311 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
18314 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
18317 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
18318 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
18319 IF_CONSTEXPR(nDim == 3) gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0;
18320 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
18321 &cutOffStencilCellIds[0], &V[0]);
18324 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
18325 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
18326 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
18328 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
18329 MFloat p = m_solver->a_pvariable(cellId, PV->P);
18330 MFloat a = sysEqn().speedOfSound(rho, p);
18332 if(dirN % 2 == 0) {
18333 L[0] = -L[last] + (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
18335 L[last] = -L[0] + (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
18338 L[1] = F1B2 * gammaMinusOne * (L[last] - L[0]) + (
a *
a * T[0] - T[last]) - V[last];
18340 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
18342 m_solver->a_rightHandSide(cellId, CV->RHO) = 0.0;
18343 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT1]) = 0.0;
18344 m_solver->a_rightHandSide(cellId, CV->RHO_E) = 0.0;
18345 IF_CONSTEXPR(nDim == 3) { m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT2]) = 0.0; }
18346 m_solver->a_pvariable(cellId, PV->RHO) = sysEqn().density_ES(p_Target, T_target);
18347 m_solver->a_pvariable(cellId, PV->VV[dimT1]) = 0.0;
18348 IF_CONSTEXPR(nDim == 3) { m_solver->a_pvariable(cellId, PV->VV[dimT2]) = 0.0; }
18349 m_solver->a_pvariable(cellId, PV->P) = p_Target;
18357template <MInt nDim,
class SysEqn>
18361 MInt otherDir[2 * nDim];
18362 for(
MInt dim = 0; dim < nDim; dim++) {
18363 otherDir[2 * dim] = 2 * dim + 1;
18364 otherDir[2 * dim + 1] = 2 * dim;
18367 MBool& first = m_static_cbc1091c_after_first;
18368 MInt& dirN = m_static_cbc1091c_after_dirN;
18369 MInt& dimN = m_static_cbc1091c_after_dimN;
18370 MInt& dimT1 = m_static_cbc1091c_after_dimT1;
18371 MInt& dimT2 = m_static_cbc1091c_after_dimT2;
18376 if(noCutOffDirections != noCutOffBndryIds) {
18378 "Wrong number of cut off directions. Must be identical to number of cut off bndryIds! Please check!");
18380 MInt cutOffBndryIdTmp, cutOffDirectionTmp;
18381 for(
MInt i = 0; i < noCutOffBndryIds; i++) {
18382 cutOffBndryIdTmp = Context::getSolverProperty<MInt>(
"cutOffBndryIds", m_solverId, AT_, i);
18383 cutOffDirectionTmp = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, i);
18384 if(cutOffBndryIdTmp == m_cutOffBndryCndIds[bcId]) {
18385 dirN = otherDir[cutOffDirectionTmp];
18389 dimN = (
MInt)dirN / 2;
18390 dimT1 = (dimN + 1) % nDim;
18391 IF_CONSTEXPR(nDim == 3) dimT2 = (dimT1 + 1) % nDim;
18396 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18397 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18398 if(m_solver->a_isHalo(cellId))
continue;
18399 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18401 MInt bndryId = m_solver->a_bndryId(cellId);
18404 if(m_bndryCells->a[bndryId].m_linkedCellId > -1) {
18410 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
18411 MFloat u = m_solver->a_variable(cellId, CV->RHO_VV[dimN]) / m_solver->a_variable(cellId, CV->RHO);
18412 MFloat v = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
18413 MFloat p = m_solver->a_pvariable(cellId, PV->P);
18415 MFloat E = sysEqn().internalEnergy(p, rho, vel);
18417 IF_CONSTEXPR(nDim == 3) {
18419 MFloat w = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
18420 E += F1B2 * (w * w) * rho;
18421 m_solver->a_variable(cellId, CV->RHO_VV[dimT2]) = rho * w;
18424 m_solver->a_variable(cellId, CV->RHO_E) = E;
18435template <MInt nDim,
class SysEqn>
18439 if(m_sortedCutOffCells[bcId]->size() == 0) {
18443 MInt cbcId = m_cbcBndryCndIds[bcId];
18445 MInt dirN = m_cbcDir[cbcId][0];
18446 MInt dimN = m_cbcDir[cbcId][1];
18447 MInt dimT1 = m_cbcDir[cbcId][2];
18449 MInt last = nDim + 1;
18458 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
18461 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
18470 MFloat mach[2] = {F0, F0};
18471 cbcMachCo(bcId, mach);
18476 MBool solverProfile = Context::getSolverProperty<MBool>(
"solverProfile", m_solverId, AT_, &solverProfile);
18478 IF_CONSTEXPR(nDim == 3) { A = sqrt(m_cbcInflowArea[cbcId] / PI); }
18480 A = m_cbcInflowArea[cbcId] * F1B2;
18484 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18485 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18486 if(m_solver->a_isHalo(cellId))
continue;
18487 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
18488 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18489 MInt bndryId = m_solver->a_bndryId(cellId);
18490 MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
18494 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
18496 area = m_solver->a_surfaceArea(srfcId);
18498 mTerm(1, AT_,
"something went wrong!");
18501 IF_CONSTEXPR(nDim == 2) area = m_solver->c_cellLengthAtCell(cellId);
18502 IF_CONSTEXPR(nDim == 3) area =
POW2(m_solver->c_cellLengthAtCell(cellId));
18506 IF_CONSTEXPR(nDim == 2) {
18507 rsquare =
POW2((m_solver->a_coordinate(cellId, dimT1) - m_cbcReferencePoint[cbcId][dimT1]));
18510 rsquare =
POW2(m_solver->a_coordinate(cellId, 0) - m_cbcReferencePoint[cbcId][0])
18511 +
POW2(m_solver->a_coordinate(cellId, 1) - m_cbcReferencePoint[cbcId][1])
18512 +
POW2(m_solver->a_coordinate(cellId, 2) - m_cbcReferencePoint[cbcId][2]);
18514 testSum2 += area * rsquare;
18515 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
18516 const MFloat un_N = m_solver->a_pvariable(nghbrN, PV->VV[dimN]);
18517 massflux += un_N * area * rho;
18520 MPI_Allreduce(MPI_IN_PLACE, &massflux, 3, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
18521 "massflux",
"massfluxResult");
18522 MPI_Allreduce(MPI_IN_PLACE, &testSum2, 3, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
18523 "testSum2",
"testSum2Result");
18526 IF_CONSTEXPR(nDim == 2) { massflux_test = F3B4 / A * (m_cbcInflowArea[cbcId] - F1 / (A * A) * testSum2); }
18528 massflux_test = F2 * (F1 - testSum2 / (m_cbcInflowArea[cbcId] * A * A));
18530 MFloat un_correctionFactor = F1;
18531 if(fabs(massflux_test) > m_solver->m_eps) {
18532 un_correctionFactor = F1 / massflux_test;
18536 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
18537 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
18539 MFloat T_target = sysEqn().temperature_IR(meanM);
18540 MFloat p_Target = sysEqn().pressure_IR(T_target);
18542 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18543 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18545 if(m_solver->a_isHalo(cellId))
continue;
18546 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
18547 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18549 MInt bndryId = m_solver->a_bndryId(cellId);
18551 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
18554 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
18556 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
18559 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
18560 MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
18561 MFloat p = m_solver->a_pvariable(cellId, PV->P);
18562 MFloat temp = sysEqn().temperature_ES(rho, p);
18563 MFloat a = sysEqn().speedOfSound(rho, p);
18566 IF_CONSTEXPR(nDim == 3) {
18567 MFloat rsquare =
POW2(m_solver->a_coordinate(cellId, 0) - m_cbcReferencePoint[cbcId][0])
18568 +
POW2(m_solver->a_coordinate(cellId, 1) - m_cbcReferencePoint[cbcId][1])
18569 +
POW2(m_solver->a_coordinate(cellId, 2) - m_cbcReferencePoint[cbcId][2]);
18570 un_target = F2 * massflux / m_cbcInflowArea[cbcId] * (F1 - rsquare / (A * A)) / un_correctionFactor;
18573 MFloat rsquare =
POW2((m_solver->a_coordinate(cellId, dimT1) - m_cbcReferencePoint[cbcId][dimT1]));
18574 if(!solverProfile) {
18575 const MFloat mu = sysEqn().sutherlandLaw(temp);
18577 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimT1] =
18578 -mu * F3B2 * massflux / (rho * A * A * A) * un_correctionFactor;
18580 un_target = F3B4 * massflux / A * (1 - rsquare / (A * A)) * un_correctionFactor;
18581 if(solverProfile) {
18582 un_target = m_solver->m_UInfinity;
18588 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
18589 &cutOffStencilCellIds[0], &V[0]);
18591 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
18592 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
18593 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
18595 if(dirN % 2 == 0) {
18596 L[0] = K[0] * (p - p_Target) + (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
18598 L[last] = K[last] * (p - p_Target) + (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
18601 L[1] = K[1] * (temp - T_target) + (
a *
a * T[0] - T[last]) - V[last];
18602 L[2] = K[2] * ut1 + T[2] + V[2];
18603 IF_CONSTEXPR(nDim == 3) {
18604 MInt dimT2 = m_cbcDir[cbcId][nDim];
18605 MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
18606 L[3] = K[3] * ut2 + T[3] + V[3];
18609 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
18610 m_solver->a_pvariable(cellId, PV->VV[dimN]) = un_target;
18618template <MInt nDim,
class SysEqn>
18622 MInt otherDir[2 * nDim];
18623 for(
MInt dim = 0; dim < nDim; dim++) {
18624 otherDir[2 * dim] = 2 * dim + 1;
18625 otherDir[2 * dim + 1] = 2 * dim;
18628 MBool& first = m_static_cbc1091d_after_first;
18629 MInt& dirN = m_static_cbc1091d_after_dirN;
18630 MInt& dimN = m_static_cbc1091d_after_dimN;
18631 MInt& dimT1 = m_static_cbc1091d_after_dimT1;
18632 MInt& dimT2 = m_static_cbc1091d_after_dimT2;
18637 if(noCutOffDirections != noCutOffBndryIds) {
18639 "Wrong number of cut off directions. Must be identical to number of cut off bndryIds! Please check!");
18641 MInt cutOffBndryIdTmp, cutOffDirectionTmp;
18642 for(
MInt i = 0; i < noCutOffBndryIds; i++) {
18643 cutOffBndryIdTmp = Context::getSolverProperty<MInt>(
"cutOffBndryIds", m_solverId, AT_, i);
18644 cutOffDirectionTmp = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, i);
18645 if(cutOffBndryIdTmp == m_cutOffBndryCndIds[bcId]) {
18646 dirN = otherDir[cutOffDirectionTmp];
18650 dimN = (
MInt)dirN / 2;
18651 dimT1 = (dimN + 1) % nDim;
18652 IF_CONSTEXPR(nDim == 3) dimT2 = (dimT1 + 1) % nDim;
18657 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18658 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18659 if(m_solver->a_isHalo(cellId))
continue;
18660 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18662 MInt bndryId = m_solver->a_bndryId(cellId);
18665 if(m_bndryCells->a[bndryId].m_linkedCellId > -1) {
18671 MFloat rho = m_solver->a_variable(cellId, CV->RHO);
18672 MFloat u = m_solver->a_pvariable(cellId, PV->VV[dimN]);
18673 MFloat u_wrong = m_solver->a_variable(cellId, CV->RHO_VV[dimN]) / m_solver->a_variable(cellId, CV->RHO);
18674 MFloat v = m_solver->a_variable(cellId, CV->RHO_VV[dimT1]) / m_solver->a_variable(cellId, CV->RHO);
18676 MFloat Sum_sq_u = u_wrong * u_wrong + v * v;
18678 IF_CONSTEXPR(nDim == 2) {
18679 MFloat p = sysEqn().pressure(rho, Sum_sq_u, m_solver->a_variable(cellId, CV->RHO_E));
18680 E = sysEqn().internalEnergy(p, rho, (u * u + v * v));
18682 IF_CONSTEXPR(nDim == 3) {
18683 MFloat w = m_solver->a_variable(cellId, CV->RHO_VV[dimT2]) / m_solver->a_variable(cellId, CV->RHO);
18684 MFloat p = sysEqn().pressure(rho, Sum_sq_u, m_solver->a_variable(cellId, CV->RHO_E));
18686 E = sysEqn().internalEnergy(p, rho, (u * u + v * v + w * w));
18688 m_solver->a_variable(cellId, CV->RHO_VV[dimN]) = rho * u;
18689 m_solver->a_variable(cellId, CV->RHO_E) = E;
18699template <MInt nDim,
class SysEqn>
18703 if(m_sortedCutOffCells[bcId]->size() == 0) {
18707 MInt cbcId = m_cbcBndryCndIds[bcId];
18709 MInt dirN = m_cbcDir[cbcId][0];
18710 MInt dimN = m_cbcDir[cbcId][1];
18711 MInt dimT1 = m_cbcDir[cbcId][2];
18712 MInt dimT2 = m_cbcDir[cbcId][nDim];
18714 MInt last = nDim + 1;
18722 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
18725 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
18734 cbcMachCo(bcId, mach);
18738 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
18739 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
18741 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18742 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18744 if(m_solver->a_isHalo(cellId))
continue;
18746 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
18749 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
18750 gradQ[dimN * nDim + dimN] = F0;
18751 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
18752 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
18753 cbcViscousTerms<(unsigned char)11111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
18754 &cutOffStencilCellIds[0], &V[0]);
18757 cbcOutgoingAmplitudeVariation<0>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
18758 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
18759 cbcDampingOutflow(cellId, bcId, maxM, &K[0]);
18761 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
18762 MFloat p = m_solver->a_pvariable(cellId, PV->P);
18763 MFloat a = sysEqn().speedOfSound(rho, p);
18764 const MFloat targetPressure = m_solver->m_PInfinity - m_deltaPL;
18767 if(dirN % 2 == 0) {
18768 L[0] = -L[last] + (F1 - beta) * (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
18770 L[last] = -L[0] + (F1 - beta) * (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
18772 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
18773 m_solver->a_rightHandSide(cellId, CV->RHO_E) = 0.0;
18774 m_solver->a_pvariable(cellId, PV->P) = targetPressure;
18782template <MInt nDim,
class SysEqn>
18786 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18787 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18789 if(m_solver->a_isHalo(cellId))
continue;
18790 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
18791 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18793 MInt bndryId = m_solver->a_bndryId(cellId);
18795 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
18799 MFloat rho = m_solver->a_variable(cellId, CV->RHO);
18800 MFloat u = m_solver->a_variable(cellId, CV->RHO_U) / rho;
18801 MFloat v = m_solver->a_variable(cellId, CV->RHO_V) / rho;
18802 MFloat p = m_solver->a_pvariable(cellId, PV->P);
18803 MFloat E = sysEqn().internalEnergy(p, rho, (u * u + v * v));
18804 IF_CONSTEXPR(nDim == 3) {
18805 MFloat w = m_solver->a_variable(cellId, CV->RHO_W) / rho;
18806 E = sysEqn().internalEnergy(p, rho, (u * u + v * v + w * w));
18809 m_solver->a_variable(cellId, CV->RHO_E) = E;
18819template <MInt nDim,
class SysEqn>
18823 if(m_sortedCutOffCells[bcId]->size() == 0) {
18827 MInt cbcId = m_cbcBndryCndIds[bcId];
18829 MInt dirN = m_cbcDir[cbcId][0];
18830 MInt dimN = m_cbcDir[cbcId][1];
18831 MInt dimT1 = m_cbcDir[cbcId][2];
18832 MInt dimT2 = m_cbcDir[cbcId][nDim];
18834 MFloat& targetPressure = m_static_cbc1099_1091_local_targetPressure;
18835 MFloat& R = m_static_cbc1099_1091_local_R;
18836 MFloat& H = m_static_cbc1099_1091_local_H;
18838 MFloat inflowArea = m_cbcInflowArea[cbcId];
18839 IF_CONSTEXPR(nDim == 3) { R = sqrt(inflowArea / PI); }
18840 IF_CONSTEXPR(nDim == 2) {
18841 targetPressure = sysEqn().p_Ref();
18842 H = inflowArea * F1B2;
18845 MInt last = nDim + 1;
18847 if(last != 4)
mTerm(1, AT_,
"Last is not four!");
18855 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
18858 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
18861 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
18862 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
18871 MFloat massflux_pos = F0;
18872 MFloat massflux_neg = F0;
18874 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18875 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18876 MInt bndryId = m_solver->a_bndryId(cellId);
18878 if(m_solver->a_isHalo(cellId))
continue;
18879 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
18880 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18884 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
18886 area = m_solver->a_surfaceArea(srfcId);
18887 IF_CONSTEXPR(nDim == 3) ASSERT(area <=
POW2(m_solver->c_cellLengthAtCell(cellId)),
"");
18889 mTerm(1, AT_,
"something went wrong!");
18892 IF_CONSTEXPR(nDim == 2) area = m_solver->c_cellLengthAtCell(cellId);
18893 IF_CONSTEXPR(nDim == 3) area =
POW2(m_solver->c_cellLengthAtCell(cellId));
18896 ASSERT(area > -1,
"");
18897 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
18898 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
18899 const MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
18900 const MFloat Temp = sysEqn().temperature_ES(rho, p);
18901 MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
18902 const MFloat un_N = m_solver->a_pvariable(nghbrN, PV->VV[dimN]);
18905 if(rho < F0 || std::isnan(rho) || std::isnan(un)) {
18906 cerr <<
"NAN detected in cutOff-Cell " << m_solver->c_globalId(cellId) <<
" " << m_solver->a_isHalo(cellId) <<
" "
18907 << m_solver->a_bndryId(cellId) <<
" " << rho << endl;
18911 massflux_pos += un_N * area;
18913 massflux_neg += un_N * area;
18916 massflux += un_N * area * rho;
18917 T_mean += Temp * area;
18920 MFloat mach[2] = {F0, F0};
18921 cbcMachCo(bcId, mach);
18925 MInt noExchangeData = 4;
18928 comm_buff[0] = massflux;
18929 comm_buff[1] = T_mean;
18930 comm_buff[2] = massflux_pos;
18931 comm_buff[3] = massflux_neg;
18933 MPI_Allreduce(&comm_buff[0], &comm_buff_result[0], 4, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
18934 AT_,
"comm_buff[0]",
"comm_buff_result[0]");
18936 massflux = comm_buff_result[0];
18937 T_mean = comm_buff_result[1];
18938 massflux_pos = comm_buff_result[2];
18939 massflux_neg = comm_buff_result[3];
18941 T_mean /= inflowArea;
18943 const MFloat gammaMinusOne = m_solver->m_gamma - 1.0;
18945 MFloat T_target = 1 - gammaMinusOne * F1B2 * (massflux * massflux / inflowArea / inflowArea);
18946 MFloat p_Target = sysEqn().pressure_IR(T_target);
18948 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
18949 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
18951 if(m_solver->a_isHalo(cellId))
continue;
18952 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
18953 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
18955 MInt bndryId = m_solver->a_bndryId(cellId);
18957 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
18960 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
18963 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
18964 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
18965 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
18966 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
18967 &cutOffStencilCellIds[0], &V[0]);
18970 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
18973 MFloat un_mean = m_solver->a_pvariable(cellId, PV->VV[dimN]);
18975 MBool hasBndryNghbr =
false;
18976 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
18977 MInt recNghbr = m_solver->a_reconstructionNeighborId(cellId, nghbr);
18978 if(m_solver->a_bndryId(recNghbr) > -1) hasBndryNghbr =
true;
18981 MFloat massFluxSum = (abs(massflux_neg) + abs(massflux_pos));
18982 MFloat negMassFluxFactor = F0;
18983 MFloat posMassFluxFactor = F0;
18984 if(massFluxSum > m_solver->m_eps) {
18985 negMassFluxFactor = abs(massflux_neg) / massFluxSum;
18986 posMassFluxFactor = abs(massflux_pos) / massFluxSum;
18988 if(dirN % 2 == 0) {
18989 negMassFluxFactor = F1;
18991 posMassFluxFactor = F1;
18995 MBool isInflow =
true;
18996 if(dirN % 2 == 0) {
19000 T_target = negMassFluxFactor * T_target + posMassFluxFactor * T_mean;
19006 T_target = posMassFluxFactor * T_target + posMassFluxFactor * T_mean;
19010 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
19011 const MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
19012 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
19013 MFloat a = sysEqn().speedOfSound(rho, p);
19014 const MFloat Temp = sysEqn().temperature_ES(rho, p);
19017 targetPressure = p_Target;
19020 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
19021 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
19024 K[0] = K[0] * m_cbcLref[cbcId] / LN;
19025 K[1] = K[1] * m_cbcLref[cbcId] / LN;
19026 K[2] = K[2] * m_cbcLref[cbcId] / LN * 100;
19027 K[last] = K[last] * m_cbcLref[cbcId] / LN;
19036 if((m_solver->a_bndryId(cellId) > -1 || hasBndryNghbr) &&
false) {
19037 if(dirN % 2 == 0) {
19038 L[0] = K[0] * (p - targetPressure);
19040 L[last] = K[last] * (p - targetPressure);
19042 L[1] = K[1] * (Temp - T_target);
19044 IF_CONSTEXPR(nDim == 3) {
19045 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
19049 if(dirN % 2 == 0) {
19050 L[0] = K[0] * (p - targetPressure) + (beta - 1) * (T[last] + ceta * rho *
a * T[1])
19051 + (V[last] + ceta * rho *
a * V[1]);
19053 L[last] = K[last] * (p - targetPressure) + (beta - 1) * (T[last] + ceta * rho *
a * T[1])
19054 + (V[last] + ceta * rho *
a * V[1]);
19057 L[1] = K[1] * (Temp - T_target) - (
a *
a * T[0] - T[last]) + (
a *
a * V[0] - V[last]);
19058 L[2] = K[2] * ut1 - T[2] * 0.9;
19059 IF_CONSTEXPR(nDim == 3) {
19060 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
19061 K[3] = K[3] * m_cbcLref[cbcId] / LN * 100;
19062 L[3] = K[3] * ut2 - T[3] * 0.9;
19066 targetPressure = sysEqn().p_Ref();
19069 cbcOutgoingAmplitudeVariation<0>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
19070 cbcDampingOutflow(cellId, bcId, maxM, &K[0]);
19074 K[0] = K[0] * m_cbcLref[cbcId] * m_sigmaNonRefl / LN;
19075 K[2] = m_cbcRelax[cbcId][2] *
a / LN * 10;
19083 MFloat deltaP = (p - targetPressure);
19084 MFloat tmpP = sysEqn().pressure_ES(T_mean, rho) - targetPressure;
19085 if((m_solver->a_bndryId(cellId) > -1 || hasBndryNghbr)) {
19086 if(tmpP > deltaP) deltaP = tmpP;
19088 L[0] = K[0] * (deltaP);
19090 L[last] = K[0] * (deltaP);
19093 if(tmpP > deltaP) deltaP = tmpP;
19094 if(dirN % 2 == 0) {
19095 L[0] = K[0] * (deltaP) + (beta - 1) * (T[last] + ceta * rho *
a * T[1]) + (V[last] + ceta * rho *
a * V[0]);
19098 K[0] * (deltaP) + (beta - 1) * (T[last] + ceta * rho *
a * T[1]) + (V[last] + ceta * rho *
a * V[1]);
19101 IF_CONSTEXPR(nDim == 3) {
19102 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
19103 L[2] += K[2] * ut1;
19104 L[3] += K[2] * ut2;
19108 IF_CONSTEXPR(nDim == 3) {
19109 if((m_solver->a_bndryId(cellId) > -1 || hasBndryNghbr)) {
19122 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
19132template <MInt nDim,
class SysEqn>
19136 if(m_sortedCutOffCells[bcId]->size() == 0) {
19140 MInt cbcId = m_cbcBndryCndIds[bcId];
19142 MInt dirN = m_cbcDir[cbcId][0];
19143 MInt dimN = m_cbcDir[cbcId][1];
19144 MInt dimT1 = m_cbcDir[cbcId][2];
19145 MInt dimT2 = m_cbcDir[cbcId][nDim];
19147 MFloat outFlowArea = m_cbcInflowArea[cbcId];
19149 MInt last = nDim + 1;
19167 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
19168 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
19169 MInt bndryId = m_solver->a_bndryId(cellId);
19171 if(m_solver->a_isHalo(cellId))
continue;
19172 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
19173 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
19179 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
19181 area = m_solver->a_surfaceArea(srfcId);
19183 mTerm(1, AT_,
"something went wrong!");
19186 IF_CONSTEXPR(nDim == 3) area =
POW2(m_solver->c_cellLengthAtCell(cellId));
19187 IF_CONSTEXPR(nDim == 2) area = m_solver->c_cellLengthAtCell(cellId);
19190 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
19191 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
19192 const MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
19193 const MFloat Temp = sysEqn().temperature_ES(rho, p);
19195 massflux += un * area * rho;
19196 T_mean += Temp * area;
19197 IF_CONSTEXPR(nDim == 2) rho_mean += rho * area;
19200 MFloat mach[2] = {F0, F0};
19201 cbcMachCo(bcId, mach);
19205 MInt noExchangeData = 2;
19208 comm_buff[0] = massflux;
19209 comm_buff[1] = T_mean;
19212 MPI_Allreduce(&comm_buff[0], &comm_buff_result[0], 2, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
19213 AT_,
"comm_buff[0]",
"comm_buff_result[0]");
19215 IF_CONSTEXPR(nDim == 2) {
19216 MPI_Allreduce(MPI_IN_PLACE, &rho_mean, 1, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
19217 "MPI_IN_PLACE",
"rho_mean");
19218 rho_mean /= outFlowArea;
19220 const MFloat gammaMinusOne = m_solver->m_gamma - 1.0;
19221 MFloat T_target = 1 - gammaMinusOne * F1B2 * (massflux * massflux / outFlowArea / outFlowArea);
19222 MFloat p_Target = sysEqn().pressure_ES(T_target, rho_mean);
19223 MFloat p_test = p_Target;
19224 for(
MInt i = 0; i < 20; i++) {
19225 p_test = sysEqn().pressure_IRit(p_test, massflux);
19227 m_solver->m_jetPressure = p_Target;
19228 m_solver->m_jetDensity = rho_mean;
19229 m_solver->m_jetTemperature = T_target;
19232 massflux = comm_buff_result[0];
19233 T_mean = comm_buff_result[1];
19234 T_mean /= outFlowArea;
19236 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->
size() : 1;
19239 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
19242 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
19243 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
19245 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
19246 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
19248 if(m_solver->a_isHalo(cellId))
continue;
19249 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
19250 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
19252 MInt bndryId = m_solver->a_bndryId(cellId);
19254 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
19257 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
19260 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
19261 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
19262 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
19263 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
19264 &cutOffStencilCellIds[0], &V[0]);
19267 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
19270 MFloat un_mean = m_solver->a_pvariable(cellId, PV->VV[dimN]);
19271 MFloat T_target_new = 0.0;
19273 MBool isInflow =
true;
19274 if(dirN % 2 == 0) {
19278 T_target_new = T_mean;
19284 T_target_new = T_mean;
19288 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
19289 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
19290 MFloat a = sysEqn().speedOfSound(rho, p);
19291 const MFloat Temp = sysEqn().temperature_ES(rho, p);
19293 const MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
19298 targetPressure = 0.0;
19301 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
19302 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
19304 IF_CONSTEXPR(nDim == 3) {
19316 if(dirN % 2 == 0) {
19317 L[0] = K[0] * (p - targetPressure) + (beta - 1) * (T[last] + ceta * rho *
a * T[1])
19318 + (V[last] + ceta * rho *
a * V[1]);
19320 L[last] = K[last] * (p - targetPressure) + (beta - 1) * (T[last] + ceta * rho *
a * T[1])
19321 + (V[last] + ceta * rho *
a * V[1]);
19324 L[1] = K[1] * (Temp - T_target_new) - (
a *
a * T[0] - T[last]) + (
a *
a * V[0] - V[last]);
19326 IF_CONSTEXPR(nDim == 3) {
19327 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
19331 targetPressure = sysEqn().p_Ref();
19334 cbcOutgoingAmplitudeVariation<0>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
19335 cbcDampingOutflow(cellId, bcId, maxM, &K[0]);
19337 IF_CONSTEXPR(nDim == 3) {
19341 K[0] = K[0] * m_sigmaNonRefl;
19350 MFloat deltaP = (p - targetPressure);
19352 if(dirN % 2 == 0) {
19353 L[0] = K[0] * (deltaP) + (beta - 1) * (T[last] + ceta * rho *
a * T[1]) + (V[last] + ceta * rho *
a * V[0]);
19355 L[last] = K[0] * (deltaP) + (beta - 1) * (T[last] + ceta * rho *
a * T[1]) + (V[last] + ceta * rho *
a * V[1]);
19358 IF_CONSTEXPR(nDim == 3) {
19359 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
19363 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
19370template <MInt nDim,
class SysEqn>
19374 const MInt noVars = PV->noVariables;
19376 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
19377 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
19380 for(
MInt varId = 0; varId < noVars; varId++) {
19381 for(
MInt i = 0; i < nDim; i++) {
19382 m_solver->a_slope(cellId, varId, i) = F0;
19392template <MInt nDim,
class SysEqn>
19395 const MUint noVars = CV->noVariables;
19396 const MInt*
const RESTRICT sortedBndryIds = ALIGNED_I(m_sortedBndryCells->a);
19397 const MInt*
const RESTRICT bndryCndIds = m_bndryCndIds;
19399 const MInt firstBndryCell = m_bndryCndCells[bcId];
19400 const MInt lastBndryCell = m_bndryCndCells[bcId + 1];
19403#pragma omp parallel for
19405 for(
MInt id = firstBndryCell;
id < lastBndryCell; ++
id) {
19406 MInt bndryId = sortedBndryIds[
id];
19408 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
19412 m_bndryCells->a[bndryId].m_srfcVariables[0];
19413 for(
MUint srfc = 0; srfc < noSrfcs; ++srfc) {
19414 if(cellSurfaces[srfc].m_bndryCndId == bndryCndIds[bcId]) {
19416 MFloat*
const RESTRICT ghostCellSlopes = ALIGNED_MF(&m_solver->a_slope(ghostCellId, 0, 0));
19417 const MFloat*
const RESTRICT cellSlopes = ALIGNED_F(&m_solver->a_slope(cellId, 0, 0));
19419 for(
MUint varId = 0; varId < noVars; ++varId) {
19420 for(
MInt spaceId = 0; spaceId < nDim; spaceId++) {
19421 ghostCellSlopes[varId * nDim + spaceId] = cellSlopes[varId * nDim + spaceId];
19433template <MInt nDim,
class SysEqn>
19437 const MInt noVars = PV->noVariables;
19438 const MInt otherDir[6] = {1, 0, 3, 2, 5, 4};
19440 MBool& first = m_static_sbc1000co_first;
19441 const MInt fixedMaxNoBndryCndIds = s_sbc1000co_fixedMaxNoBndryCndIds;
19442 MInt(&directions)[fixedMaxNoBndryCndIds] = m_static_sbc1000co_directions;
19444 if(fixedMaxNoBndryCndIds < m_maxNoBndryCndIds) {
19445 mTerm(1, AT_,
"fixedMaxNoBndryCndIds is too small. increase...");
19450 if(noCutOffDirections != noCutOffBndryIds) {
19452 "Wrong number of cut off directions. Must be identical to number of cut off bndryIds! Please check!");
19454 MInt cutOffBndryIdTmp, cutOffDirectionTmp;
19455 for(
MInt bc = 0; bc < m_noCutOffBndryCndIds; bc++) {
19456 for(
MInt i = 0; i < noCutOffBndryIds; i++) {
19457 cutOffBndryIdTmp = Context::getSolverProperty<MInt>(
"cutOffBndryIds", m_solverId, AT_, i);
19458 cutOffDirectionTmp = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, i);
19459 if(cutOffBndryIdTmp == m_cutOffBndryCndIds[bc]) {
19460 directions[bc] = otherDir[cutOffDirectionTmp];
19470 const MInt direction = directions[bcId];
19472 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
19473 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
19474 MLong nghbrId = m_solver->c_neighborId(cellId, direction);
19478 TERMM_IF_NOT_COND(m_solver->a_isHalo(cellId),
"Error: cell has no neighbor and is not a halo cell.");
19482 if(m_solver->a_hasProperty(nghbrId, SolverCell::IsInactive))
continue;
19484 if(m_solver->a_hasProperty(nghbrId, SolverCell::IsOnCurrentMGLevel)) {
19486 for(
MInt varId = 0; varId < noVars; varId++) {
19487 for(
MInt i = 0; i < nDim; i++) {
19488 m_solver->a_slope(cellId, varId, i) = m_solver->a_slope(nghbrId, varId, i);
19499template <MInt nDim,
class SysEqn>
19504 MInt ghostCellId = 0;
19505 const MInt noVars = PV->noVariables;
19508 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
19509 cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
19510 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
19511 ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[0]->m_ghostCellId;
19514 for(
MInt varId = 0; varId < noVars; varId++) {
19515 m_solver->a_slope(ghostCellId, varId, 0) = m_solver->a_slope(cellId, varId, 0);
19516 m_solver->a_slope(ghostCellId, varId, 1) = -m_solver->a_slope(cellId, varId, 1);
19529template <MInt nDim,
class SysEqn>
19533 if(m_sortedCutOffCells[bcId]->size() == 0) {
19537 MInt cbcId = m_cbcBndryCndIds[bcId];
19539 MInt dirN = m_cbcDir[cbcId][0];
19540 MInt dimN = m_cbcDir[cbcId][1];
19541 MInt dimT1 = m_cbcDir[cbcId][2];
19543 MInt last = nDim + 1;
19556 MFloat mach[2] = {F0, F0};
19557 cbcMachCo(bcId, mach);
19560 const MFloat gammaMinusOne = m_solver->m_gamma - 1.0;
19562 MFloat T_target = sysEqn().temperature_IR(m_solver->m_Ma);
19564 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
19565 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
19567 if(m_solver->a_isHalo(cellId))
continue;
19568 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
19569 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
19571 MInt bndryId = m_solver->a_bndryId(cellId);
19574 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
19577 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
19579 gradVV[dimN * nDim + dimT1] = F0;
19580 gradVV[dimT1 * nDim + dimT1] = F0;
19582 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
19583 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
19585 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"velocity");
19587 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
19588 MFloat p = m_solver->a_pvariable(cellId, PV->P);
19589 MFloat a = sysEqn().speedOfSound(rho, p);
19591 MFloat un_target = m_solver->m_UInfinity;
19594 if(dirN % 2 == 0) {
19595 L[0] = L[last] + (T[last] - rho *
a * T[1]);
19597 L[last] = L[0] + (T[last] + rho *
a * T[1]);
19600 L[1] = F1B2 * gammaMinusOne * (L[0] + L[last]) + (
a *
a * T[0] - T[last]);
19603 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
19605 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimN]) = F0;
19606 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT1]) = F0;
19607 m_solver->a_rightHandSide(cellId, CV->RHO_E) = F0;
19609 m_solver->a_pvariable(cellId, PV->VV[dimN]) = un_target;
19610 m_solver->a_pvariable(cellId, PV->VV[dimT1]) = ut1_target;
19611 m_solver->a_pvariable(cellId, PV->P) = T_target;
19617template <MInt nDim,
class SysEqn>
19619 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function cbc1091e_after is untested for 3D!"); }
19622 if(m_sortedCutOffCells[bcId]->size() == 0)
return;
19624 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
19625 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
19627 if(m_solver->a_isHalo(cellId))
continue;
19628 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
19629 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
19631 MInt bndryId = m_solver->a_bndryId(cellId);
19634 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
19638 MFloat rho = m_solver->a_variable(cellId, CV->RHO);
19639 MFloat u = m_solver->a_pvariable(cellId, PV->VV[0]);
19640 MFloat v = m_solver->a_pvariable(cellId, PV->VV[1]);
19641 MFloat T = m_solver->a_pvariable(cellId, PV->P);
19642 MFloat p = sysEqn().pressure_ES(T, rho);
19643 MFloat E = sysEqn().internalEnergy(p, rho, (u * u + v * v));
19645 m_solver->a_variable(cellId, CV->RHO_VV[0]) = rho * u;
19646 m_solver->a_variable(cellId, CV->RHO_VV[1]) = rho * v;
19647 m_solver->a_variable(cellId, CV->RHO_E) = E;
19655template <MInt nDim,
class SysEqn>
19659 MInt cbcId = m_cbcBndryCndIds[bcId];
19660 MInt dirN = m_cbcDir[cbcId][0];
19661 MInt dimN = m_cbcDir[cbcId][1];
19662 MInt dimT1 = m_cbcDir[cbcId][2];
19664 MFloat localMach[2] = {F0, F0};
19666 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
19667 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
19668 MInt bndryId = m_solver->a_bndryId(cellId);
19670 if(m_solver->a_isHalo(cellId))
continue;
19671 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
19672 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
19675 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
19677 area = m_solver->a_surfaceArea(srfcId);
19678 IF_CONSTEXPR(nDim == 3) ASSERT(area <=
POW2(m_solver->c_cellLengthAtCell(cellId)),
"");
19680 for(
MInt dir = 0; dir < m_noDirs; dir++) {
19681 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dir];
19682 if(srfcId > -1)
break;
19685 mTerm(1, AT_,
"something went wrong!");
19687 area = m_solver->a_surfaceArea(srfcId);
19690 IF_CONSTEXPR(nDim == 2) area = m_solver->c_cellLengthAtCell(cellId);
19691 IF_CONSTEXPR(nDim == 3) area =
POW2(m_solver->c_cellLengthAtCell(cellId));
19694 area *= m_dirTangent[cbcId][dimT1];
19696 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
19697 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
19698 const MFloat T = sysEqn().temperature_ES(rho, p);
19699 const MFloat a = sysEqn().speedOfSound(T);
19701 MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]) * m_dirNormal[cbcId][dimN]
19702 + m_solver->a_pvariable(cellId, PV->VV[dimT1]) * m_dirNormal[cbcId][dimT1];
19703 IF_CONSTEXPR(nDim == 3) {
19704 MInt dimT2 = m_cbcDir[cbcId][nDim];
19705 un += m_solver->a_pvariable(cellId, PV->VV[dimT2]) * m_dirNormal[cbcId][dimT2];
19708 const MFloat M = fabs(un /
a);
19710 localMach[0] += fabs(M) * area;
19711 localMach[1] =
mMax(localMach[1], M);
19714 MFloat globalMach[2] = {F0, F0};
19716 if(m_solver->noDomains() > 1) {
19717 MPI_Allreduce(&localMach[0], &globalMach[0], 1, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
19718 "localMeanMach",
"globalMeanMach");
19719 MPI_Allreduce(&localMach[1], &globalMach[1], 1, MPI_DOUBLE, MPI_MAX, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
19720 "localMaxMach",
"globalMaxMach");
19723 MFloat inflowArea = m_cbcInflowArea[cbcId];
19724 globalMach[0] /= inflowArea;
19726 mach[0] = globalMach[0];
19727 mach[1] = globalMach[1];
19736template <MInt nDim,
class SysEqn>
19740 auto index = [&](
MInt dim0,
MInt dim1,
MInt dim2) {
return dim0 * (nDim * nDim) + dim1 * nDim + dim2; };
19742 MInt cbcId = m_cbcBndryCndIds[bcId];
19744 MInt dimN = m_cbcDir[cbcId][1];
19745 MInt dimT1 = m_cbcDir[cbcId][2];
19747 for(
MInt i = 0; i < m_solver->maxNoGridCells(); i++) {
19748 cutOffStencilCellIds[i] = -1;
19751 MInt cellCounter = 0;
19752 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
19753 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
19755 if(m_solver->a_isHalo(cellId))
continue;
19756 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
19757 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
19759 MInt bndryId = m_solver->a_bndryId(cellId);
19761 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
19764 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
19765 MFloat p = m_solver->a_pvariable(cellId, PV->P);
19766 MFloat T = sysEqn().temperature_ES(rho, p);
19768 if(cutOffStencilCellIds[cellId] < 0) {
19769 MInt coId = cellCounter++;
19770 cutOffStencilCellIds[cellId] = coId;
19772 MFloat dpdn = m_solver->a_slope(cellId, PV->P, dimN);
19773 MFloat dpdt1 = m_solver->a_slope(cellId, PV->P, dimT1);
19774 MFloat drhodn = m_solver->a_slope(cellId, PV->RHO, dimN);
19775 MFloat drhodt1 = m_solver->a_slope(cellId, PV->RHO, dimT1);
19776 MFloat dundn = m_solver->a_slope(cellId, PV->VV[dimN], dimN);
19777 MFloat dundt1 = m_solver->a_slope(cellId, PV->VV[dimN], dimT1);
19778 MFloat dut1dn = m_solver->a_slope(cellId, PV->VV[dimT1], dimN);
19779 MFloat dut1dt1 = m_solver->a_slope(cellId, PV->VV[dimT1], dimT1);
19781 const MFloat mu = sysEqn().sutherlandLaw(T);
19782 MFloat divT = dundn + dut1dt1;
19783 IF_CONSTEXPR(nDim == 3) {
19784 MInt dimT2 = m_cbcDir[cbcId][nDim];
19785 MFloat dpdt2 = m_solver->a_slope(cellId, PV->P, dimT2);
19786 MFloat drhodt2 = m_solver->a_slope(cellId, PV->RHO, dimT2);
19787 MFloat dundt2 = m_solver->a_slope(cellId, PV->VV[dimN], dimT2);
19788 MFloat dut1dt2 = m_solver->a_slope(cellId, PV->VV[dimT1], dimT2);
19789 MFloat dut2dn = m_solver->a_slope(cellId, PV->VV[dimT2], dimN);
19790 MFloat dut2dt1 = m_solver->a_slope(cellId, PV->VV[dimT2], dimT1);
19791 MFloat dut2dt2 = m_solver->a_slope(cellId, PV->VV[dimT2], dimT2);
19792 divT = divT + dut2dt2;
19794 tau[index(coId, dimN, dimT2)] = mu * (dundt2 + dut2dn);
19795 tau[index(coId, dimT2, dimN)] = tau[index(coId, dimN, dimT2)];
19796 tau[index(coId, dimT1, dimT2)] = mu * (dut1dt2 + dut2dt1);
19797 tau[index(coId, dimT2, dimT2)] = mu * (F2 * dut2dt2 - F2B3 * divT);
19798 tau[index(coId, dimT2, dimT1)] = tau[index(coId, dimT1, dimT2)];
19800 q[index(0, coId, dimT2)] =
19801 mu * m_solver->m_gamma * sysEqn().cp_Ref() / (m_solver->m_Pr * rho) * (dpdt2 - p / rho * drhodt2);
19804 tau[index(coId, dimN, dimN)] = mu * (F2 * dundn - F2B3 * divT);
19805 tau[index(coId, dimN, dimT1)] = mu * (dundt1 + dut1dn);
19806 tau[index(coId, dimT1, dimN)] = tau[index(coId, dimN, dimT1)];
19807 tau[index(coId, dimT1, dimT1)] = mu * (F2 * dut1dt1 - F2B3 * divT);
19809 q[index(0, coId, dimN)] =
19810 mu * m_solver->m_gamma * sysEqn().cp_Ref() / (m_solver->m_Pr * rho) * (dpdn - p / rho * drhodn);
19811 q[index(0, coId, dimT1)] =
19812 mu * m_solver->m_gamma * sysEqn().cp_Ref() / (m_solver->m_Pr * rho) * (dpdt1 - p / rho * drhodt1);
19815 for(
MInt recN = 0; recN < m_solver->a_noReconstructionNeighbors(cellId); recN++) {
19816 MInt recNgbhr = m_solver->a_reconstructionNeighborId(cellId, recN);
19817 if(cutOffStencilCellIds[recNgbhr] < 0) {
19818 MInt coIdN = cellCounter++;
19819 cutOffStencilCellIds[recNgbhr] = coIdN;
19821 MFloat pG = m_solver->a_pvariable(recNgbhr, PV->P);
19822 MFloat rhoG = m_solver->a_pvariable(recNgbhr, PV->RHO);
19823 MFloat TG = sysEqn().temperature_ES(rhoG, pG);
19824 MFloat muG = sysEqn().sutherlandLaw(TG);
19825 MFloat dpdnG = m_solver->a_slope(recNgbhr, PV->P, dimN);
19826 MFloat dpdt1G = m_solver->a_slope(recNgbhr, PV->P, dimT1);
19827 MFloat drhodnG = m_solver->a_slope(recNgbhr, PV->RHO, dimN);
19828 MFloat drhodt1G = m_solver->a_slope(recNgbhr, PV->RHO, dimT1);
19829 MFloat dundnG = m_solver->a_slope(recNgbhr, PV->VV[dimN], dimN);
19830 MFloat dundt1G = m_solver->a_slope(recNgbhr, PV->VV[dimN], dimT1);
19831 MFloat dut1dnG = m_solver->a_slope(recNgbhr, PV->VV[dimT1], dimN);
19832 MFloat dut1dt1G = m_solver->a_slope(recNgbhr, PV->VV[dimT1], dimT1);
19834 MFloat divTG = dundnG + dut1dt1G;
19836 IF_CONSTEXPR(nDim == 3) {
19837 MInt dimT2 = m_cbcDir[cbcId][nDim];
19838 MFloat dpdt2G = m_solver->a_slope(recNgbhr, PV->P, dimT2);
19839 MFloat drhodt2G = m_solver->a_slope(recNgbhr, PV->RHO, dimT2);
19840 MFloat dundt2G = m_solver->a_slope(recNgbhr, PV->VV[dimN], dimT2);
19841 MFloat dut1dt2G = m_solver->a_slope(recNgbhr, PV->VV[dimT1], dimT2);
19842 MFloat dut2dnG = m_solver->a_slope(recNgbhr, PV->VV[dimT2], dimN);
19843 MFloat dut2dt1G = m_solver->a_slope(recNgbhr, PV->VV[dimT2], dimT1);
19844 MFloat dut2dt2G = m_solver->a_slope(recNgbhr, PV->VV[dimT2], dimT2);
19845 divTG = divTG + dut2dt2G;
19847 tau[index(coIdN, dimN, dimT2)] = muG * (dundt2G + dut2dnG);
19848 tau[index(coIdN, dimT2, dimN)] = tau[index(coIdN, dimN, dimT2)];
19849 tau[index(coIdN, dimT2, dimT2)] = muG * (2 * dut2dt2G - F2B3 * divTG);
19850 tau[index(coIdN, dimT1, dimT2)] = muG * (dut1dt2G + dut2dt1G);
19851 tau[index(coIdN, dimT2, dimT1)] = tau[index(coIdN, dimT1, dimT2)];
19853 q[index(0, coIdN, dimT2)] =
19854 muG * m_solver->m_gamma * sysEqn().cp_Ref() / (m_solver->m_Pr * rhoG) * (dpdt2G - pG / rhoG * drhodt2G);
19857 tau[index(coIdN, dimN, dimN)] = muG * (F2 * dundnG - F2B3 * divTG);
19858 tau[index(coIdN, dimN, dimT1)] = muG * (dundt1G + dut1dnG);
19859 tau[index(coIdN, dimT1, dimN)] = tau[index(coIdN, dimN, dimT1)];
19860 tau[index(coIdN, dimT1, dimT1)] = muG * (2 * dut1dt1G - F2B3 * divTG);
19862 q[index(0, coIdN, dimN)] =
19863 muG * m_solver->m_gamma * sysEqn().cp_Ref() / (m_solver->m_Pr * rhoG) * (dpdnG - pG / rhoG * drhodnG);
19864 q[index(0, coIdN, dimT1)] =
19865 muG * m_solver->m_gamma * sysEqn().cp_Ref() / (m_solver->m_Pr * rhoG) * (dpdt1G - pG / rhoG * drhodt1G);
19874template <MInt nDim,
class SysEqn>
19876 MFloat* gradQ,
MInt* cutOffStencilCellIds) {
19879 auto index = [&](
MInt dim0,
MInt dim1,
MInt dim2) {
return dim0 * (nDim * nDim) + dim1 * nDim + dim2; };
19881 MInt cbcId = m_cbcBndryCndIds[bcId];
19883 MInt dimN = m_cbcDir[cbcId][1];
19884 MInt dimT1 = m_cbcDir[cbcId][2];
19886 MInt coId = cutOffStencilCellIds[cellId];
19887 MInt recData = m_solver->a_reconstructionData(cellId);
19888 for(
MInt nghbr = 0; nghbr < m_solver->a_noReconstructionNeighbors(cellId); nghbr++) {
19889 MInt recNghbr = m_solver->a_reconstructionNeighborId(cellId, nghbr);
19890 MInt coIdN = cutOffStencilCellIds[recNghbr];
19891 for(
MInt i = 0; i < nDim; i++) {
19892 MFloat recConst = m_solver->m_reconstructionConstants[nDim * (recData + nghbr) + i];
19893 gradTau[index(dimN, dimN, i)] += recConst * (tau[index(coIdN, dimN, dimN)] - tau[index(coId, dimN, dimN)]);
19894 gradTau[index(dimN, dimT1, i)] += recConst * (tau[index(coIdN, dimN, dimT1)] - tau[index(coId, dimN, dimT1)]);
19895 gradTau[index(dimT1, dimT1, i)] += recConst * (tau[index(coIdN, dimT1, dimT1)] - tau[index(coId, dimT1, dimT1)]);
19896 gradQ[index(0, dimN, i)] += recConst * (q[index(0, coIdN, dimN)] - q[index(0, coId, dimN)]);
19897 gradQ[index(0, dimT1, i)] += recConst * (q[index(0, coIdN, dimT1)] - q[index(0, coId, dimT1)]);
19898 IF_CONSTEXPR(nDim == 3) {
19899 MInt dimT2 = m_cbcDir[cbcId][nDim];
19900 gradTau[index(dimN, dimT2, i)] += recConst * (tau[index(coIdN, dimN, dimT2)] - tau[index(coId, dimN, dimT2)]);
19901 gradTau[index(dimT1, dimT2, i)] +=
19902 recConst * (tau[index(coIdN, dimT1, dimT2)] - tau[index(coId, dimT1, dimT2)]);
19903 gradTau[index(dimT2, dimT2, i)] +=
19904 recConst * (tau[index(coIdN, dimT2, dimT2)] - tau[index(coId, dimT2, dimT2)]);
19905 gradQ[index(0, dimT2, i)] += recConst * (q[index(0, coIdN, dimT2)] - q[index(0, coId, dimT2)]);
19915template <MInt nDim,
class SysEqn>
19920 MInt cbcId = m_cbcBndryCndIds[bcId];
19922 MInt dimN = m_cbcDir[cbcId][1];
19923 MInt dimT1 = m_cbcDir[cbcId][2];
19924 MInt dimT2 = m_cbcDir[cbcId][nDim];
19926 gradRho[dimN] = m_solver->a_slope(cellId, PV->RHO, dimN) * m_dirNormal[cbcId][dimN]
19927 + m_solver->a_slope(cellId, PV->RHO, dimT1) * m_dirNormal[cbcId][dimT1];
19928 gradRho[dimT1] = m_solver->a_slope(cellId, PV->RHO, dimN) * m_dirTangent[cbcId][dimN]
19929 + m_solver->a_slope(cellId, PV->RHO, dimT1) * m_dirTangent[cbcId][dimT1];
19931 gradVV[dimN * nDim + dimN] = m_solver->a_slope(cellId, PV->VV[dimN], dimN) * m_dirNormal[cbcId][dimN]
19932 + m_solver->a_slope(cellId, PV->VV[dimN], dimT1) * m_dirNormal[cbcId][dimT1];
19933 gradVV[dimN * nDim + dimT1] = m_solver->a_slope(cellId, PV->VV[dimN], dimN) * m_dirTangent[cbcId][dimN]
19934 + m_solver->a_slope(cellId, PV->VV[dimN], dimT1) * m_dirTangent[cbcId][dimT1];
19935 gradVV[dimT1 * nDim + dimN] = m_solver->a_slope(cellId, PV->VV[dimT1], dimN) * m_dirNormal[cbcId][dimN]
19936 + m_solver->a_slope(cellId, PV->VV[dimT1], dimT1) * m_dirNormal[cbcId][dimT1];
19937 gradVV[dimT1 * nDim + dimT1] = m_solver->a_slope(cellId, PV->VV[dimT1], dimN) * m_dirTangent[cbcId][dimN]
19938 + m_solver->a_slope(cellId, PV->VV[dimT1], dimT1) * m_dirTangent[cbcId][dimT1];
19940 gradP[dimN] = m_solver->a_slope(cellId, PV->P, dimN) * m_dirNormal[cbcId][dimN]
19941 + m_solver->a_slope(cellId, PV->P, dimT1) * m_dirNormal[cbcId][dimT1];
19942 gradP[dimT1] = m_solver->a_slope(cellId, PV->P, dimN) * m_dirTangent[cbcId][dimN]
19943 + m_solver->a_slope(cellId, PV->P, dimT1) * m_dirTangent[cbcId][dimT1];
19945 if(m_solver->m_noSpecies > 0) {
19946 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
19947 gradY[s * nDim + dimN] = m_solver->a_slope(cellId, PV->Y[s], dimN) * m_dirNormal[cbcId][dimN]
19948 + m_solver->a_slope(cellId, PV->Y[s], dimT1) * m_dirNormal[cbcId][dimT1];
19949 gradY[s * nDim + dimT1] = m_solver->a_slope(cellId, PV->Y[s], dimN) * m_dirTangent[cbcId][dimN]
19950 + m_solver->a_slope(cellId, PV->Y[s], dimT1) * m_dirNormal[cbcId][dimT1];
19954 IF_CONSTEXPR(nDim == 3) {
19955 gradRho[dimN] += m_solver->a_slope(cellId, PV->RHO, dimT2) * m_dirNormal[cbcId][dimT2];
19956 gradRho[dimT1] += m_solver->a_slope(cellId, PV->RHO, dimT2) * m_dirTangent[cbcId][dimT2];
19957 gradRho[dimT2] = m_solver->a_slope(cellId, PV->RHO, dimT2);
19959 gradVV[dimN * nDim + dimN] += m_solver->a_slope(cellId, PV->VV[dimN], dimT2) * m_dirNormal[cbcId][dimT2];
19960 gradVV[dimN * nDim + dimT1] += m_solver->a_slope(cellId, PV->VV[dimN], dimT2) * m_dirTangent[cbcId][dimT2];
19961 gradVV[dimN * nDim + dimT2] = m_solver->a_slope(cellId, PV->VV[dimN], dimT2);
19962 gradVV[dimT1 * nDim + dimN] += m_solver->a_slope(cellId, PV->VV[dimT1], dimT2) * m_dirNormal[cbcId][dimT2];
19963 gradVV[dimT1 * nDim + dimT1] += m_solver->a_slope(cellId, PV->VV[dimT1], dimT2) * m_dirTangent[cbcId][dimT2];
19964 gradVV[dimT1 * nDim + dimT2] = m_solver->a_slope(cellId, PV->VV[dimT1], dimT2);
19965 gradVV[dimT2 * nDim + dimN] = m_solver->a_slope(cellId, PV->VV[dimT2], dimN) * m_dirNormal[cbcId][dimN]
19966 + m_solver->a_slope(cellId, PV->VV[dimT2], dimT1) * m_dirNormal[cbcId][dimT1]
19967 + m_solver->a_slope(cellId, PV->VV[dimT2], dimT2) * m_dirNormal[cbcId][dimT2];
19968 gradVV[dimT2 * nDim + dimT1] = m_solver->a_slope(cellId, PV->VV[dimT2], dimN) * m_dirTangent[cbcId][dimN]
19969 + m_solver->a_slope(cellId, PV->VV[dimT2], dimT1) * m_dirTangent[cbcId][dimT1]
19970 + m_solver->a_slope(cellId, PV->VV[dimT2], dimT2) * m_dirTangent[cbcId][dimT2];
19971 gradVV[dimT2 * nDim + dimT2] = m_solver->a_slope(cellId, PV->VV[dimT2], dimT2);
19973 gradP[dimN] += m_solver->a_slope(cellId, PV->P, dimT2) * m_dirNormal[cbcId][dimT2];
19974 gradP[dimT1] += m_solver->a_slope(cellId, PV->P, dimT2) * m_dirTangent[cbcId][dimT2];
19975 gradP[dimT2] = m_solver->a_slope(cellId, PV->P, dimT2);
19976 if(m_solver->m_noSpecies > 0) {
19977 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
19978 gradY[s * nDim + dimN] += m_solver->a_slope(cellId, PV->Y[s], dimT2) * m_dirNormal[cbcId][dimT2];
19979 gradY[s * nDim + dimT1] += m_solver->a_slope(cellId, PV->Y[s], dimT2) * m_dirTangent[cbcId][dimT2];
19980 gradY[s * nDim + dimT2] = m_solver->a_slope(cellId, PV->Y[s], dimT2);
19992template <MInt nDim,
class SysEqn>
19993template <MInt s
ide>
19998 MInt cbcId = m_cbcBndryCndIds[bcId];
20000 MInt dimN = m_cbcDir[cbcId][1];
20001 MInt dimT1 = m_cbcDir[cbcId][2];
20002 MInt dimT2 = m_cbcDir[cbcId][nDim];
20004 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20006 un = m_solver->a_pvariable(cellId, PV->VV[dimN]) * m_dirNormal[cbcId][dimN]
20007 + m_solver->a_pvariable(cellId, PV->VV[dimT1]) * m_dirNormal[cbcId][dimT1];
20009 IF_CONSTEXPR(nDim == 3) { un += m_solver->a_pvariable(cellId, PV->VV[dimT2]) * m_dirNormal[cbcId][dimT2]; }
20011 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20012 MFloat a = sysEqn().speedOfSound(rho, p);
20014 MInt last = CV->noVariables - 1 - m_solver->m_noSpecies;
20019 L[0] = lambda1 * (gradP[dimN] - rho *
a * gradVV[dimN * nDim + dimN]);
20020 L[last] = lambda5 * (gradP[dimN] + rho *
a * gradVV[dimN * nDim + dimN]);
20021 IF_CONSTEXPR(nDim == 3) { L[3] = un * (gradVV[dimT2 * nDim + dimN]); }
20022 }
else if(side == 0) {
20026 L[0] = lambda1 * (gradP[dimN] - rho *
a * gradVV[dimN * nDim + dimN]);
20027 L[1] = lambda2 * (
a *
a * gradRho[dimN] - gradP[dimN]);
20028 L[2] = lambda2 * (gradVV[dimT1 * nDim + dimN]);
20029 IF_CONSTEXPR(nDim == 3) { L[3] = lambda2 * (gradVV[dimT2 * nDim + dimN]); }
20030 L[last] = lambda5 * (gradP[dimN] + rho *
a * gradVV[dimN * nDim + dimN]);
20031 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
20032 L[last + 1 + s] = lambda2 * gradY[s * nDim + dimN];
20035 mTerm(1, AT_,
"Wrong template argument");
20043template <MInt nDim,
class SysEqn>
20044template <
unsigned char tTerms>
20049 MInt cbcId = m_cbcBndryCndIds[bcId];
20051 MInt dimN = m_cbcDir[cbcId][1];
20052 MInt dimT1 = m_cbcDir[cbcId][2];
20053 MInt dimT2 = m_cbcDir[cbcId][nDim];
20055 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20058 ut1 = m_solver->a_pvariable(cellId, PV->VV[dimN]) * m_dirTangent[cbcId][dimN]
20059 + m_solver->a_pvariable(cellId, PV->VV[dimT1]) * m_dirTangent[cbcId][dimT1];
20062 IF_CONSTEXPR(nDim == 3) {
20063 ut1 += m_solver->a_pvariable(cellId, PV->VV[dimT2]) * m_dirTangent[cbcId][dimT2];
20064 ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
20067 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20069 MInt last = CV->noVariables - 1 - m_solver->m_noSpecies;
20072 T[0] = -rho * gradVV[dimT1 * nDim + dimT1] - ut1 * gradRho[dimT1];
20073 IF_CONSTEXPR(nDim == 3) T[0] += (-rho * gradVV[dimT2 * nDim + dimT2] - ut2 * gradRho[dimT2]);
20077 T[1] = -ut1 * gradVV[dimN * nDim + dimT1];
20078 IF_CONSTEXPR(nDim == 3) T[1] += (-ut2 * gradVV[dimN * nDim + dimT2]);
20082 T[2] = -ut1 * gradVV[dimT1 * nDim + dimT1] - F1 / rho * gradP[dimT1];
20083 IF_CONSTEXPR(nDim == 3) T[2] += (-ut2 * gradVV[dimT1 * nDim + dimT2]);
20086 IF_CONSTEXPR(nDim == 3) {
20088 T[3] = -ut1 * gradVV[dimT2 * nDim + dimT1] - ut2 * gradVV[dimT2 * nDim + dimT2] - F1 / rho * gradP[dimT2];
20093 T[last] = -ut1 * gradP[dimT1] - p * sysEqn().gamma_Ref() * gradVV[dimT1 * nDim + dimT1];
20094 IF_CONSTEXPR(nDim == 3) T[last] += (-ut2 * gradP[dimT2] - p * sysEqn().gamma_Ref() * gradVV[dimT2 * nDim + dimT2]);
20097 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
20098 T[last + 1 + s] = -ut1 * gradY[s * nDim + dimT1];
20099 IF_CONSTEXPR(nDim == 3) T[last + 1 + s] += -ut2 * gradY[s * nDim + dimT2];
20104template <MInt nDim,
class SysEqn>
20108 MInt cbcId = m_cbcBndryCndIds[bcId];
20109 MInt dirN = m_cbcDir[cbcId][0];
20111 MFloat localMeanPressure = F0;
20113 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
20114 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
20115 MInt bndryId = m_solver->a_bndryId(cellId);
20117 if(m_solver->a_isHalo(cellId))
continue;
20118 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
20119 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
20125 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
20127 area = m_solver->a_surfaceArea(srfcId);
20129 mTerm(1, AT_,
"something went wrong!");
20132 area = m_solver->c_cellLengthAtCell(cellId);
20134 area =
POW2(m_solver->c_cellLengthAtCell(cellId));
20138 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20140 localMeanPressure += p * area;
20143 MFloat globalMeanPressure = F0;
20145 MPI_Allreduce(&localMeanPressure, &globalMeanPressure, 1, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
20146 AT_,
"localMeanPressure",
"globalMeanPressure");
20148 const MFloat inflowArea = m_cbcInflowArea[cbcId];
20150 globalMeanPressure /= inflowArea;
20151 pressure[0] = globalMeanPressure;
20158template <MInt nDim,
class SysEqn>
20159template <
unsigned char vTerms>
20164 auto index = [&](
MInt dim0,
MInt dim1,
MInt dim2) {
return dim0 * (nDim * nDim) + dim1 * nDim + dim2; };
20168 MInt coId = cutOffStencilCellIds[cellId];
20170 MInt cbcId = m_cbcBndryCndIds[bcId];
20172 MInt dimN = m_cbcDir[cbcId][1];
20173 MInt dimT1 = m_cbcDir[cbcId][2];
20174 MInt dimT2 = m_cbcDir[cbcId][nDim];
20176 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20177 MInt last = CV->noVariables - 1 - m_solver->m_noSpecies;
20179 if(last != 4)
mTerm(1, AT_,
"last is not four!");
20182 MFloat Sum_dtaun = gradTau[index(dimN, dimN, dimN)] + gradTau[index(dimN, dimT1, dimT1)];
20183 IF_CONSTEXPR(nDim == 3) { Sum_dtaun += gradTau[index(dimN, dimT2, dimT2)]; }
20184 V[1] = F1 / (sysEqn().m_Re0 * rho) * (Sum_dtaun);
20188 MFloat Sum_dtaut = gradTau[index(dimT1, dimT1, dimT1)];
20189 IF_CONSTEXPR(nDim == 3) { Sum_dtaut += gradTau[index(dimT1, dimT2, +dimT2)]; }
20190 V[2] = F1 / (sysEqn().m_Re0 * rho) * (Sum_dtaut);
20193 IF_CONSTEXPR(nDim == 3) {
20195 V[3] = F1 / (sysEqn().m_Re0 * rho) * (gradTau[index(dimT1, dimT2, dimT1)] + gradTau[index(dimT2, dimT2, dimT2)]);
20201 tau[index(coId, dimN, dimN)] * gradVV[index(0, dimN, dimN)]
20202 + tau[index(coId, dimN, dimT1)] * (gradVV[index(0, dimT1, dimN)] + gradVV[index(0, dimN, dimT1)])
20203 + tau[index(coId, dimT1, dimT1)] * gradVV[index(0, dimT1, dimT1)] + gradQ[index(0, dimT1, dimT1)];
20205 IF_CONSTEXPR(nDim == 3) {
20207 tau[index(coId, dimN, dimT2)] * (gradVV[index(0, dimT2, dimN)] + gradVV[index(0, dimN, dimT2)])
20208 + tau[index(coId, dimT2, dimT2)] * gradVV[index(0, dimT2, dimT2)]
20209 + tau[index(coId, dimT1, dimT2)] * (gradVV[index(0, dimT1, dimT2)] + gradVV[index(0, dimT2, dimT1)])
20210 + gradQ[index(0, dimT2, dimT2)];
20212 V[last] = Sum_d_for_V5 / sysEqn().cp_Ref() / sysEqn().m_Re0;
20220template <MInt nDim,
class SysEqn>
20222 MString prescribedVariable) {
20225 MInt cbcId = m_cbcBndryCndIds[bcId];
20226 MInt dirN = m_cbcDir[cbcId][0];
20227 MInt last = CV->noVariables - 1 - m_solver->m_noSpecies;
20229 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20230 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20231 MFloat a = sysEqn().speedOfSound(rho, p);
20233 if(dirN % 2 == 0) {
20234 if(prescribedVariable ==
"velocity") {
20235 K[0] = m_cbcRelax[cbcId][0] * rho *
a *
a * (1 - maxM * maxM) / m_cbcLref[cbcId];
20236 }
else if(prescribedVariable ==
"pressure") {
20237 K[0] = m_cbcRelax[cbcId][0] * rho *
a * (1 - maxM * maxM) / m_cbcLref[cbcId];
20239 TERMM(-1,
"INFO: no prescribed variable set in cbcDampingInflow");
20241 K[last] = m_cbcRelax[cbcId][last] * rho *
a *
a * (1 - maxM * maxM) / m_cbcLref[cbcId];
20243 if(prescribedVariable ==
"velocity") {
20244 K[last] = m_cbcRelax[cbcId][last] * rho *
a *
a * (1 - maxM * maxM) / m_cbcLref[cbcId];
20245 }
else if(prescribedVariable ==
"pressure") {
20246 K[last] = m_cbcRelax[cbcId][last] * rho *
a * (1 - maxM * maxM) / m_cbcLref[cbcId];
20248 TERMM(-1,
"INFO: no prescribed variable set in cbcDampingInflow");
20250 K[0] = m_cbcRelax[cbcId][0] * rho *
a *
a * (1 - maxM * maxM) / m_cbcLref[cbcId];
20253 K[1] = m_cbcRelax[cbcId][1] * rho *
a / (m_cbcLref[cbcId]);
20256 IF_CONSTEXPR(isDetChem<SysEqn>)
20257 K[1] = m_cbcRelax[cbcId][1] * rho *
a * m_solver->m_gasConstant
20258 / (m_cbcLref[cbcId] * m_solver->a_avariable(cellId, AV->W_MEAN));
20260 K[2] = m_cbcRelax[cbcId][2] *
a / m_cbcLref[cbcId];
20261 IF_CONSTEXPR(nDim == 3) { K[3] = m_cbcRelax[cbcId][3] *
a / m_cbcLref[cbcId]; }
20263 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
20264 K[last + 1 + s] = m_cbcRelax[cbcId][last + 1 + s] *
a / m_cbcLref[cbcId];
20272template <MInt nDim,
class SysEqn>
20276 MInt cbcId = m_cbcBndryCndIds[bcId];
20277 MInt last = CV->noVariables - 1 - m_solver->m_noSpecies;
20279 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20280 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20281 MFloat a = sysEqn().speedOfSound(rho, p);
20283 K[0] = m_cbcRelax[cbcId][0] *
a * (F1 - maxM * maxM) / m_cbcLref[cbcId];
20290template <MInt nDim,
class SysEqn>
20294 MInt last = CV->noVariables - 1 - m_solver->m_noSpecies;
20296 MInt cbcId = m_cbcBndryCndIds[bcId];
20298 MInt dimN = m_cbcDir[cbcId][1];
20299 MInt dimT1 = m_cbcDir[cbcId][2];
20301 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20305 un = m_solver->a_pvariable(cellId, PV->VV[dimN]) * m_dirNormal[cbcId][dimN]
20306 + m_solver->a_pvariable(cellId, PV->VV[dimT1]) * m_dirNormal[cbcId][dimT1];
20307 ut1 = m_solver->a_pvariable(cellId, PV->VV[dimN]) * m_dirTangent[cbcId][dimN]
20308 + m_solver->a_pvariable(cellId, PV->VV[dimT1]) * m_dirTangent[cbcId][dimT1];
20311 IF_CONSTEXPR(nDim == 3) {
20312 MInt dimT2 = m_cbcDir[cbcId][nDim];
20313 un += m_solver->a_pvariable(cellId, PV->VV[dimT2]) * m_dirNormal[cbcId][dimT2];
20314 ut1 += m_solver->a_pvariable(cellId, PV->VV[dimT2]) * m_dirTangent[cbcId][dimT2];
20315 ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
20318 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20319 MFloat a = sysEqn().speedOfSound(rho, p);
20322 IF_CONSTEXPR(nDim == 3) sumOfVVSquared +=
POW2(ut2);
20324 MFloat d1 = m_dirNormal[cbcId][dimN] * F1 / (
a *
a) * L[1] + m_dirNormal[cbcId][dimT1] * L[3]
20325 + F1B2 * F1 / (
a *
a) * (L[last] + L[0]);
20326 MFloat d2 = m_dirNormal[cbcId][dimN] * (F1B2 / (rho *
a) * (L[last] - L[0])) - m_dirNormal[cbcId][dimT1] * L[2];
20327 MFloat d3 = m_dirNormal[cbcId][dimN] * L[2] + m_dirNormal[cbcId][dimT1] * (F1B2 / (rho *
a) * (L[last] - L[0]));
20328 IF_CONSTEXPR(nDim == 3) {
20329 MInt dimT2 = m_cbcDir[cbcId][nDim];
20330 d1 -= m_dirNormal[cbcId][dimT2] * L[2];
20331 d2 -= m_dirNormal[cbcId][dimT2] * L[3];
20332 d3 += m_dirNormal[cbcId][dimT2] * F1 / (
a *
a) * L[1];
20334 MFloat d5 = F1B2 * (L[last] + L[0]);
20336 std::vector<MFloat> dSpecies;
20337 std::vector<MFloat> rhs_rhoY;
20338 dSpecies.resize(m_solver->m_noSpecies);
20339 rhs_rhoY.resize(m_solver->m_noSpecies);
20341 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
20342 dSpecies[s] = L[last + 1 + s];
20345 MFloat rhs_rho = -d1 + T[0] + V[0];
20346 MFloat rhs_rhoun = un * (-d1 + T[0] + V[0]) + rho * (-d2 + T[1] + V[1]);
20347 MFloat rhs_rhout1 = ut1 * (-d1 + T[0] + V[0]) + rho * (-d3 + T[2] + V[2]);
20348 MFloat rhs_rhoe = F1B2 * sumOfVVSquared * (-d1 + T[0] + V[0]) + rho * un * (-d2 + T[1] + V[1])
20349 + rho * ut1 * (-d3 + T[2] + V[2]) + sysEqn().cp_Ref() * (-d5 + T[last] + V[last]);
20351 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
20352 rhs_rhoY[s] = m_solver->a_pvariable(cellId, PV->Y[s]) * (-d1 + T[0]) + rho * (-dSpecies[s] + T[last + 1 + s]);
20355 IF_CONSTEXPR(nDim == 3) {
20356 MInt dimT2 = m_cbcDir[cbcId][nDim];
20357 MFloat d4 = m_dirNormal[cbcId][dimN] * L[3] + m_dirNormal[cbcId][dimT2] * (F1B2 / (rho *
a) * (L[last] - L[0]))
20358 - m_dirNormal[cbcId][dimT1] * F1 / (
a *
a) * L[1];
20359 MFloat rhs_rhout2 = ut2 * (-d1 + T[0] + V[0]) + rho * (-d4 + T[3] + V[3]);
20360 rhs_rhoe += rho * ut2 * (-d4 + T[3] + V[3]);
20362 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT2]) = -m_solver->a_cellVolume(cellId) * rhs_rhout2;
20365 m_solver->a_rightHandSide(cellId, CV->RHO) = -m_solver->a_cellVolume(cellId) * rhs_rho;
20366 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimN]) = -m_solver->a_cellVolume(cellId) * rhs_rhoun;
20367 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT1]) = -m_solver->a_cellVolume(cellId) * rhs_rhout1;
20368 m_solver->a_rightHandSide(cellId, CV->RHO_E) = -m_solver->a_cellVolume(cellId) * rhs_rhoe;
20370 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
20371 m_solver->a_rightHandSide(cellId, CV->RHO_Y[s]) -= m_solver->a_cellVolume(cellId) * rhs_rhoY[s];
20380template <MInt nDim,
class SysEqn>
20384 IF_CONSTEXPR(nDim != 3)
mTerm(1, AT_,
"Only implemented for nDim = 3");
20387 MFloat that, twopioverlb;
20389 MFloat xhat, yhat, zhat;
20393 if(m_solver->m_restart &&
globalTimeStep == m_solver->m_restartTimeStep + 1) {
20394 dummyTime = (m_solver->m_time - m_solver->m_timeStep) / m_bc1601->m_tau_b;
20395 m_bc1601->checkRegeneration(dummyTime);
20397 that = F2 * PI * dummyTime;
20398 twopioverlb = F2 * PI / m_bc1601->m_l_b;
20400 xhat = twopioverlb * m_solver->a_coordinate(cellId, 0);
20401 yhat = twopioverlb * m_solver->a_coordinate(cellId, 1);
20402 zhat = twopioverlb * m_solver->a_coordinate(cellId, 2);
20404 m_bc1601->calculateFlucts(that, xhat, yhat, zhat, fluctChol);
20406 m_oldFluctChol[sortedCutOffCellId][0] = fluctChol[0];
20407 m_oldFluctChol[sortedCutOffCellId][1] = fluctChol[1];
20408 IF_CONSTEXPR(nDim == 3) m_oldFluctChol[sortedCutOffCellId][2] = fluctChol[2];
20411 dummyTime = m_solver->m_time / m_bc1601->m_tau_b;
20412 m_bc1601->checkRegeneration(dummyTime);
20414 that = F2 * PI * dummyTime;
20415 twopioverlb = F2 * PI / m_bc1601->m_l_b;
20417 xhat = twopioverlb * m_solver->a_coordinate(cellId, 0);
20418 yhat = twopioverlb * m_solver->a_coordinate(cellId, 1);
20419 zhat = twopioverlb * m_solver->a_coordinate(cellId, 2);
20421 m_bc1601->calculateFlucts(that, xhat, yhat, zhat, fluctChol);
20424 (fluctChol[0] - m_oldFluctChol[sortedCutOffCellId][0]) / (m_solver->c_cellLengthAtCell(cellId));
20426 (fluctChol[1] - m_oldFluctChol[sortedCutOffCellId][1]) / (m_solver->c_cellLengthAtCell(cellId));
20428 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20429 MFloat a = sysEqn().speedOfSound(rho, m_solver->a_pvariable(cellId, PV->P));
20431 L_turbulent[0] = rho *
a * m_solver->m_UInfinity * dFluctCholndn;
20432 L_turbulent[1] = rho *
a * m_solver->m_UInfinity * dFluctCholt1dn;
20433 IF_CONSTEXPR(nDim == 3) {
20435 (fluctChol[2] - m_oldFluctChol[sortedCutOffCellId][2]) / (m_solver->c_cellLengthAtCell(cellId));
20436 L_turbulent[2] = rho *
a * m_solver->m_UInfinity * dFluctCholt2dn;
20439 if(m_solver->m_RKStep == m_solver->m_noRKSteps - 1) {
20440 m_oldFluctChol[sortedCutOffCellId][0] = fluctChol[0];
20441 m_oldFluctChol[sortedCutOffCellId][1] = fluctChol[1];
20442 IF_CONSTEXPR(nDim == 3) m_oldFluctChol[sortedCutOffCellId][2] = fluctChol[2];
20456template <MInt nDim,
class SysEqn>
20460 if(m_sortedCutOffCells[bcId]->size() == 0) {
20464 MInt cbcId = m_cbcBndryCndIds[bcId];
20466 MInt dirN = m_cbcDir[cbcId][0];
20467 MInt dimN = m_cbcDir[cbcId][1];
20468 MInt dimT1 = m_cbcDir[cbcId][2];
20469 MInt dimT2 = m_cbcDir[cbcId][nDim];
20471 MInt last = nDim + 1;
20485 MFloat mach[2] = {F0, F0};
20486 cbcMachCo(bcId, mach);
20491 if(m_cbcTurbulence) m_cbcViscous =
false;
20493 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
20496 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
20499 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
20500 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
20502 MFloat T_target = sysEqn().temperature_IR(meanM);
20503 IF_CONSTEXPR(isDetChem<SysEqn>) T_target = m_solver->m_detChem.infTemperature;
20506 MBool solverProfile =
false;
20507 solverProfile = Context::getSolverProperty<MBool>(
"solverProfile", m_solverId, AT_, &solverProfile);
20509 IF_CONSTEXPR(nDim == 3) { A = sqrt(m_cbcInflowArea[cbcId] / PI); }
20511 A = m_cbcInflowArea[cbcId] * F1B2;
20514 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
20515 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
20516 if(m_solver->a_isHalo(cellId))
continue;
20517 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
20518 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
20519 MInt bndryId = m_solver->a_bndryId(cellId);
20523 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
20525 area = m_solver->a_surfaceArea(srfcId);
20527 mTerm(1, AT_,
"something went wrong!");
20530 IF_CONSTEXPR(nDim == 2) area = m_solver->c_cellLengthAtCell(cellId);
20531 IF_CONSTEXPR(nDim == 3) area =
POW2(m_solver->c_cellLengthAtCell(cellId));
20534 area *= m_dirTangent[cbcId][m_cbcDir[cbcId][2]];
20537 IF_CONSTEXPR(nDim == 2) {
20538 rsquare =
POW2((m_solver->a_coordinate(cellId, dimT1) - m_cbcReferencePoint[cbcId][dimT1]));
20541 rsquare =
POW2(m_solver->a_coordinate(cellId, 0) - m_cbcReferencePoint[cbcId][0])
20542 +
POW2(m_solver->a_coordinate(cellId, 1) - m_cbcReferencePoint[cbcId][1])
20543 +
POW2(m_solver->a_coordinate(cellId, 2) - m_cbcReferencePoint[cbcId][2]);
20545 testSum2 += area * rsquare;
20548 MInt noExchangeData = 1;
20551 comm_buff[0] = testSum2;
20553 if(noDomains() > 1) {
20554 MPI_Allreduce(&comm_buff[0], &comm_buff_result[0], 1, MPI_DOUBLE, MPI_MAX, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
20555 AT_,
"comm_buff[0]",
"comm_buff_result[0]");
20558 testSum2 = comm_buff_result[0];
20561 IF_CONSTEXPR(nDim == 2) { massflux_test = F3B4 / A * (m_cbcInflowArea[cbcId] - F1 / (A * A) * testSum2); }
20563 massflux_test = F2 * (F1 - testSum2 / (m_cbcInflowArea[cbcId] * A * A));
20565 MFloat un_correctionFactor = F1;
20566 if(fabs(massflux_test) > m_solver->m_eps) {
20567 un_correctionFactor = F1 / massflux_test;
20571 IF_CONSTEXPR(nDim == 2) {
20572 massflux_target = m_solver->m_UInfinity * m_cbcInflowArea[cbcId]
20573 * sysEqn().density_ES(m_solver->m_PInfinity, m_solver->m_TInfinity);
20574 IF_CONSTEXPR(isDetChem<SysEqn>) {
20575 massflux_target = m_solver->m_VInfinity * m_cbcInflowArea[cbcId] * m_solver->m_rhoInfinity;
20579 IF_CONSTEXPR(nDim == 3) {
20580 massflux_target = m_solver->m_VInfinity * m_cbcInflowArea[cbcId]
20581 * sysEqn().density_ES(m_solver->m_PInfinity, m_solver->m_TInfinity);
20585 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
20586 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
20588 if(m_solver->a_isHalo(cellId))
continue;
20589 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
20590 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
20592 MInt bndryId = m_solver->a_bndryId(cellId);
20595 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
20598 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
20601 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
20602 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
20603 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
20605 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
20606 &cutOffStencilCellIds[0], &V[0]);
20609 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
20610 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
20611 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"velocity");
20613 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20614 MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
20615 MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
20616 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20617 MFloat temp = sysEqn().temperature_ES(rho, p);
20619 IF_CONSTEXPR(isDetChem<SysEqn>) {
20620 MFloat fMeanMolarWeight = F0;
20621 for(
MUint s = 0; s < PV->m_noSpecies; s++) {
20622 fMeanMolarWeight += m_solver->a_pvariable(cellId, PV->Y[s]) * m_solver->m_fMolarMass[s];
20624 MFloat meanMolarWeight = F1 / fMeanMolarWeight;
20625 temp = p / rho * meanMolarWeight / m_solver->m_gasConstant;
20628 MFloat a = sysEqn().speedOfSound(rho, p);
20629 IF_CONSTEXPR(isDetChem<SysEqn>)
a = sqrt(m_solver->a_avariable(cellId, m_solver->AV->GAMMA) * p / rho);
20634 IF_CONSTEXPR(nDim == 2) {
20635 rsquare =
POW2((m_solver->a_coordinate(cellId, dimT1) - m_cbcReferencePoint[cbcId][dimT1]));
20636 un_target = F3B4 * massflux_target / rho / A * (1 - rsquare / (A * A)) * un_correctionFactor;
20639 rsquare =
POW2(m_solver->a_coordinate(cellId, 0) - m_cbcReferencePoint[cbcId][0])
20640 +
POW2(m_solver->a_coordinate(cellId, 1) - m_cbcReferencePoint[cbcId][1])
20641 +
POW2(m_solver->a_coordinate(cellId, 2) - m_cbcReferencePoint[cbcId][2]);
20642 un_target = F2 * massflux_target / m_cbcInflowArea[cbcId] * (F1 - rsquare / (A * A)) / rho * un_correctionFactor;
20644 if(solverProfile) {
20645 un_target = massflux_target / m_cbcInflowArea[cbcId] / rho;
20650 IF_CONSTEXPR(isDetChem<SysEqn>) un_target = m_solver->m_VInfinity;
20654 MFloat L_turbulent[3] = {F0, F0, F0};
20655 if(m_cbcTurbulence) {
20656 cbcTurbulenceInjection(cellId, L_turbulent,
id);
20659 if(dirN % 2 == 0) {
20660 L[0] = -F1 * K[0] * (un - un_target) + (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
20662 L[last] = K[last] * (un - un_target) - L_turbulent[0] + (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
20665 L[1] = K[1] * (temp - T_target) + (
a *
a * T[0] - T[last]) - V[last];
20666 L[2] = K[2] * (ut1 - ut1_target) - L_turbulent[1] + T[2] + V[2];
20668 IF_CONSTEXPR(nDim == 3) {
20669 MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
20671 L[3] = K[3] * (ut2 - ut2_target) - L_turbulent[2] + T[3] + V[3];
20674 IF_CONSTEXPR(isDetChem<SysEqn>) {
20675 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
20676 MFloat y = m_solver->a_pvariable(cellId, sysEqn().PV->Y[s]);
20677 L[last + 1 + s] = K[last + 1 + s] * (
y - m_solver->m_YInfinity[s]);
20681 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
20682 MFloat y = m_solver->a_pvariable(cellId, sysEqn().PV->Y[s]);
20683 L[last + 1 + s] = K[last + 1 + s] * (
y - y_target);
20686 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
20694template <MInt nDim,
class SysEqn>
20698 if(m_sortedCutOffCells[bcId]->size() == 0) {
20702 MInt cbcId = m_cbcBndryCndIds[bcId];
20704 MInt dirN = m_cbcDir[cbcId][0];
20705 MInt dimN = m_cbcDir[cbcId][1];
20707 MInt dimT2 = m_cbcDir[cbcId][nDim];
20726 std::vector<MFloat> mach(2);
20727 cbcMachCo(bcId, &mach[0]);
20731 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
20734 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
20737 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
20738 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
20740 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
20741 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
20743 if(m_solver->a_isHalo(cellId))
continue;
20745 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
20756 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20757 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20758 MFloat a = sysEqn().speedOfSound(rho, p);
20763 if(m_solver->checkNeighborActive(cellId, dirN) && m_solver->a_hasNeighbor(cellId, dirN)) {
20764 const MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
20765 for(
MInt n = 0; n < nDim; n++) {
20766 vn_N += m_solver->a_variable(nghbrN, CV->RHO_VV[n]) * m_dirNormal[cbcId][n];
20770 MFloat x = m_solver->a_coordinate(cellId, 0);
20771 MFloat vn_target = m_solver->m_UInfinity;
20772 MInt length = m_vnTargetDataCount;
20773 for(
MInt i = 1; i < length; i++) {
20774 if(m_vnTargetData[i].first > x && m_vnTargetData[i - 1].first <= x) {
20775 vn_target = m_vnTargetData[i - 1].second
20776 + (m_vnTargetData[i].second - m_vnTargetData[i - 1].second)
20777 / (m_vnTargetData[i].first - m_vnTargetData[i - 1].first) * (x - m_vnTargetData[i - 1].first);
20781 MFloat un = m_solver->a_pvariable(cellId, PV->VV[0]);
20782 MFloat vn = m_solver->a_pvariable(cellId, PV->VV[1]);
20786 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
20787 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
20788 L[0] = lambda1 * (gradP[dimN] - rho *
a * gradVV[dimN * nDim + dimN]);
20789 L[1] = lambda2 * (
a *
a * gradRho[dimN] - gradP[dimN]);
20790 L[2] = K[2] * (vn - vn_target);
20792 IF_CONSTEXPR(nDim == 3) { L[3] = lambda2 * (gradVV[dimT2 * nDim + dimN]); }
20794 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
20802template <MInt nDim,
class SysEqn>
20806 if(m_sortedCutOffCells[bcId]->size() == 0) {
20810 MInt cbcId = m_cbcBndryCndIds[bcId];
20812 MInt dirN = m_cbcDir[cbcId][0];
20813 MInt dimN = m_cbcDir[cbcId][1];
20814 MInt dimT1 = m_cbcDir[cbcId][2];
20815 MInt dimT2 = m_cbcDir[cbcId][nDim];
20817 MInt last = nDim + 1;
20834 std::vector<MFloat> mach(2);
20835 cbcMachCo(bcId, &mach[0]);
20839 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
20842 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
20845 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
20846 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
20849 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
20850 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
20852 if(m_solver->a_isHalo(cellId))
continue;
20854 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
20865 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20866 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20867 MFloat a = sysEqn().speedOfSound(rho, p);
20872 MFloat targetPressure = m_solver->m_PInfinity;
20873 MFloat targetDensity = m_solver->m_rhoInfinity;
20878 if(m_solver->checkNeighborActive(cellId, dirN) && m_solver->a_hasNeighbor(cellId, dirN)) {
20879 const MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
20881 for(
MInt n = 0; n < nDim; n++) {
20882 un_N += m_solver->a_variable(nghbrN, CV->RHO_VV[n]) * m_dirNormal[cbcId][n];
20886 MFloat y = m_solver->a_coordinate(cellId, 1);
20887 MFloat un_target = m_solver->m_UInfinity;
20888 MInt length = m_unTargetDataCount;
20889 for(
MInt i = 1; i < length; i++) {
20890 if(m_unTargetData[i].first >
y && m_unTargetData[i - 1].first <=
y) {
20891 un_target = m_unTargetData[i - 1].second
20892 + (m_unTargetData[i].second - m_unTargetData[i - 1].second)
20893 / (m_unTargetData[i].first - m_unTargetData[i - 1].first) * (
y - m_unTargetData[i - 1].first);
20897 MBool isInflow =
false;
20898 if(dirN % 2 == 0) {
20908 MFloat un = m_solver->a_pvariable(cellId, PV->VV[0]);
20914 std::ignore = targetDensity;
20917 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
20918 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
20919 if(dirN % 2 == 0) {
20920 L[0] = -F1 * K[0] * (un - un_target) + (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
20922 L[last] = K[last] * (un - un_target) + (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
20924 L[1] = lambda2 * (
a *
a * gradRho[dimN] - gradP[dimN]);
20925 L[2] = lambda2 * (gradVV[dimT1 * nDim + dimN]);
20926 IF_CONSTEXPR(nDim == 3) { L[3] = lambda2 * (gradVV[dimT2 * nDim + dimN]); }
20928 cbcOutgoingAmplitudeVariation<0>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
20929 cbcDampingOutflow(cellId, bcId, maxM, &K[0]);
20930 if(dirN % 2 == 0) {
20931 L[0] = K[0] * (p - targetPressure) + (F1 - beta) * (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
20934 K[last] * (p - targetPressure) + (F1 - beta) * (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
20938 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
20946template <MInt nDim,
class SysEqn>
20950 if(m_sortedCutOffCells[bcId]->size() == 0) {
20954 MInt cbcId = m_cbcBndryCndIds[bcId];
20956 MInt dirN = m_cbcDir[cbcId][0];
20961 MInt last = nDim + 1;
20987 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
20988 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
20989 MInt level = m_solver->a_level(cellId);
20990 MInt rDistance = 1 / m_solver->c_cellLengthAtLevel(level);
20992 if(m_solver->a_isHalo(cellId))
continue;
20994 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
20996 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
20997 MFloat p = m_solver->a_pvariable(cellId, PV->P);
20998 MFloat u = m_solver->a_pvariable(cellId, PV->VV[0]);
20999 MFloat a = sysEqn().speedOfSound(rho, p);
21002 MFloat targetPressure = m_solver->m_PInfinity;
21005 MFloat y = m_solver->a_coordinate(cellId, 1);
21006 MFloat un_target = m_solver->m_UInfinity;
21007 MInt length = m_unTargetDataCount;
21008 for(
MInt i = 1; i < length; i++) {
21009 if(m_unTargetData[i].first >
y && m_unTargetData[i - 1].first <=
y) {
21010 un_target = m_unTargetData[i - 1].second
21011 + (m_unTargetData[i].second - m_unTargetData[i - 1].second)
21012 / (m_unTargetData[i].first - m_unTargetData[i - 1].first) * (
y - m_unTargetData[i - 1].first);
21020 if(dirN % 2 == 0) {
21023 L[last] = rDistance * ((u -
a) * (targetPressure - p) - rho *
a * (un_target - u));
21026 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
21037template <MInt nDim,
class SysEqn>
21041 if(m_sortedCutOffCells[bcId]->size() == 0) {
21045 MInt cbcId = m_cbcBndryCndIds[bcId];
21047 MInt dirN = m_cbcDir[cbcId][0];
21048 MInt dimN = m_cbcDir[cbcId][1];
21049 MInt dimT1 = m_cbcDir[cbcId][2];
21050 MInt dimT2 = m_cbcDir[cbcId][nDim];
21052 MInt last = nDim + 1;
21066 cbcMachCo(bcId, mach);
21071 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
21074 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
21077 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
21078 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
21080 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21081 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21083 if(m_solver->a_isHalo(cellId))
continue;
21085 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
21088 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
21089 gradQ[dimN * nDim + dimN] = F0;
21090 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
21091 IF_CONSTEXPR(nDim == 3) gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0;
21092 cbcViscousTerms<(unsigned char)11111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
21093 &cutOffStencilCellIds[0], &V[0]);
21096 cbcOutgoingAmplitudeVariation<0>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
21097 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
21098 cbcDampingOutflow(cellId, bcId, maxM, &K[0]);
21100 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
21101 MFloat p = m_solver->a_pvariable(cellId, PV->P);
21102 MFloat a = sysEqn().speedOfSound(rho, p);
21107 MFloat targetPressure = m_solver->m_PInfinity - m_deltaPL;
21112 if(dirN % 2 == 0) {
21113 L[0] = K[0] * (p - targetPressure) + (F1 - beta) * (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
21115 L[last] = K[last] * (p - targetPressure) + (F1 - beta) * (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
21117 for(
MInt s = 0; s < m_solver->m_noSpecies; s++) {
21118 MFloat y = m_solver->a_pvariable(cellId, sysEqn().PV->Y[s]);
21119 L[last + 1 + s] = K[last + 1 + s] * (
y - y_target);
21122 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
21133template <MInt nDim,
class SysEqn>
21135 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function cbc2091a is untested for 3D!"); }
21138 if(m_sortedCutOffCells[bcId]->size() == 0) {
21142 MInt cbcId = m_cbcBndryCndIds[bcId];
21144 MInt dirN = m_cbcDir[cbcId][0];
21145 MInt dimN = m_cbcDir[cbcId][1];
21146 MInt dimT1 = m_cbcDir[cbcId][2];
21147 MInt dimT2 = m_cbcDir[cbcId][nDim];
21149 MBool solverProfile = Context::getSolverProperty<MBool>(
"solverProfile", m_solverId, AT_, &solverProfile);
21150 MFloat time = m_solver->m_time;
21151 MFloat St = m_solver->m_flameStrouhal;
21152 MFloat ampl = m_solver->m_forcingAmplitude;
21154 MFloat inflowArea = m_cbcInflowArea[cbcId];
21157 MInt last = nDim + 1;
21170 MFloat mach[2] = {F0, F0};
21171 cbcMachCo(bcId, mach);
21178 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21179 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21180 MInt bndryId = m_solver->a_bndryId(cellId);
21182 if(m_solver->a_isHalo(cellId))
continue;
21183 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21184 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21190 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
21192 area = m_solver->a_surfaceArea(srfcId);
21194 mTerm(1, AT_,
"something went wrong!");
21196 area = m_solver->c_cellLengthAtCell(cellId);
21199 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
21200 const MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
21201 const MFloat y = (m_solver->a_coordinate(cellId, dimT1) - m_cbcReferencePoint[cbcId][dimT1]);
21202 testSum2 += area *
y *
y;
21203 massflux += un * rho * area;
21207 MInt noExchangeData = 2;
21210 comm_buff[0] = massflux;
21211 comm_buff[1] = testSum2;
21213 if(noDomains() > 1) {
21214 MPI_Allreduce(&comm_buff[0], &comm_buff_result[0], 3, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
21215 AT_,
"comm_buff[0]",
"comm_buff_result[0]");
21216 MPI_Allreduce(MPI_IN_PLACE, &uInt, 1, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
21217 "MPI_IN_PLACE",
"uInt");
21220 massflux = comm_buff_result[0];
21221 testSum2 = comm_buff_result[1];
21222 MFloat massflux_test = uInt / m_solver->m_analyticIntegralVelocity;
21224 MFloat un_correctionFactor = F1;
21225 if(fabs(massflux_test) > m_solver->m_eps) un_correctionFactor = F1 / massflux_test;
21227 const MFloat massflux_target = massflux * un_correctionFactor;
21229 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->
size() : 1;
21232 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
21235 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
21236 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
21238 MFloat T_target = sysEqn().temperature_ES(m_solver->m_rhoInfinity, m_solver->m_meanPressure);
21240 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21241 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21243 if(m_solver->a_isHalo(cellId))
continue;
21244 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21245 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21247 MInt bndryId = m_solver->a_bndryId(cellId);
21249 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
21252 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
21255 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
21256 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
21257 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
21258 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
21259 &cutOffStencilCellIds[0], &V[0]);
21262 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
21263 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
21264 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"velocity");
21266 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
21267 MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
21268 MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
21270 MFloat p = m_solver->a_pvariable(cellId, PV->P);
21271 MFloat temp = sysEqn().temperature_ES(rho, p);
21272 MFloat a = sysEqn().speedOfSound(rho, p);
21274 MFloat xPlus = (m_solver->a_coordinate(cellId, 0) + m_radiusVelFlameTube);
21275 xPlus *= m_shearLayerStrength;
21276 MFloat xNegative = m_solver->a_coordinate(cellId, 0) - m_radiusVelFlameTube;
21277 xNegative *= m_shearLayerStrength;
21279 MFloat un_target = m_solver->m_VInfinity
21280 * (F1B2 * (F1 + tanh(xPlus)) * (F1 - tanh(xNegative))
21284 if(solverProfile) un_target = massflux_target / inflowArea / rho;
21286 if(m_solver->m_forcing) {
21289 un_target *= (F1 + ampl * sin(St * time));
21294 if(dirN % 2 == 0) {
21295 L[0] = -F1 * K[0] * (un - un_target) + (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
21297 L[last] = K[last] * (un - un_target) + (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
21300 L[1] = K[1] * (temp - T_target) + (
a *
a * T[0] - T[last]) - V[last];
21301 L[2] = K[2] * (ut1 - ut1_target) + T[2] + V[2];
21303 IF_CONSTEXPR(nDim == 3) {
21304 MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
21306 L[3] = K[3] * (ut2 - ut2_target) + T[3] + V[3];
21309 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
21310 for(
MInt s = 0; s < m_solver->m_noSpecies; s++)
21311 m_solver->a_rightHandSide(cellId, CV->RHO_Y[s]) = F0;
21322template <MInt nDim,
class SysEqn>
21326 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function cbc2091a is untested for 3D!"); }
21328 if(m_sortedCutOffCells[bcId]->size() == 0) {
21332 MInt cbcId = m_cbcBndryCndIds[bcId];
21334 MInt dirN = m_cbcDir[cbcId][0];
21335 MInt dimN = m_cbcDir[cbcId][1];
21336 MInt dimT1 = m_cbcDir[cbcId][2];
21337 MInt dimT2 = m_cbcDir[cbcId][nDim];
21339 MBool solverProfile = Context::getSolverProperty<MBool>(
"solverProfile", m_solverId, AT_, &solverProfile);
21340 MFloat time = m_solver->m_time;
21341 MFloat St = m_solver->m_flameStrouhal;
21342 MFloat ampl = m_solver->m_forcingAmplitude;
21344 MFloat inflowArea = m_cbcInflowArea[cbcId];
21347 MInt last = nDim + 1;
21360 MFloat mach[2] = {F0, F0};
21361 cbcMachCo(bcId, mach);
21368 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21369 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21370 MInt bndryId = m_solver->a_bndryId(cellId);
21372 if(m_solver->a_isHalo(cellId))
continue;
21373 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21374 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21380 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
21382 area = m_solver->a_surfaceArea(srfcId);
21384 mTerm(1, AT_,
"something went wrong!");
21386 area = m_solver->c_cellLengthAtCell(cellId);
21389 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
21390 const MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
21391 const MFloat y = (m_solver->a_coordinate(cellId, dimT1) - m_cbcReferencePoint[cbcId][dimT1]);
21392 testSum2 += area *
y *
y;
21393 massflux += un * rho * area;
21397 MInt noExchangeData = 2;
21400 comm_buff[0] = massflux;
21401 comm_buff[1] = testSum2;
21403 if(noDomains() > 1) {
21404 MPI_Allreduce(&comm_buff[0], &comm_buff_result[0], 3, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
21405 AT_,
"comm_buff[0]",
"comm_buff_result[0]");
21406 MPI_Allreduce(MPI_IN_PLACE, &uInt, 1, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
21407 "MPI_IN_PLACE",
"uInt");
21410 massflux = comm_buff_result[0];
21411 testSum2 = comm_buff_result[1];
21412 MFloat massflux_test = uInt / m_solver->m_analyticIntegralVelocity;
21414 MFloat un_correctionFactor = F1;
21415 if(fabs(massflux_test) > m_solver->m_eps) un_correctionFactor = F1 / massflux_test;
21417 const MFloat massflux_target = massflux * un_correctionFactor;
21418 const MFloat gammaMinusOne = m_solver->m_gamma - 1.0;
21420 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->
size() : 1;
21423 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
21426 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
21427 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
21429 MFloat T_target = sysEqn().temperature_IR(m_solver->m_Ma);
21431 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21432 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21434 if(m_solver->a_isHalo(cellId))
continue;
21435 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21436 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21438 MInt bndryId = m_solver->a_bndryId(cellId);
21440 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
21443 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
21446 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
21447 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
21448 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
21450 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
21451 &cutOffStencilCellIds[0], &V[0]);
21454 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
21455 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
21456 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"velocity");
21458 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
21459 MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
21460 MFloat p = m_solver->a_pvariable(cellId, PV->P);
21461 MFloat a = sysEqn().speedOfSound(rho, p);
21463 MFloat xPlus = (m_solver->a_coordinate(cellId, 0) + m_radiusVelFlameTube);
21464 xPlus *= m_shearLayerStrength;
21465 MFloat xNegative = m_solver->a_coordinate(cellId, 0) - m_radiusVelFlameTube;
21466 xNegative *= m_shearLayerStrength;
21468 MFloat un_target = m_solver->m_VInfinity
21469 * (F1B2 * (F1 + tanh(xPlus)) * (F1 - tanh(xNegative))
21473 if(solverProfile) un_target = massflux_target / inflowArea / rho;
21482 if(m_solver->m_forcing) {
21484 dundt *= St * ampl * cos(St * time);
21485 un_target *= (F1 + ampl * sin(St * time));
21489 if(dirN % 2 == 0) {
21490 L[0] = L[last] + (T[last] + ceta * rho *
a * T[1]) - ceta * F2 * rho *
a * dundt;
21492 L[last] = L[0] + (T[last] + ceta * rho *
a * T[1]) - ceta * F2 * rho *
a * dundt;
21494 L[1] = F1B2 * gammaMinusOne * (L[0] + L[last]) + (
a *
a * T[0] - T[last]);
21496 MFloat d1 = F1 / (
a *
a) * (L[1] + F1B2 * (L[last] + L[0]));
21498 MFloat dut1dt1 = m_solver->a_slope(cellId, PV->VV[dimT1], dimT1);
21499 MFloat drhodt1 = m_solver->a_slope(cellId, PV->RHO, dimT1);
21501 MFloat rhs_rho = -d1 - rho * (dut1dt1)-ut1 * drhodt1;
21503 m_solver->a_rightHandSide(cellId, CV->RHO) = -m_solver->a_cellVolume(cellId) * rhs_rho;
21504 for(
MInt s = 0; s < m_solver->m_noSpecies; s++)
21505 m_solver->a_rightHandSide(cellId, CV->RHO_Y[s]) -=
21506 m_solver->a_cellVolume(cellId) * rhs_rho * m_solver->a_pvariable(cellId, PV->Y[s]);
21507 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimN]) = F0;
21508 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT1]) = F0;
21509 m_solver->a_rightHandSide(cellId, CV->RHO_E) = F0;
21511 for(
MInt s = 0; s < m_solver->m_noSpecies; s++)
21512 m_solver->a_pvariable(cellId, PV->Y[s]) = 0;
21514 m_solver->a_pvariable(cellId, PV->VV[dimN]) = un_target;
21515 m_solver->a_pvariable(cellId, PV->VV[dimT1]) = ut1_target;
21516 m_solver->a_pvariable(cellId, PV->P) = T_target;
21524template <MInt nDim,
class SysEqn>
21526 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function cbc2091b_after is untested for 3D!"); }
21529 if(m_sortedCutOffCells[bcId]->size() == 0)
return;
21531 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21532 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21534 if(m_solver->a_isHalo(cellId))
continue;
21535 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21536 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21538 MInt bndryId = m_solver->a_bndryId(cellId);
21541 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
21545 MFloat rho = m_solver->a_variable(cellId, CV->RHO);
21546 MFloat u = m_solver->a_pvariable(cellId, PV->VV[0]);
21547 MFloat v = m_solver->a_pvariable(cellId, PV->VV[1]);
21548 MFloat T = m_solver->a_pvariable(cellId, PV->P);
21549 MFloat p = sysEqn().pressure_ES(T, rho);
21550 MFloat E = sysEqn().internalEnergy(p, rho, (u * u + v * v));
21552 m_solver->a_variable(cellId, CV->RHO_VV[0]) = rho * u;
21553 m_solver->a_variable(cellId, CV->RHO_VV[1]) = rho * v;
21554 m_solver->a_variable(cellId, CV->RHO_E) = E;
21555 for(
MInt s = 0; s < m_solver->m_noSpecies; s++)
21556 m_solver->a_variable(cellId, CV->RHO_Y[s]) = rho * m_solver->a_pvariable(cellId, PV->Y[s]);
21565template <MInt nDim,
class SysEqn>
21567 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function cbc2091a is untested for 3D!"); }
21570 if(m_sortedCutOffCells[bcId]->size() == 0) {
21574 MInt cbcId = m_cbcBndryCndIds[bcId];
21576 MInt dirN = m_cbcDir[cbcId][0];
21577 MInt dimN = m_cbcDir[cbcId][1];
21578 MInt dimT1 = m_cbcDir[cbcId][2];
21579 MInt dimT2 = m_cbcDir[cbcId][nDim];
21581 MFloat inflowArea = m_cbcInflowArea[cbcId];
21584 MInt last = nDim + 1;
21597 MFloat mach[2] = {F0, F0};
21598 cbcMachCo(bcId, mach);
21604 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21605 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21606 MInt bndryId = m_solver->a_bndryId(cellId);
21607 MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
21609 if(m_solver->a_isHalo(cellId))
continue;
21610 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21611 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21617 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
21619 area = m_solver->a_surfaceArea(srfcId);
21621 mTerm(1, AT_,
"something went wrong!");
21623 area = m_solver->c_cellLengthAtCell(cellId);
21626 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
21627 const MFloat un_N = m_solver->a_pvariable(nghbrN, PV->VV[dimN]);
21628 massflux += un_N * rho * area;
21629 uInt += un_N * area;
21632 MInt noExchangeData = 2;
21635 comm_buff[0] = massflux;
21636 comm_buff[1] = uInt;
21638 if(noDomains() > 1) {
21639 MPI_Allreduce(&comm_buff[0], &comm_buff_result[0], 3, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
21640 AT_,
"comm_buff[0]",
"comm_buff_result[0]");
21641 MPI_Allreduce(MPI_IN_PLACE, &uInt, 1, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
21642 "MPI_IN_PLACE",
"uInt");
21645 massflux = comm_buff_result[0];
21646 MFloat massflux_test = uInt / m_solver->m_analyticIntegralVelocity;
21648 MFloat un_correctionFactor = F1;
21649 if(fabs(massflux_test) > m_solver->m_eps) un_correctionFactor = F1 / massflux_test;
21651 massflux = massflux * un_correctionFactor;
21653 const MFloat gammaMinusOne = m_solver->m_gamma - 1.0;
21655 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->
size() : 1;
21658 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
21661 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
21662 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
21664 MFloat T_target = 1 - gammaMinusOne * F1B2 * (massflux * massflux / inflowArea / inflowArea);
21665 MFloat p_Target = sysEqn().pressure_IR(T_target);
21666 p_Target += m_solver->m_rhoInfinity *
POW2(m_solver->m_flameSpeed) * (m_solver->m_burntUnburntTemperatureRatio - F1);
21667 p_Target += m_solver->m_rhoFlameTube * m_solver->m_targetDensityFactor *
POW2(m_solver->m_velocityOutlet)
21668 * m_solver->m_flameOutletAreaRatio;
21669 p_Target -= m_solver->m_rhoFlameTube *
POW2(m_solver->m_VInfinity);
21671 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21672 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21674 if(m_solver->a_isHalo(cellId))
continue;
21675 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21676 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21678 MInt bndryId = m_solver->a_bndryId(cellId);
21680 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
21683 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
21686 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
21687 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
21688 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
21690 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
21691 &cutOffStencilCellIds[0], &V[0]);
21694 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
21695 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
21696 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
21698 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
21699 MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
21701 MFloat p = m_solver->a_pvariable(cellId, PV->P);
21702 MFloat temp = sysEqn().temperature_ES(rho, p);
21703 MFloat a = sysEqn().speedOfSound(rho, p);
21705 MFloat xPlus = (m_solver->a_coordinate(cellId, 0) + m_radiusVelFlameTube);
21706 xPlus *= m_shearLayerStrength;
21707 MFloat xNegative = m_solver->a_coordinate(cellId, 0) - m_radiusVelFlameTube;
21708 xNegative *= m_shearLayerStrength;
21710 MFloat un_target = m_solver->m_VInfinity
21711 * (F1B2 * (F1 + tanh(xPlus)) * (F1 - tanh(xNegative))
21716 if(dirN % 2 == 0) {
21717 L[0] = K[0] * (p - p_Target) + (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
21719 L[last] = K[last] * (p - p_Target) + (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
21722 L[1] = K[1] * (temp - T_target) + (
a *
a * T[0] - T[last]) - V[last];
21723 L[2] = K[2] * (ut1 - ut1_target) + T[2] + V[2];
21725 IF_CONSTEXPR(nDim == 3) {
21726 MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
21728 L[3] = K[3] * (ut2 - ut2_target) + T[3] + V[3];
21731 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
21734 MFloat d1 = F1 / (
a *
a) * (L[1] + F1B2 * (L[last] + L[0]));
21735 MFloat rhs_rho = -d1 + T[0] + V[0];
21736 for(
MInt s = 0; s < m_solver->m_noSpecies; s++)
21737 m_solver->a_rightHandSide(cellId, CV->RHO_Y[s]) -=
21738 m_solver->a_cellVolume(cellId) * rhs_rho * m_solver->a_pvariable(cellId, PV->Y[s]);
21739 for(
MInt s = 0; s < m_solver->m_noSpecies; s++)
21740 m_solver->a_rightHandSide(cellId, CV->RHO_Y[s]) = F0;
21741 m_solver->a_pvariable(cellId, PV->VV[dimN]) = un_target;
21747template <MInt nDim,
class SysEqn>
21751 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function cbc2091d_after is untested for 3D!"); }
21753 const MInt otherDir[4] = {1, 0, 3, 2};
21755 MBool& first = m_static_cbc2091d_after_first;
21756 MInt& dirN = m_static_cbc2091d_after_dirN;
21757 MInt& dimN = m_static_cbc2091d_after_dimN;
21758 MInt& dimT1 = m_static_cbc2091d_after_dimT1;
21762 if(noCutOffDirections != noCutOffBndryIds)
21764 "Wrong number of cut off directions. Must be identical to number of cut off bndryIds! Please check!");
21765 MInt cutOffBndryIdTmp, cutOffDirectionTmp;
21766 for(
MInt i = 0; i < noCutOffBndryIds; i++) {
21767 cutOffBndryIdTmp = Context::getSolverProperty<MInt>(
"cutOffBndryIds", m_solverId, AT_, i);
21768 cutOffDirectionTmp = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, i);
21769 if(cutOffBndryIdTmp == m_cutOffBndryCndIds[bcId]) {
21770 dirN = otherDir[cutOffDirectionTmp];
21774 dimN = (
MInt)dirN / 2;
21775 dimT1 = (dimN + 1) % nDim;
21780 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21781 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21782 if(m_solver->a_isHalo(cellId))
continue;
21783 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21784 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21786 MInt bndryId = m_solver->a_bndryId(cellId);
21789 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
21793 MFloat rho = m_solver->a_variable(cellId, CV->RHO);
21794 MFloat u = m_solver->a_pvariable(cellId, PV->VV[dimN]);
21795 MFloat u_wrong = m_solver->a_variable(cellId, CV->RHO_VV[dimN]) / m_solver->a_variable(cellId, CV->RHO);
21796 MFloat v = m_solver->a_variable(cellId, CV->RHO_VV[dimT1]) / m_solver->a_variable(cellId, CV->RHO);
21797 MFloat p = sysEqn().pressure(rho, (u_wrong * u_wrong + v * v), m_solver->a_variable(cellId, CV->RHO_E));
21798 MFloat E = sysEqn().internalEnergy(p, rho, (u * u + v * v));
21800 m_solver->a_variable(cellId, CV->RHO_VV[dimN]) = rho * u;
21801 for(
MInt s = 0; s < m_solver->m_noSpecies; s++)
21802 m_solver->a_variable(cellId, CV->RHO_Y[s]) = rho * m_solver->a_pvariable(cellId, PV->Y[s]);
21803 m_solver->a_variable(cellId, CV->RHO_E) = E;
21813template <MInt nDim,
class SysEqn>
21815 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function cbc2099_1091_local_comb is untested for 3D!"); }
21818 if(m_sortedCutOffCells[bcId]->size() == 0) {
21822 MInt cbcId = m_cbcBndryCndIds[bcId];
21824 MInt dirN = m_cbcDir[cbcId][0];
21825 MInt dimN = m_cbcDir[cbcId][1];
21826 MInt dimT1 = m_cbcDir[cbcId][2];
21827 MInt dimT2 = m_cbcDir[cbcId][nDim];
21829 MFloat outFlowArea = m_cbcInflowArea[cbcId];
21831 MInt last = nDim + 1;
21848 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21849 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21850 MInt bndryId = m_solver->a_bndryId(cellId);
21852 if(m_solver->a_isHalo(cellId))
continue;
21853 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21854 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21860 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
21862 area = m_solver->a_surfaceArea(srfcId);
21864 mTerm(1, AT_,
"something went wrong!");
21866 IF_CONSTEXPR(nDim == 2) { area = m_solver->c_cellLengthAtCell(cellId); }
21868 area =
POW2(m_solver->c_cellLengthAtCell(cellId));
21872 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
21873 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
21874 const MFloat Temp = sysEqn().temperature_ES(rho, p);
21875 const MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
21877 massflux += un * area * rho;
21878 T_mean += Temp * area;
21879 rho_mean += rho * area;
21882 MFloat mach[2] = {F0, F0};
21883 cbcMachCo(bcId, mach);
21886 MInt noExchangeData = 2;
21889 comm_buff[0] = massflux;
21890 comm_buff[2] = T_mean;
21892 if(noDomains() > 1) {
21893 MPI_Allreduce(&comm_buff[0], &comm_buff_result[0], 2, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
21894 AT_,
"comm_buff[0]",
"comm_buff_result[0]");
21897 massflux = comm_buff_result[0];
21898 T_mean = comm_buff_result[1];
21899 T_mean /= outFlowArea;
21900 rho_mean /= outFlowArea;
21902 MFloat T_target = T_mean;
21903 MFloat p_Target = m_solver->m_PInfinity;
21905 m_solver->m_jetPressure = m_solver->m_PInfinity;
21906 m_solver->m_jetDensity = rho_mean;
21907 m_solver->m_jetTemperature = T_target;
21909 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->
size() : 1;
21912 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
21915 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
21916 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
21918 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
21919 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
21921 if(m_solver->a_isHalo(cellId))
continue;
21922 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
21923 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
21925 MInt bndryId = m_solver->a_bndryId(cellId);
21928 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
21931 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
21934 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
21935 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
21936 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
21937 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
21938 &cutOffStencilCellIds[0], &V[0]);
21941 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
21944 MFloat un_mean = m_solver->a_pvariable(cellId, PV->VV[dimN]);
21946 MBool isInflow =
true;
21947 if(dirN % 2 == 0) {
21961 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
21962 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
21963 const MFloat Temp = sysEqn().temperature_ES(rho, p);
21964 const MFloat a = sysEqn().speedOfSound(Temp);
21968 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
21969 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
21977 K[0] = K[0] /
a * m_sigmaNonRefl;
21981 if(dirN % 2 == 0) {
21983 K[0] * (p - p_Target) + (beta - 1) * (T[last] + ceta * rho *
a * T[1]) + (V[last] + ceta * rho *
a * V[1]);
21985 L[last] = K[last] * (p - p_Target) + (beta - 1) * (T[last] + ceta * rho *
a * T[1])
21986 + (V[last] + ceta * rho *
a * V[1]);
21990 cbcOutgoingAmplitudeVariation<0>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
21991 cbcDampingOutflow(cellId, bcId, maxM, &K[0]);
21993 K[0] = K[0] * m_sigmaNonRefl;
21996 MFloat deltaP = (p - p_Target);
21998 if(dirN % 2 == 0) {
21999 L[0] = K[0] * deltaP;
22001 L[last] = K[last] * deltaP;
22004 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
22014template <MInt nDim,
class SysEqn>
22017 MInt direction = m_cutOffBndryCndIds[bcId] - 2720;
22019 if(direction % 2) {
22025 const MInt noPVars = PV->noVariables;
22027 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
22028 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
22029 MLong nghbrId = m_solver->c_neighborId(cellId, direction);
22034 if(m_solver->c_noChildren(nghbrId) > 0) {
22035 MFloat coCoord = m_solver->a_coordinate(cellId, direction / 2);
22038 for(
MInt varId = 0; varId < noPVars; varId++) {
22039 for(
MInt i = 0; i < nDim; i++) {
22040 m_solver->a_slope(cellId, varId, i) = F0;
22043 for(
MInt child = 0; child <
IPOW2(nDim); child++) {
22044 MInt childId = m_solver->c_childId(nghbrId, child);
22048 if(abs(m_solver->a_coordinate(childId, direction / 2) - coCoord) > m_solver->c_cellLengthAtCell(cellId)) {
22052 for(
MInt varId = 0; varId < noPVars; varId++) {
22053 for(
MInt i = 0; i < nDim; i++) {
22054 m_solver->a_slope(cellId, varId, i) += m_solver->a_slope(childId, varId, i);
22058 for(
MInt varId = 0; varId < noPVars; varId++) {
22059 for(
MInt i = 0; i < nDim; i++) {
22060 m_solver->a_slope(cellId, varId, i) /= childCnt;
22065 for(
MInt varId = 0; varId < noPVars; varId++) {
22066 for(
MInt i = 0; i < nDim; i++) {
22067 m_solver->a_slope(cellId, varId, i) = m_solver->a_slope(nghbrId, varId, i);
22080template <MInt nDim,
class SysEqn>
22082 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function sbc2801x is untested for 3D!"); }
22085 MInt bndryId, cellId, ghostCellId;
22086 MFloat Frho, FrhoGhost, rhoU2;
22087 const MInt noPVars = PV->noVariables;
22092 Frho = FrhoGhost = rhoU2 = 0.0;
22094 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
22095 bndryId = m_sortedBndryCells->a[
id];
22096 cellId = m_bndryCells->a[bndryId].m_cellId;
22097 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
22098 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
22100 for(
MInt i = 0; i < nDim; i++) {
22101 PVbndry[i] = m_solver->a_variable(cellId, CV->RHO_VV[i]) * Frho;
22102 PVghost[i] = m_solver->a_variable(ghostCellId, CV->RHO_VV[i]) * FrhoGhost;
22106 PVbndry[PV->RHO] = m_solver->a_variable(cellId, CV->RHO);
22107 PVghost[PV->RHO] = m_solver->a_variable(ghostCellId, CV->RHO);
22111 for(
MInt i = 0; i < nDim; i++) {
22112 rhoU2 +=
POW2(m_solver->a_variable(cellId, CV->RHO_VV[i]));
22115 PVbndry[PV->P] = sysEqn().pressure(Frho, rhoU2, m_solver->a_variable(cellId, CV->RHO_E));
22117 for(
MInt i = 0; i < nDim; i++) {
22118 rhoU2 +=
POW2(m_solver->a_variable(ghostCellId, CV->RHO_VV[i]));
22120 PVbndry[PV->P] = sysEqn().pressure(FrhoGhost, rhoU2, m_solver->a_variable(ghostCellId, CV->RHO_E));
22123 for(
MInt k = 0; k < m_noSpecies; k++) {
22124 PVbndry[PV->Y[k]] = m_solver->a_variable(cellId, CV->RHO_Y[k]) * Frho;
22125 PVghost[PV->Y[k]] = m_solver->a_variable(ghostCellId, CV->RHO_Y[k]) * FrhoGhost;
22128 for(
MInt var = 0; var < noPVars; var++) {
22129 m_solver->a_slope(ghostCellId, var, 0) =
22130 (PVbndry[var] - PVghost[var])
22131 / (m_solver->a_coordinate(cellId, 0) - m_solver->a_coordinate(ghostCellId, 0));
22132 m_solver->a_slope(ghostCellId, var, 1) = m_solver->a_slope(cellId, var, 1);
22136 for(
MInt varId = 0; varId < noPVars; varId++) {
22137 for(
MInt i = 0; i < nDim; i++) {
22138 m_solver->a_slope(ghostCellId, varId, i) =
22139 F2 * m_solver->a_slope(ghostCellId, varId, i) - m_solver->a_slope(cellId, varId, i);
22151template <MInt nDim,
class SysEqn>
22153 IF_CONSTEXPR(!hasE<SysEqn>) {
22154 mTerm(1, AT_,
"Not compatible with SysEqn without RHO_E!");
22157 IF_CONSTEXPR(nDim == 3) { TERMM(-1,
"INFO: function sbc2801x is untested for 3D!"); }
22160 MInt bndryId, cellId, ghostCellId;
22161 MFloat Frho, FrhoGhost, rhoU2;
22162 const MInt noPVars = PV->noVariables;
22167 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
22168 bndryId = m_sortedBndryCells->a[
id];
22169 cellId = m_bndryCells->a[bndryId].m_cellId;
22170 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
22171 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[0]->m_ghostCellId;
22174 Frho = F1 / m_solver->a_variable(cellId, CV->RHO);
22175 FrhoGhost = F1 / m_solver->a_variable(ghostCellId, CV->RHO);
22177 for(
MInt i = 0; i < nDim; i++) {
22178 PVbndry[i] = m_solver->a_variable(cellId, CV->RHO_VV[i]) * Frho;
22179 PVghost[i] = m_solver->a_variable(ghostCellId, CV->RHO_VV[i]) * FrhoGhost;
22183 PVbndry[PV->RHO] = m_solver->a_variable(cellId, CV->RHO);
22184 PVghost[PV->RHO] = m_solver->a_variable(ghostCellId, CV->RHO);
22188 for(
MInt i = 0; i < nDim; i++) {
22189 rhoU2 +=
POW2(m_solver->a_variable(cellId, CV->RHO_VV[i]));
22192 PVbndry[PV->P] = sysEqn().pressure(1.0, rhoU2, m_solver->a_variable(cellId, CV->RHO_E));
22194 for(
MInt i = 0; i < nDim; i++) {
22195 rhoU2 +=
POW2(m_solver->a_variable(ghostCellId, CV->RHO_VV[i]));
22197 rhoU2 *= FrhoGhost;
22198 PVghost[PV->P] = sysEqn().pressure(1.0, rhoU2, m_solver->a_variable(ghostCellId, CV->RHO_E));
22201 for(
MInt k = 0; k < m_noSpecies; k++) {
22202 PVbndry[PV->Y[k]] = m_solver->a_variable(cellId, CV->RHO_Y[k]) * Frho;
22203 PVghost[PV->Y[k]] = m_solver->a_variable(ghostCellId, CV->RHO_Y[k]) * FrhoGhost;
22206 for(
MInt var = 0; var < noPVars; var++) {
22207 m_solver->a_slope(ghostCellId, var, 0) = m_solver->a_slope(cellId, var, 0);
22208 m_solver->a_slope(ghostCellId, var, 1) =
22209 (PVbndry[var] - PVghost[var])
22210 / (m_solver->a_coordinate(cellId, 1) - m_solver->a_coordinate(ghostCellId, 1));
22214 for(
MInt varId = 0; varId < noPVars; varId++) {
22215 for(
MInt i = 0; i < nDim; i++) {
22216 m_solver->a_slope(ghostCellId, varId, i) =
22217 F2 * m_solver->a_slope(ghostCellId, varId, i) - m_solver->a_slope(cellId, varId, i);
22230template <MInt nDim,
class SysEqn>
22232 IF_CONSTEXPR(nDim == 2) { TERMM(-1,
"INFO: function cbc3091a is untested for 2D!"); }
22236 MFloat that, twopioverlb;
22237 MFloat factor1, factor2, b1, b2;
22239 MFloat xhat, yhat, zhat;
22242 b1 = m_shearLayerThickness;
22243 b2 = m_shearLayerThickness;
22244 MFloat massfluxTest = F0, jetInflowArea = F0;
22247 m_log <<
"computing mass flux " << endl;
22249 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
22250 ghost1 = m_sortedCutOffCells[bcId]->a[
id];
22251 if(m_solver->a_isHalo(ghost1))
continue;
22253 MFloat jetArea =
POW2(m_solver->grid().cellLengthAtCell(ghost1));
22254 factor1 = m_solver->a_coordinate(ghost1, 0);
22255 factor2 = m_solver->a_coordinate(ghost1, 2);
22257 velocity = m_solver->m_Ma
22258 * (F1B2 * (1 + tanh(b1 * (factor1 + m_solver->m_jetHalfWidth)))
22259 * (1 - tanh(b1 * (factor1 - m_solver->m_jetHalfWidth)))
22261 * (F1B2 * (1 + tanh(b2 * (factor2 + m_solver->m_jetHalfLength)))
22262 * (1 - tanh(b2 * (factor2 - m_solver->m_jetHalfLength)))
22264 massfluxTest += m_solver->a_variable(ghost1, PV->RHO) * velocity * jetArea;
22265 jetInflowArea += jetArea;
22268 MPI_Allreduce(MPI_IN_PLACE, &massfluxTest, 1, MPI_DOUBLE, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
"massfluxTest");
22269 MPI_Allreduce(MPI_IN_PLACE, &jetInflowArea, 1, MPI_DOUBLE, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
22274 massfluxTest /= jetInflowArea;
22276 m_solver->m_jetPressure = m_solver->m_PInfinity;
22277 m_solver->m_jetDensity = m_solver->m_rhoInfinity;
22278 m_solver->m_jetTemperature = sysEqn().temperature_ES(m_solver->m_jetDensity, m_solver->m_jetPressure);
22279 m_log <<
"calculated pressure" << m_solver->m_jetPressure << endl;
22280 m_log <<
"calculated density" << m_solver->m_jetDensity << endl;
22281 m_log <<
"calculated temperature at inflow " << m_solver->m_jetTemperature << endl;
22282 m_log <<
"calculated massflux" << massfluxTest << endl;
22285 if(m_sortedCutOffCells[bcId]->size() == 0) {
22289 dummyTime = m_solver->m_time / m_bc1601->m_tau_b;
22291 m_bc1601->checkRegeneration(dummyTime);
22293 that = 2.0 * PI * dummyTime;
22294 twopioverlb = 2.0 * PI / m_bc1601->m_l_b;
22297 MInt cbcId = m_cbcBndryCndIds[bcId];
22299 MInt dirN = m_cbcDir[cbcId][0];
22300 MInt dimN = m_cbcDir[cbcId][1];
22301 MInt dimT1 = m_cbcDir[cbcId][2];
22302 MInt dimT2 = m_cbcDir[cbcId][nDim];
22304 MBool solverProfile = Context::getSolverProperty<MBool>(
"solverProfile", m_solverId, AT_, &solverProfile);
22305 MFloat inflowArea = m_cbcInflowArea[cbcId];
22308 MInt last = nDim + 1;
22321 MFloat mach[2] = {F0, F0};
22322 cbcMachCo(bcId, mach);
22328 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
22329 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
22330 MInt bndryId = m_solver->a_bndryId(cellId);
22332 if(m_solver->a_isHalo(cellId))
continue;
22333 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
22334 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
22340 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
22342 area = m_solver->a_surfaceArea(srfcId);
22344 mTerm(1, AT_,
"something went wrong!");
22346 area = m_solver->c_cellLengthAtCell(cellId);
22349 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
22350 const MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
22351 const MFloat y = (m_solver->a_coordinate(cellId, dimT1) - m_cbcReferencePoint[cbcId][dimT1]);
22352 testSum2 += area *
y *
y;
22353 massflux += un * rho * area;
22356 MInt noExchangeData = 2;
22359 comm_buff[0] = massflux;
22360 comm_buff[1] = testSum2;
22362 if(noDomains() > 1) {
22363 MPI_Allreduce(&comm_buff[0], &comm_buff_result[0], 3, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
22364 AT_,
"comm_buff[0]",
"comm_buff_result[0]");
22367 massflux = comm_buff_result[0];
22368 testSum2 = comm_buff_result[1];
22370 const MFloat TInfinity = m_solver->m_TInfinity;
22371 const MFloat PInfinity = m_solver->m_PInfinity;
22374 const MFloat massflux_target = m_solver->m_VInfinity * inflowArea * sysEqn().density_ES(PInfinity, TInfinity);
22375 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->
size() : 1;
22378 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
22381 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
22382 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
22384 MFloat T_target = sysEqn().temperature_IR(m_solver->m_Ma);
22386 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
22387 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
22389 if(m_solver->a_isHalo(cellId))
continue;
22390 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
22391 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
22393 MInt bndryId = m_solver->a_bndryId(cellId);
22395 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
22398 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
22401 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
22402 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
22403 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
22404 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
22405 &cutOffStencilCellIds[0], &V[0]);
22408 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
22409 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
22410 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"velocity");
22412 MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
22413 MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
22414 MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
22415 MFloat p = m_solver->a_pvariable(cellId, PV->P);
22416 MFloat temp = sysEqn().temperature_ES(rho, p);
22417 MFloat a = sysEqn().speedOfSound(rho, p);
22419 factor1 = m_solver->a_coordinate(cellId, dimT1);
22420 IF_CONSTEXPR(nDim == 3) { factor2 = m_solver->a_coordinate(cellId, dimT2); }
22422 xhat = twopioverlb * m_solver->a_coordinate(cellId, dimN);
22423 yhat = twopioverlb * m_solver->a_coordinate(cellId, dimT1);
22424 IF_CONSTEXPR(nDim == 2) { zhat = F0; }
22425 IF_CONSTEXPR(nDim == 3) { zhat = twopioverlb * m_solver->a_coordinate(cellId, dimT2); }
22426 fluctChol[dimN] = 0;
22427 fluctChol[dimT1] = 0;
22428 fluctChol[dimT2] = 0;
22430 m_bc1601->calculateFlucts(that, xhat, yhat, zhat, fluctChol);
22432 fluctChol[dimT1] *= (F1B2 * (1 + tanh(b1 * (factor1 + m_solver->m_jetHalfWidth)))
22433 * (1 - tanh(b1 * (factor1 - m_solver->m_jetHalfWidth)))
22435 fluctChol[dimT1] *= (F1B2 * (1 + tanh(b2 * (factor2 + m_solver->m_jetHalfLength)))
22436 * (1 - tanh(b2 * (factor2 - m_solver->m_jetHalfLength)))
22438 IF_CONSTEXPR(nDim == 3) {
22439 fluctChol[dimT2] *= (F1B2 * (1 + tanh(b1 * (factor1 + m_solver->m_jetHalfWidth)))
22440 * (1 - tanh(b1 * (factor1 - m_solver->m_jetHalfWidth)))
22442 fluctChol[dimT2] *= (F1B2 * (1 + tanh(b2 * (factor2 + m_solver->m_jetHalfLength)))
22443 * (1 - tanh(b2 * (factor2 - m_solver->m_jetHalfLength)))
22447 ut1_target = fluctChol[dimT1];
22448 MFloat un_target = (velocity + fluctChol[1])
22449 * (F1B2 * (1 + tanh(b1 * (factor1 + m_solver->m_jetHalfWidth)))
22450 * (1 - tanh(b1 * (factor1 - m_solver->m_jetHalfWidth)))
22452 * (F1B2 * (1 + tanh(b2 * (factor2 + m_solver->m_jetHalfLength)))
22453 * (1 - tanh(b2 * (factor2 - m_solver->m_jetHalfLength)))
22457 if(solverProfile) un_target = massflux_target / inflowArea / rho;
22459 if(dirN % 2 == 0) {
22460 L[0] = -F1 * K[0] * (un - un_target) + (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
22462 L[last] = K[last] * (un - un_target) + (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
22465 L[1] = K[1] * (temp - T_target) + (
a *
a * T[0] - T[last]) - V[last];
22466 L[2] = K[2] * (ut1 - ut1_target) + T[2] + V[2];
22467 IF_CONSTEXPR(nDim == 3) {
22468 MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
22469 MFloat ut2_target = fluctChol[dimT2];
22470 L[3] = K[3] * (ut2 - ut2_target) + T[3] + V[3];
22473 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
22474 for(
MInt s = 0; s < m_solver->m_noSpecies; s++)
22475 m_solver->a_rightHandSide(cellId, CV->RHO_Y[s]) = F0;
22496template <MInt nDim,
class SysEqn>
22499 IF_CONSTEXPR(nDim == 2) TERMM(1,
"3D BC!");
22501 if(m_bndryCndCells[bcId] == m_bndryCndCells[bcId + 1]) {
22505 MInt cellId, bndryId;
22513 MFloat referencePoint[3] = {0.0, 0.0, 0.0};
22514 MFloat normal[3] = {0.0, 0.0, 0.0};
22519 MInt minTimeSteps = m_static_bc1091MGC_minTimeSteps;
22520 MInt nghbrDir = m_static_bc1091MGC_nghbrDir;
22525 MInt noBndryCndCells = m_bndryCndCells[bcId + 1] - m_bndryCndCells[bcId];
22526 MIntScratchSpace edgeCells_scratch(noBndryCndCells, AT_,
"edgeCells_scratch");
22527 MFloatScratchSpace edgeDistance_scratch(noBndryCndCells, AT_,
"edgeDistance_scratch");
22528 MIntScratchSpace edgeSurface_scratch(noBndryCndCells, AT_,
"edgeSurface_scratch");
22529 MInt edgeCellCounter = m_static_bc1091MGC_edgeCellCounter;
22530 MInt first = m_static_bc1091MGC_first;
22531 MInt first2 = m_static_bc1091MGC_first2;
22545 minTimeSteps = Context::getSolverProperty<MInt>(
"InflowMinTimeSteps", m_solverId, AT_, &minTimeSteps);
22553 nghbrDir = Context::getSolverProperty<MInt>(
"InflowNghbrDir", m_solverId, AT_, &nghbrDir);
22557 m_static_bc1091MGC_first2 = first2;
22560 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
22561 cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
22562 bndryId = m_solver->a_bndryId(cellId);
22563 if(m_solver->a_hasProperty(cellId,
22564 SolverCell::IsNotGradient)) {
22567 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
22568 for(
MInt srfc = 0; srfc < m_bndryCells->a[m_sortedBndryCells->a[
id]].m_noSrfcs; srfc++) {
22570 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
22572 massflux -= (((m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->U])
22573 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
22574 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[0]
22575 + (m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->V])
22576 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
22577 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[1]
22578 + (m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->W])
22579 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
22580 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[2])
22581 * (m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->RHO]));
22583 if(nghbrDir > -1) {
22587 nghbrId = m_solver->c_neighborId(cellId, nghbrDir);
22588 massflux -= (((m_solver->a_pvariable(nghbrId, PV->U)) * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
22589 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[0]
22590 + (m_solver->a_pvariable(nghbrId, PV->V)) * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
22591 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[1]
22592 + (m_solver->a_pvariable(nghbrId, PV->W)) * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area
22593 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[2])
22594 * (m_solver->a_pvariable(nghbrId, PV->RHO)));
22596 inflowArea += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area;
22599 for(
MInt i = 0; i < 3; i++) {
22600 referencePoint[i] += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i]
22601 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area;
22602 normal[i] += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i]
22603 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area;
22610 comm_buff[0] = inflowArea;
22611 comm_buff[1] = referencePoint[0];
22612 comm_buff[2] = referencePoint[1];
22613 comm_buff[3] = referencePoint[2];
22614 comm_buff[4] = massflux;
22616 if(noDomains() > 1) {
22617 MPI_Allreduce(comm_buff, comm_buff_result, 5, MPI_DOUBLE, MPI_SUM, m_comm_bc[m_bc_comm_pointer[bcId]], AT_,
22618 "comm_buff",
"comm_buff_result");
22621 inflowArea = comm_buff_result[0];
22622 referencePoint[0] = comm_buff_result[1];
22623 referencePoint[1] = comm_buff_result[2];
22624 referencePoint[2] = comm_buff_result[3];
22625 massflux = comm_buff_result[4];
22627 for(
MInt i = 0; i < 3; i++) {
22628 referencePoint[i] /= inflowArea;
22629 normal[i] /= inflowArea;
22637 referencePoint[0] = 0.0;
22638 referencePoint[2] = 0.0;
22642 if(nghbrDir > -1) {
22643 massflux /= (2.0 * inflowArea);
22645 massflux /= (inflowArea);
22649 if(abs(massflux) < epsilon * inflowArea ||
globalTimeStep < minTimeSteps) {
22654 meanPressure = sysEqn().p_Ref();
22655 for(
MInt i = 0; i < 20; i++) {
22656 meanPressure = sysEqn().pressure_IRit(meanPressure, massflux);
22658 meanPressure = meanPressure * sysEqn().p_Ref();
22659 meanDensity = sysEqn().density_IR_P(meanPressure);
22660 meanVelocity = massflux / meanDensity;
22662 R = sqrt(inflowArea / PI);
22666 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
22667 cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
22668 bndryId = m_solver->a_bndryId(cellId);
22669 if(m_solver->a_hasProperty(cellId,
22670 SolverCell::IsNotGradient)) {
22673 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
22674 if(m_bndryCells->a[bndryId].m_noSrfcs > 1) {
22675 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
22676 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId != m_bndryCndIds[bcId]) {
22677 edgeCells_scratch[edgeCellCounter] = bndryId;
22678 edgeSurface_scratch[edgeCellCounter] = srfc;
22685 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
22686 cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
22687 bndryId = m_solver->a_bndryId(cellId);
22688 if(m_solver->a_hasProperty(cellId,
22689 SolverCell::IsNotGradient)) {
22692 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
22693 for(
MInt srfc = 0; srfc < m_bndryCells->a[m_sortedBndryCells->a[
id]].m_noSrfcs; srfc++) {
22695 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
22696 edgeDistance_scratch[
id - m_bndryCndCells[bcId]] = F2 * R;
22697 for(
MInt ec = 0; ec < edgeCellCounter; ec++) {
22699 for(
MInt d = 0; d < nDim; d++) {
22701 (m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[d]
22702 - m_bndryCells->a[edgeCells_scratch[ec]].m_srfcs[srfc]->m_coordinates[d])
22703 * (m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[d]
22704 - m_bndryCells->a[edgeCells_scratch[ec]].m_srfcs[edgeSurface_scratch[ec]]->m_coordinates[d]);
22706 distCur = sqrt(distCur);
22707 if(distCur < edgeDistance_scratch[
id - m_bndryCndCells[bcId]]) {
22708 edgeDistance_scratch[
id - m_bndryCndCells[bcId]] = distCur;
22718 m_static_bc1091MGC_first = first;
22725 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
22726 cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
22727 bndryId = m_solver->a_bndryId(cellId);
22728 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
22729 for(
MInt srfc = 0; srfc < m_bndryCells->a[m_sortedBndryCells->a[
id]].m_noSrfcs; srfc++) {
22731 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
22733 radius =
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[0] - referencePoint[0])
22734 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[1] - referencePoint[1])
22735 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[2] - referencePoint[2]);
22736 Vdot += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area * 2.0 * meanVelocity
22737 * (1.0 - radius /
POW2(edgeDistance_scratch[
id - m_bndryCndCells[bcId]] + sqrt(radius)));
22742 if(abs(meanVelocity) > epsilon * inflowArea && abs(Vdot / inflowArea) > epsilon * inflowArea) {
22743 K = meanVelocity / Vdot * inflowArea;
22748 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
22749 cellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_cellId;
22750 bndryId = m_solver->a_bndryId(cellId);
22751 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
22752 for(
MInt srfc = 0; srfc < m_bndryCells->a[m_sortedBndryCells->a[
id]].m_noSrfcs; srfc++) {
22754 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == m_bndryCndIds[bcId]) {
22755 ghostCellId = m_bndryCells->a[m_sortedBndryCells->a[
id]].m_srfcVariables[srfc]->m_ghostCellId;
22758 radius =
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[0] - referencePoint[0])
22759 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[1] - referencePoint[1])
22760 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[2] - referencePoint[2]);
22761 localVelocity = 2.0 * meanVelocity * (1.0 - radius /
POW2(R));
22763 localVelocity = 2.0 * meanVelocity * K
22764 * (1.0 - radius /
POW2(edgeDistance_scratch[
id - m_bndryCndCells[bcId]] + sqrt(radius)));
22767 localVelocity = -((m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->U])
22768 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[0]
22769 + (m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->V])
22770 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[1]
22771 + (m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->W])
22772 * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[2])
22773 * (m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->RHO]) / meanDensity;
22778 m_solver->a_pvariable(ghostCellId, PV->RHO) =
22779 F2 * meanDensity - m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->RHO];
22780 m_solver->a_pvariable(ghostCellId, PV->P) =
22781 F2 * meanPressure - m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->P];
22782 m_solver->a_pvariable(ghostCellId, PV->U) =
22783 -F2 * localVelocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[0]
22784 - m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->U];
22785 m_solver->a_pvariable(ghostCellId, PV->V) =
22786 -F2 * localVelocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[1]
22787 - m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->V];
22788 m_solver->a_pvariable(ghostCellId, PV->W) =
22789 -F2 * localVelocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[2]
22790 - m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->W];
22793 if(m_surfaceGhostCell) {
22794 m_solver->a_pvariable(ghostCellId, PV->RHO) = meanDensity;
22795 m_solver->a_pvariable(ghostCellId, PV->P) = meanPressure;
22796 m_solver->a_pvariable(ghostCellId, PV->U) =
22797 -localVelocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[0];
22798 m_solver->a_pvariable(ghostCellId, PV->W) =
22799 -localVelocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[2];
22800 m_solver->a_pvariable(ghostCellId, PV->V) =
22801 -localVelocity * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[1];
22809 cerr <<
" ReferencePoint, R, normal, Massflux, pressure, density, velocity: " << referencePoint[0] <<
" "
22810 << referencePoint[1] <<
" " << referencePoint[2] <<
", " << R <<
", " << normal[0] <<
" " << normal[1] <<
" "
22811 << normal[2] <<
", " << massflux <<
", " << meanPressure <<
", " << meanDensity <<
", " << meanVelocity
22832template <MInt nDim,
class SysEqn>
22835 IF_CONSTEXPR(nDim == 2) TERMM(1,
"3D BC!");
22837 MInt cellId, bndryId, ghostCellId;
22845 MFloat& timeOfMaxPdiff = m_static_bc1099MGC_timeOfMaxPdiff;
22846 MBool& first = m_static_bc1099MGC_first;
22848 timeOfMaxPdiff = Context::getSolverProperty<MFloat>(
"timeOfMaxPdiff", m_solverId, AT_, &timeOfMaxPdiff);
22850 timeOfMaxPdiff = timeOfMaxPdiff / m_solver->m_timeRef;
22853 MFloat Pdiff = m_deltaPL;
22855 if(m_solver->m_time < timeOfMaxPdiff) fac = m_solver->m_time / timeOfMaxPdiff;
22856 const MFloat initialPressure = sysEqn().p_Ref() - Pdiff;
22857 const MFloat deltaPressure = m_solver->m_PInfinity - sysEqn().p_Ref();
22862 for(
MInt id = m_bndryCndCells[bcId];
id < m_bndryCndCells[bcId + 1];
id++) {
22863 bndryId = m_sortedBndryCells->a[
id];
22864 cellId = m_bndryCells->a[bndryId].m_cellId;
22866 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
22868 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
22869 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId != m_bndryCndIds[bcId]) {
22872 ghostCellId = m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_ghostCellId;
22873 m_solver->a_pvariable(ghostCellId, PV->P) =
22874 F2 * (initialPressure + fac * deltaPressure)
22875 - m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->P];
22878 if(m_surfaceGhostCell) m_solver->a_pvariable(ghostCellId, PV->P) = (initialPressure + fac * deltaPressure);
22882 m_solver->a_pvariable(ghostCellId, PV->RHO) =
22883 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->RHO];
22884 m_solver->a_pvariable(ghostCellId, PV->U) =
22885 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->U];
22886 m_solver->a_pvariable(ghostCellId, PV->V) =
22887 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->V];
22888 m_solver->a_pvariable(ghostCellId, PV->W) =
22889 m_bndryCells->a[bndryId].m_srfcVariables[srfc]->m_imageVariables[PV->W];
22904template <MInt nDim,
class SysEqn>
22908 if(m_sortedCutOffCells[bcId]->size() == 0) {
22912 MInt cbcId = m_cbcBndryCndIds[bcId];
22914 MInt dirN = m_cbcDir[cbcId][0];
22915 MInt dimN = m_cbcDir[cbcId][1];
22916 MInt dimT1 = m_cbcDir[cbcId][2];
22917 MInt dimT2 = m_cbcDir[cbcId][nDim];
22919 MFloat inflowArea = m_cbcInflowArea[cbcId];
22920 MFloat targetPressure = sysEqn().p_Ref();
22921 MInt last = nDim + 1;
22923 const MFloat R = sqrt(inflowArea / PI);
22924 const MFloat gammaMinusOne = m_solver->m_gamma - 1.0;
22925 const MFloat ut1_target = F0;
22941 MFloat massflux_pos = F0;
22942 MFloat massflux_neg = F0;
22944 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
22945 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
22946 MInt bndryId = m_solver->a_bndryId(cellId);
22948 if(m_solver->a_isHalo(cellId))
continue;
22949 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
22950 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
22956 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
22958 area = m_solver->a_surfaceArea(srfcId);
22960 mTerm(1, AT_,
"something went wrong!");
22963 area =
POW2(m_solver->c_cellLengthAtCell(cellId));
22966 MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
22967 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
22968 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
22969 const MFloat un_N = m_solver->a_pvariable(nghbrN, PV->VV[dimN]);
22970 const MFloat Temp = sysEqn().temperature_ES(rho, p);
22972 const MFloat rsquare =
POW2(m_solver->a_coordinate(cellId, 0) - m_cbcReferencePoint[cbcId][0])
22973 +
POW2(m_solver->a_coordinate(cellId, 1) - m_cbcReferencePoint[cbcId][1])
22974 +
POW2(m_solver->a_coordinate(cellId, 2) - m_cbcReferencePoint[cbcId][2]);
22976 testSum2 += area * rsquare;
22977 massflux += un_N * area;
22978 T_mean += Temp * area;
22981 massflux_pos += un_N * area;
22983 massflux_neg += un_N * area;
22987 MFloat mach[2] = {F0, F0};
22988 cbcMachCo(bcId, mach);
22992 MInt noExchangeData = 5;
22995 comm_buff[0] = massflux;
22996 comm_buff[1] = testSum2;
22997 comm_buff[2] = T_mean;
22998 comm_buff[3] = massflux_pos;
22999 comm_buff[4] = massflux_neg;
23001 if(noDomains() > 1) {
23002 MPI_Allreduce(&comm_buff[0], &comm_buff_result[0], 5, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]],
23003 AT_,
"comm_buff[0]",
"comm_buff_result[0]");
23006 massflux = comm_buff_result[0];
23007 testSum2 = comm_buff_result[2];
23008 T_mean = comm_buff_result[3];
23009 massflux_pos = comm_buff_result[4];
23010 massflux_neg = comm_buff_result[5];
23011 T_mean /= inflowArea;
23012 MFloat massflux_test = F2 * (F1 - testSum2 / (inflowArea * R * R));
23013 MFloat un_correctionFactor = F1;
23014 if(fabs(massflux_test) > m_solver->m_eps) un_correctionFactor = F1 / massflux_test;
23016 MFloat T_target = 1 - gammaMinusOne * F1B2 * (massflux * massflux / inflowArea / inflowArea);
23017 MFloat p_Target = sysEqn().pressure_IR(T_target);
23019 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
23022 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
23025 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
23026 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
23028 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
23029 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
23031 if(m_solver->a_isHalo(cellId))
continue;
23032 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
23033 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
23035 MInt bndryId = m_solver->a_bndryId(cellId);
23037 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
23040 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
23043 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
23044 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
23045 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
23046 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
23047 &cutOffStencilCellIds[0], &V[0]);
23050 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
23052 const MFloat rsquare =
POW2(m_solver->a_coordinate(cellId, 0) - m_cbcReferencePoint[cbcId][0])
23053 +
POW2(m_solver->a_coordinate(cellId, 1) - m_cbcReferencePoint[cbcId][1])
23054 +
POW2(m_solver->a_coordinate(cellId, 2) - m_cbcReferencePoint[cbcId][2]);
23057 MFloat un_mean = m_solver->a_pvariable(cellId, PV->VV[dimN]);
23059 MBool isInflow =
true;
23060 if(dirN % 2 == 0) {
23064 T_target = abs(massflux_neg) / (abs(massflux_neg) + abs(massflux_pos)) * T_target
23065 + abs(massflux_pos) / (abs(massflux_neg) + abs(massflux_pos)) * T_mean;
23071 T_target = abs(massflux_pos) / (abs(massflux_neg) + abs(massflux_pos)) * T_target
23072 + abs(massflux_neg) / (abs(massflux_neg) + abs(massflux_pos)) * T_mean;
23076 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
23077 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
23078 MFloat a = sysEqn().speedOfSound(rho, p);
23080 const MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
23081 const MFloat Temp = sysEqn().temperature_ES(rho, p);
23083 targetPressure = p_Target;
23086 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
23087 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
23095 if(dirN % 2 == 0) {
23096 L[0] = K[0] * (p - targetPressure) + (T[last] + ceta * rho *
a * T[1]) + (V[last] + ceta * rho *
a * V[1]);
23099 K[last] * (p - targetPressure) + (T[last] + ceta * rho *
a * T[1]) + (V[last] + ceta * rho *
a * V[1]);
23101 L[1] = K[1] * (Temp - T_target) + (
a *
a * T[0] - T[last]) + (
a *
a * V[0] - V[last]);
23102 L[2] = K[2] * (ut1 - ut1_target) + T[2] + V[2];
23103 IF_CONSTEXPR(nDim == 3) {
23104 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
23105 const MFloat ut2_target = F0;
23106 L[3] = K[3] * (ut2 - ut2_target) + T[3] + V[3];
23111 cbcOutgoingAmplitudeVariation<0>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
23112 cbcDampingOutflow(cellId, bcId, maxM, &K[0]);
23121 L[0] = K[0] * (p - targetPressure) + (F1 - beta) * (T[last] + ceta * rho *
a * T[1])
23122 + (V[last] + ceta * rho *
a * V[1]);
23124 L[last] = K[last] * (p - targetPressure) + (F1 - beta) * (T[last] + ceta * rho *
a * T[1])
23125 + (V[last] + ceta * rho *
a * V[1]);
23127 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
23129 MFloat un_target = F2 * massflux / inflowArea * (F1 - rsquare / (R * R)) * un_correctionFactor;
23130 m_solver->a_pvariable(cellId, PV->VV[dimN]) = un_target;
23144template <MInt nDim,
class SysEqn>
23147 IF_CONSTEXPR(nDim == 2) TERMM(1, "3D BC!");
23149 if(m_sortedCutOffCells[bcId]->size() == 0) return;
23151 const
MInt otherDir[6] = {1, 0, 3, 2, 5, 4};
23153 MBool& first = m_static_cbc1099_1091d_after_first;
23154 MInt& dirN = m_static_cbc1099_1091d_after_dirN;
23155 MInt& dimN = m_static_cbc1099_1091d_after_dimN;
23156 MFloat& interpolationFactor = m_static_cbc1099_1091d_after_interpolationFactor;
23161 if(noCutOffDirections != noCutOffBndryIds)
23163 "Wrong number of cut off directions. Must be identical to number of cut off bndryIds! Please check!");
23164 MInt cutOffBndryIdTmp, cutOffDirectionTmp;
23165 for(
MInt i = 0; i < noCutOffBndryIds; i++) {
23166 cutOffBndryIdTmp = Context::getSolverProperty<MInt>(
"cutOffBndryIds", m_solverId, AT_, i);
23167 cutOffDirectionTmp = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, i);
23168 if(cutOffBndryIdTmp == m_cutOffBndryCndIds[bcId]) {
23169 dirN = otherDir[cutOffDirectionTmp];
23173 dimN = (
MInt)dirN / 2;
23186 interpolationFactor =
23187 Context::getSolverProperty<MFloat>(
"inOutInterpolationFactor", m_solverId, AT_, &interpolationFactor);
23193 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
23196 if(m_solver->a_isHalo(cellId))
continue;
23197 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
23198 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
23201 MFloat rho = m_solver->a_variable(cellId, CV->RHO);
23202 MFloat u_target = m_solver->a_pvariable(cellId, PV->VV[dimN]);
23203 MFloat u_rungeKutta = m_solver->a_variable(cellId, CV->RHO_VV[dimN]) / m_solver->a_variable(cellId, CV->RHO);
23204 MFloat deltaU = u_target - u_rungeKutta;
23205 MFloat u_corrected = u_rungeKutta + deltaU * interpolationFactor;
23207 m_solver->a_variable(cellId, CV->RHO_VV[dimN]) = rho * u_corrected;
23208 m_solver->a_pvariable(cellId, PV->VV[dimN]) = u_corrected;
23218template <MInt nDim,
class SysEqn>
23222 if(m_sortedCutOffCells[bcId]->size() == 0) {
23228 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
23229 const MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
23231 ASSERT(fabs(m_solver->a_rightHandSide(cellId, CV->RHO)) < m_solver->m_eps,
"");
23232 ASSERT(fabs(m_solver->a_rightHandSide(cellId, CV->RHO_VV[0])) < m_solver->m_eps,
"");
23233 ASSERT(fabs(m_solver->a_rightHandSide(cellId, CV->RHO_VV[1])) < m_solver->m_eps,
"");
23234 ASSERT(fabs(m_solver->a_rightHandSide(cellId, CV->RHO_E)) < m_solver->m_eps,
"");
23235 IF_CONSTEXPR(nDim == 3)
23236 ASSERT(fabs(m_solver->a_rightHandSide(cellId, CV->RHO_VV[2])) < m_solver->m_eps,
"");
23267 MInt cbcId = m_cbcBndryCndIds[bcId];
23269 MInt dirN = m_cbcDir[cbcId][0];
23270 MInt dimN = m_cbcDir[cbcId][1];
23271 MInt dimT1 = m_cbcDir[cbcId][2];
23272 MInt dimT2 = m_cbcDir[cbcId][nDim];
23274 MFloat inflowArea = m_cbcInflowArea[cbcId];
23275 inflowArea = inflowArea * m_dirTangent[cbcId][dimT1];
23277 MInt last = nDim + 1;
23296 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
23297 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
23298 MInt bndryId = m_solver->a_bndryId(cellId);
23300 if(m_solver->a_isHalo(cellId))
continue;
23301 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
23302 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
23308 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
23310 area = m_solver->a_surfaceArea(srfcId);
23311 IF_CONSTEXPR(nDim == 3) ASSERT(area <=
POW2(m_solver->c_cellLengthAtCell(cellId)),
"");
23313 for(
MInt dir = 0; dir < m_noDirs; dir++) {
23314 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dir];
23315 if(srfcId > -1)
break;
23318 mTerm(1, AT_,
"something went wrong!");
23320 area = m_solver->a_surfaceArea(srfcId);
23323 IF_CONSTEXPR(nDim == 2) area = m_solver->c_cellLengthAtCell(cellId);
23324 IF_CONSTEXPR(nDim == 3) area =
POW2(m_solver->c_cellLengthAtCell(cellId));
23327 ASSERT(area > 0,
"");
23330 area = area * m_dirTangent[cbcId][dimT1];
23332 m_solver->setPrimitiveVariables(cellId);
23334 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
23335 MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
23340 if(m_solver->checkNeighborActive(cellId, dirN) && m_solver->a_hasNeighbor(cellId, dirN)) {
23341 const MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
23343 if(m_dirNormal[cbcId][0] > -2) {
23344 for(
MInt n = 0; n < nDim; n++) {
23345 un_N += m_solver->a_variable(nghbrN, CV->RHO_VV[n]) / m_solver->a_variable(nghbrN, CV->RHO)
23346 * m_dirNormal[cbcId][n];
23349 un_N = m_solver->a_variable(nghbrN, CV->RHO_VV[dimN]) / m_solver->a_variable(nghbrN, CV->RHO);
23352 if(std::isnan(un_N)) {
23353 cerr <<
"NAN detected in cutOff-Neighbor! " << endl;
23356 T_N = sysEqn().temperature_ES(m_solver->a_variable(nghbrN, CV->RHO), m_solver->a_pvariable(nghbrN, PV->P));
23359 if(rho < F0 || std::isnan(rho) || std::isnan(un)) {
23360 cerr <<
"NAN detected in cutOff-Cell " << m_solver->c_globalId(cellId) <<
" " << m_solver->a_isHalo(cellId) <<
" "
23361 << m_solver->a_bndryId(cellId) <<
" " << rho <<
" " << bcId << endl;
23365 massflux += un_N * area;
23366 T_mean += T_N * area;
23367 rho_mean += rho * area;
23368 rho_min =
mMin(rho, rho_min);
23369 rho_max =
mMax(rho, rho_max);
23372 MInt noExchangeData = 3;
23374 comm_buff[0] = massflux;
23375 comm_buff[1] = T_mean;
23376 comm_buff[2] = rho_mean;
23378 if(noDomains() > 1) {
23379 MPI_Allreduce(MPI_IN_PLACE, &comm_buff[0], noExchangeData, MPI_DOUBLE, MPI_SUM,
23380 m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
"MPI_IN_PLACE",
"comm_buff[0]");
23381 MPI_Allreduce(MPI_IN_PLACE, &rho_max, 1, MPI_DOUBLE, MPI_MAX, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
23382 "MPI_IN_PLACE",
"rho_max");
23383 MPI_Allreduce(MPI_IN_PLACE, &rho_min, 1, MPI_DOUBLE, MPI_MIN, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
23384 "MPI_IN_PLACE",
"rho_min");
23387 massflux = comm_buff[0];
23388 T_mean = comm_buff[1];
23389 rho_mean = comm_buff[2];
23391 T_mean /= inflowArea;
23392 rho_mean /= inflowArea;
23394 MFloat mach[2] = {F0, F0};
23395 cbcMachCo(bcId, mach);
23400 MFloat T_out = sysEqn().temperature_IR(massflux / inflowArea);
23401 MFloat p_out = sysEqn().pressure_IR(T_out);
23402 if(p_out / sysEqn().p_Ref() > 1) p_out = sysEqn().p_Ref();
23403 if(T_out > 1) T_out = 1;
23404 const MFloat p_target = p_out;
23406 if(dirN % 2 == 1) {
23412 if(
globalTimeStep % 10 == 0 && m_solver->m_RKStep == 0 && domainId() == m_cbcDomainMin[cbcId]) {
23414 <<
" M_mean, M_max, T_target, p_target, rho_mean, massflux, T_mean, rho_min, rho_max" << setprecision(9)
23415 << meanM <<
", " << maxM <<
", " << T_target <<
", " << p_target <<
", " << rho_mean <<
", " << rho_min <<
", "
23416 << rho_max <<
", " << massflux <<
" " << T_mean << endl;
23440 ASSERT(!std::isnan(massflux),
"ERROR: Mass-flux is nan!");
23442 MInt noCutOffBCCells = m_cbcViscous ? m_sortedCutOffCells[bcId]->size() : 1;
23445 MFloatScratchSpace gradTau(m_cbcViscous ? (nDim * nDim * nDim) : 1, AT_,
"gradTau");
23448 MIntScratchSpace cutOffStencilCellIds(m_cbcViscous ? m_solver->a_noCells() : 1, AT_,
"cutOffStencilCellIds");
23449 if(m_cbcViscous) cbcTauQ(bcId, &tau[0], &q[0], &cutOffStencilCellIds[0]);
23451 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
23452 MInt cellId = m_sortedCutOffCells[bcId]->a[
id];
23454 if(m_solver->a_isHalo(cellId))
continue;
23455 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
23456 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
23460 MFloat ut_N[nDim - 1] = {0};
23463 if(m_solver->checkNeighborActive(cellId, dirN) && m_solver->a_hasNeighbor(cellId, dirN)) {
23464 const MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
23466 for(
MInt n = 0; n < nDim; n++) {
23467 un_N += m_solver->a_variable(nghbrN, CV->RHO_VV[n]) * m_dirNormal[cbcId][n];
23468 ut_N[0] += m_solver->a_variable(nghbrN, CV->RHO_VV[n]) * m_dirTangent[cbcId][n];
23470 IF_CONSTEXPR(nDim == 3) { ut_N[1] = m_solver->a_variable(nghbrN, CV->RHO_VV[dimT2]); }
23473 MInt bndryId = m_solver->a_bndryId(cellId);
23475 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
23478 cbcGradients(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0]);
23481 cbcGradientsViscous(cellId, bcId, &tau[0], &q[0], &gradTau[0], &gradQ[0], &cutOffStencilCellIds[0]);
23482 gradTau[dimN *
IPOW2(nDim) + dimT1 * nDim + dimN] = F0;
23483 IF_CONSTEXPR(nDim == 3) { gradTau[dimN *
IPOW2(nDim) + dimT2 * nDim + dimN] = F0; }
23484 cbcViscousTerms<(unsigned char)01111>(cellId, bcId, &tau[0], &gradTau[0], &gradQ[0], &gradVV[0],
23485 &cutOffStencilCellIds[0], &V[0]);
23488 cbcTransversalTerms<(unsigned char)11111>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &T[0]);
23492 IF_CONSTEXPR(nDim == 3) { eddy = (
POW2(ut_N[0]) +
POW2(ut_N[1])) /
POW2(un_N); }
23494 MBool isInflow =
true;
23495 if(dirN % 2 == 0) {
23505 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
23508 for(
MInt n = 0; n < nDim; n++) {
23509 ut1 += m_solver->a_pvariable(cellId, PV->VV[n]) * m_dirTangent[cbcId][n];
23512 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
23513 MFloat a = sysEqn().speedOfSound(rho, p);
23514 const MFloat Temp = sysEqn().temperature_ES(rho, p);
23517 cbcOutgoingAmplitudeVariation<1>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
23518 cbcDampingInflow(cellId, bcId, maxM, &K[0],
"pressure");
23520 if(dirN % 2 == 0) {
23521 L[0] = K[0] * (p - p_target) + (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
23523 L[last] = K[last] * (p - p_target) + (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
23526 L[1] = K[1] * (Temp - T_target) + (
a *
a * T[0] - T[last]) - V[last];
23527 L[2] = K[2] * ut1 + T[2] + V[2];
23528 IF_CONSTEXPR(nDim == 3) {
23529 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
23530 L[3] = K[3] * ut2 + T[3] + V[3];
23533 MBool limitVariable =
false;
23534 if(m_solver->a_pvariable(cellId, PV->RHO) > 1.0000001) {
23535 m_solver->a_pvariable(cellId, PV->RHO) = 1;
23536 limitVariable =
true;
23538 if(m_solver->a_pvariable(cellId, PV->P) / sysEqn().p_Ref() > 1.0000001) {
23539 m_solver->a_pvariable(cellId, PV->P) = sysEqn().p_Ref();
23540 limitVariable =
true;
23543 if(limitVariable) {
23544 m_solver->setConservativeVariables(cellId);
23550 cbcOutgoingAmplitudeVariation<0>(cellId, bcId, &gradRho[0], &gradVV[0], &gradP[0], &gradY[0], &L[0]);
23551 cbcDampingOutflow(cellId, bcId, maxM, &K[0]);
23555 if(!m_solver->m_engineSetup) {
23560 if(fabs(massflux) > 0.05) {
23565 L[2] = K[2] * ut1 + T[2] + V[2];
23566 IF_CONSTEXPR(nDim == 3) {
23567 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
23568 L[3] = K[3] * ut2 + T[3] + V[3];
23574 if(dirN % 2 == 0) {
23575 L[0] = K[0] * (p - p_target) + (F1 - beta) * (T[last] - rho *
a * T[1]) + (V[last] - rho *
a * V[1]);
23577 L[last] = K[last] * (p - p_target) + (F1 - beta) * (T[last] + rho *
a * T[1]) + (V[last] + rho *
a * V[1]);
23581 if(dirN % 2 != 0 && fabs(massflux) < 0.05 && m_solver->m_engineSetup) {
23582 const MFloat K2_outflow = m_cbcRelax[cbcId][1] * rho *
a / m_cbcLref[cbcId];
23583 L[1] = K2_outflow * (Temp - T_target) + (
a *
a * T[0] - T[last]) - V[last];
23587 cbcRHS(cellId, bcId, &L[0], &T[0], &V[0]);
23596template <MInt nDim,
class SysEqn>
23600 for(
auto it = m_sortedCutOffCells.begin(); it != m_sortedCutOffCells.end(); it++) {
23604 m_sortedCutOffCells.clear();
23613template <MInt nDim,
class SysEqn>
23617 m_static_cbc1099_first =
true;
23618 m_static_cbc1091_first =
true;
23619 m_static_cbc2091a_first =
true;
23620 m_static_cbc1091b_first =
true;
23621 m_static_cbc2091b_first =
true;
23622 m_static_cbc1091c_first =
true;
23623 m_static_cbc1091c_after_first =
true;
23624 m_static_cbc1091d_first =
true;
23625 m_static_cbc1091d_after_first =
true;
23626 m_static_cbc2091d_first =
true;
23627 m_static_cbc2091d_after_first =
true;
23628 m_static_cbc1091e_first =
true;
23629 m_static_cbc1099_1091_local_first =
true;
23630 m_static_cbc1099_1091_local_comb_first =
true;
23631 m_static_cbc2099_1091_local_comb_first =
true;
23632 m_static_cbc3091a_first =
true;
23633 m_static_cbc1099_1091_engine_first =
true;
23634 IF_CONSTEXPR(nDim == 3) {
23635 m_static_cbc1099_1091d_first =
true;
23636 m_static_cbc1099_1091d_after_first =
true;
23641template <MInt nDim,
class SysEqn>
23644 if(m_comm_bc_init > 0) {
23645 for(
MInt i = 0; i < m_comm_bc_init; i++) {
23646 if(m_comm_bc[i] != MPI_COMM_NULL && m_comm_bc[i] != MPI_COMM_WORLD) {
23652 if(m_comm_bcCo_init > 0) {
23653 for(
MInt i = 0; i < m_comm_bcCo_init; i++) {
23654 if(m_comm_bcCo[i] != MPI_COMM_NULL && m_comm_bcCo[i] != MPI_COMM_WORLD) {
23689template <MInt nDim,
class SysEqn>
23690template <
class _, std::enable_if_t<nDim == 2, _*>>
23694 const MInt otherDir[2] = {1, 0};
23695 const MInt faceOrder[4] = {2, 1, 3, 0};
23696 const MFloat signCode[2][4] = {{-F1, F1, F1, -F1}, {-F1, -F1, F1, F1}};
23699 for(
MInt bndryId = 0; bndryId < m_bndryCells->size(); bndryId++) {
23700 MInt cellId = m_bndryCells->a[bndryId].m_cellId;
23702 for(
MInt f = 0; f < m_noDirs; f++) {
23703 m_bndryCells->a[bndryId].m_externalFaces[f] =
false;
23706 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints != 2) {
23707 cerr <<
"** FvBndryCnd2D ERROR" << endl;
23708 cerr <<
"boundary cell " << bndryId << endl;
23709 cerr << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 1) << endl;
23710 cerr << m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints
23711 <<
" -> number of cut points is not equal two - multiple body surfaces not implemented!" << endl;
23715 const MFloat cellLength = m_solver->c_cellLengthAtCell(cellId);
23716 const MFloat cellHalfLength = F1B2 * cellLength;
23718 if(!m_solver->c_isLeafCell(cellId) || (!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))) {
23719 m_bndryCells->a[bndryId].m_volume = m_solver->grid().gridCellVolume(m_solver->a_level(cellId));
23720 for(
MInt i = 0; i < nDim; i++) {
23721 m_bndryCells->a[bndryId].m_coordinates[i] = F0;
23723 m_bndryCells->a[bndryId].m_noSrfcs = 0;
23727 MInt noCutPoints = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
23729 MInt cutPointIds[4] = {-1, -1, -1, -1};
23730 MInt edgeCutPointCounter[4] = {0, 0, 0, 0};
23731 for(
MInt cp = 0; cp < noCutPoints; cp++) {
23732 MInt edge = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cp];
23733 ASSERT(edgeCutPointCounter[edge] == 0,
"");
23734 cutPointIds[edge] = cp;
23735 edgeCutPointCounter[edge]++;
23740 MInt pointBodyId[8];
23741 MInt pointEdgeId[8];
23743 for(
MInt n = 0; n < 4; n++) {
23744 MFloat cornerPoint[2] = {F0, F0};
23745 for(
MInt d = 0; d < nDim; d++)
23746 cornerPoint[d] = m_solver->a_coordinate(cellId, d) + signCode[d][n] * cellHalfLength;
23747 if(!m_solver->m_geometry->pointIsInside(cornerPoint)) {
23748 for(
MInt d = 0; d < nDim; d++)
23749 coords[noNodes * 2 + d] = cornerPoint[d];
23750 pointBodyId[noNodes] = -1;
23751 pointEdgeId[noNodes] =
23755 MInt cpId = cutPointIds[faceOrder[n]];
23757 for(
MInt d = 0; d < nDim; d++)
23758 coords[noNodes * 2 + d] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cpId][d];
23759 pointBodyId[noNodes] = m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[cpId];
23760 pointEdgeId[noNodes] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cpId];
23770 computePolygon(coords, noNodes, centroid, &volume);
23773 MInt lineSegments[8][2];
23775 MInt edgeLinePointer[4] = {
23778 MInt bodyLinePointer[4] = {
23781 MInt bodyLineCounter = 0;
23782 for(
MInt segment = 0; segment < noNodes; segment++) {
23783 MInt firstPoint = segment;
23784 MInt secondPoint = (segment + 1) % noNodes;
23785 lineSegments[segment][0] = firstPoint;
23786 lineSegments[segment][1] = secondPoint;
23787 if(pointBodyId[firstPoint] == -1 && pointBodyId[secondPoint] == -1) {
23789 edgeLinePointer[pointEdgeId[firstPoint]] = segment;
23790 lineTypes[segment] = -2;
23791 }
else if(pointBodyId[firstPoint] == -1 || pointBodyId[secondPoint] == -1) {
23793 edgeLinePointer[pointEdgeId[firstPoint]] = segment;
23794 lineTypes[segment] = -1;
23797 bodyLinePointer[bodyLineCounter] = segment;
23798 lineTypes[segment] = bodyLineCounter++;
23800 if(bodyLineCounter > 1) {
23801 cerr << to_string(m_solver->c_cellLengthAtCell(cellId)) << endl;
23802 cerr << to_string(m_solver->c_cellLengthAtCell(cellId)) << endl;
23809 for(
MInt dir = 0; dir < m_noDirs; dir++) {
23811 MInt sideId = dir % 2;
23812 MInt spaceId = dir / 2;
23813 MInt tDir = otherDir[spaceId];
23814 for(
MInt j = 0; j < nDim; j++) {
23815 surfCoords[j] = m_solver->a_coordinate(cellId, j);
23817 surfCoords[spaceId] += signCode[0][sideId] * cellHalfLength;
23819 MInt segmentId = edgeLinePointer[edge];
23820 if(segmentId == -1) {
23822 m_bndryCells->a[bndryId].m_externalFaces[dir] =
true;
23823 cutFaceAreas[dir] = F0;
23825 MInt lineType = lineTypes[segmentId];
23826 if(lineType == -2) {
23828 cutFaceAreas[dir] = cellLength;
23831 MInt point1 = lineSegments[segmentId][0];
23832 MInt point2 = lineSegments[segmentId][1];
23833 MFloat pointDiff = coords[point2 * 2 + tDir] - coords[point1 * 2 + tDir];
23834 cutFaceAreas[dir] = fabs(pointDiff);
23835 surfCoords[tDir] = coords[point1 * 2 + tDir] + F1B2 * pointDiff;
23839 MBool createSrfc =
true;
23841 if(m_solver->a_hasNeighbor(cellId, dir) > 0) {
23842 nghbrId = m_solver->c_neighborId(cellId, dir);
23844 if(m_solver->c_parentId(cellId) > -1) {
23845 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId), dir) > 0)
23846 nghbrId = m_solver->c_neighborId(m_solver->c_parentId(cellId), dir);
23848 createSrfc =
false;
23850 createSrfc =
false;
23853 if(m_solver->c_noChildren(nghbrId) > 0) createSrfc =
false;
23855 MInt srfcId = m_solver->a_noSurfaces();
23856 m_surfaces.append();
23857 m_solver->a_surfaceOrientation(srfcId) = spaceId;
23858 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
23859 m_solver->a_surfaceNghbrCellId(srfcId, otherDir[sideId]) = cellId;
23860 m_solver->a_surfaceArea(srfcId) = cutFaceAreas[dir];
23861 for(
MInt i = 0; i < nDim; i++) {
23862 m_solver->a_surfaceCoordinate(srfcId, i) = surfCoords[i];
23864 m_bndryCells->a[bndryId].m_associatedSrfc[dir] = srfcId;
23868 ASSERT(bodyLineCounter == 1,
"");
23869 m_bndryCells->a[bndryId].m_noSrfcs = 1;
23871 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
23872 MInt segmentId = bodyLinePointer[srfc];
23873 ASSERT(segmentId > -1,
"");
23874 MInt point1 = lineSegments[segmentId][0];
23875 MInt point2 = lineSegments[segmentId][1];
23880 MFloat surfaceCoordinates[2];
23882 MFloat deltaX = coords[point2 * 2] - coords[point1 * 2];
23883 MFloat deltaY = coords[point2 * 2 + 1] - coords[point1 * 2 + 1];
23884 area = sqrt(deltaX * deltaX + deltaY * deltaY);
23885 normal[0] = -deltaY /
mMax(m_solver->m_eps, area);
23886 normal[1] = deltaX /
mMax(m_solver->m_eps, area);
23887 surfaceCoordinates[0] = coords[point1 * 2 + 0] + F1B2 * deltaX;
23888 surfaceCoordinates[1] = coords[point1 * 2 + 1] + F1B2 * deltaY;
23891 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_noCutPoints = 2;
23892 for(
MInt i = 0; i < nDim; i++) {
23893 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_cutCoordinates[0][i] = coords[point1 * 2 + i];
23894 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_cutCoordinates[1][i] = coords[point2 * 2 + i];
23896 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_cutEdge[0] = pointEdgeId[point1];
23897 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_cutEdge[1] = pointEdgeId[point2];
23898 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bodyId[0] = pointBodyId[point1];
23899 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bodyId[1] = pointBodyId[point2];
23902 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area = area;
23903 for(
MInt i = 0; i < nDim; i++) {
23904 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i] = normal[i];
23905 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i] = surfaceCoordinates[i];
23909 m_bndryCells->a[bndryId].m_volume = volume;
23910 for(
MInt i = 0; i < nDim; i++) {
23911 m_bndryCells->a[bndryId].m_coordinates[i] = centroid[i] - m_solver->a_coordinate(cellId, i);
23915 MFloat areaCheck[2] = {F0, F0};
23916 const MFloat checkEps = 1e-12;
23917 for(
MInt i = 0; i < nDim; i++) {
23918 areaCheck[i] += (cutFaceAreas[2 * i] - cutFaceAreas[2 * i + 1]);
23920 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
23921 for(
MInt i = 0; i < nDim; i++) {
23923 m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area * m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
23926 MBool checkPassed = ((fabs(areaCheck[0]) < checkEps) && (fabs(areaCheck[1]) < checkEps));
23928 cerr <<
"** FvBndryCnd2D WARNING" << endl;
23929 cerr <<
"boundary cell " << bndryId << endl;
23930 cerr << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 1) << endl;
23931 cerr <<
" -> boundary cell check not passed! " << endl;
23932 cerr <<
" area check: " << areaCheck[0] <<
" " << areaCheck[1] << endl;
23962template <MInt nDim,
class SysEqn>
23963template <
class _, std::enable_if_t<nDim == 3, _*>>
23967 static constexpr MInt edgeCode[24] = {8, 10, 0, 4, 9, 11, 1, 5, 2, 6, 8, 9, 3, 7, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7};
23968 static constexpr MInt faceCode[24] = {0, 4, 1, 4, 2, 4, 3, 4, 0, 5, 1, 5, 2, 5, 3, 5, 0, 2, 1, 2, 0, 3, 1, 3};
23971 MBoolScratchSpace faceGeometryIsTriangle(m_noDirs, AT_,
"faceGeometryIsTriangle");
23974 MBool positiveSlope;
23977 MInt face0 = 0, face1 = 0;
23978 const MInt noCells = m_bndryCells->size();
23991 MFloat* delta = delta_scratch.getPointer();
23996 MFloat negativePoint[3] = {0, 0, 0};
23997 MFloat oppositePoint[3] = {0, 0, 0};
23998 MFloat point[3] = {0, 0, 0};
23999 MFloat pointP[3] = {0, 0, 0};
24000 MFloat pointM[3] = {0, 0, 0};
24001 MFloat pointW[3] = {0, 0, 0};
24002 MFloat pointE[3] = {0, 0, 0};
24003 MFloat pointBR[3] = {0, 0, 0};
24004 MFloat pointTL[3] = {0, 0, 0};
24005 MFloat rectVolume, triVolume;
24006 MFloat trianglePoint[3] = {0, 0, 0};
24007 MFloat trianglePointP[3] = {0, 0, 0};
24008 MFloat trianglePointM[3] = {0, 0, 0};
24009 MFloat trianglePointW[3] = {0, 0, 0};
24010 MFloat trianglePointE[3] = {0, 0, 0};
24013 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
24014 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
24015 MInt noCutFaces = 0;
24016 m_bndryCells->a[bndryId].m_noSrfcs = 1;
24018 for(
MInt f = 0; f < m_noDirs; f++) {
24019 m_bndryCells->a[bndryId].m_externalFaces[f] =
false;
24023 fill_n(&cutEdgesAll[0], m_noEdges,
false);
24024 fill_n(&nonFluidSideEdge[0], m_noEdges,
false);
24025 fill_n(&cutPointOnEdge[0], m_noEdges, -1);
24026 fill_n(&cutFaces[0], m_noDirs,
false);
24027 fill_n(&faceGeometryIsTriangle[0], m_noDirs,
false);
24028 fill_n(&shapeIsInside[0], m_noDirs,
false);
24030 const MFloat eps = m_solver->c_cellLengthAtCell(cellId) * 0.00001;
24032 if(!m_solver->c_isLeafCell(cellId) || (!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))) {
24033 m_bndryCells->a[bndryId].m_volume = m_solver->grid().gridCellVolume(m_solver->a_level(cellId));
24034 for(
MInt i = 0; i < nDim; i++) {
24035 m_bndryCells->a[bndryId].m_coordinates[i] = F0;
24037 m_bndryCells->a[bndryId].m_noSrfcs = 0;
24042 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
24043 cutPointOnEdge[m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cp]] = cp;
24050 for(
MInt face = 0; face < m_noDirs; face++) {
24053 for(
MInt e = 0; e < 4; e++) {
24054 MInt cp = cutPointOnEdge[edgeCode[4 * face + e]];
24058 cutEdgesAll[edgeCode[4 * face + e]] =
true;
24064 cutFaces[face] =
true;
24068 if(n == 1 || n > 2) {
24069 cerr <<
"** ERROR create cut face: " << n <<
" cut points for face " << face << endl;
24070 stringstream errorMessage;
24071 errorMessage <<
"create cut face: " << n <<
" cut points for face " << face;
24072 cerr <<
"cell " <<
cellId <<
" cog " << m_solver->a_coordinate(cellId, 0) <<
" "
24073 << m_solver->a_coordinate(cellId, 1) <<
" " << m_solver->a_coordinate(cellId, 2) << endl;
24074 cerr <<
"level " << m_solver->a_level(cellId) << endl;
24075 cerr <<
"edges that get cut: " << endl;
24076 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
24077 cerr << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cp] << endl;
24080 stringstream fileName;
24081 fileName <<
"multipleCutCell_" <<
cellId <<
".stl";
24082 cerr <<
"Writing stl-file of cell " <<
cellId <<
" to " << (fileName.str()) << endl;
24083 writeStlFileOfCell(cellId, (fileName.str()).c_str());
24085 mTerm(1, AT_, errorMessage.str());
24088 const MInt spaceId = face / 2;
24089 const MInt sideId = face % 2;
24090 const MInt spaceId1 = (spaceId + 1) % nDim;
24091 const MInt spaceId2 = (spaceId1 + 1) % nDim;
24093 const MInt nDimFaceSpaceId1 = nDim * face + spaceId1;
24094 const MInt nDimFaceSpaceId2 = nDim * face + spaceId2;
24096 gridFaceVolume[face] =
POW2(m_solver->c_cellLengthAtCell(cellId));
24097 faceVolume[face] = gridFaceVolume[face];
24100 for(
MInt i = 0; i < nDim; i++) {
24101 point[i] = m_solver->a_coordinate(cellId, i) - F1B2 * m_solver->c_cellLengthAtCell(cellId);
24102 negativePoint[i] = point[i];
24103 oppositePoint[i] = point[i] + m_solver->c_cellLengthAtCell(cellId);
24107 point[spaceId] += (
MFloat)sideId * m_solver->c_cellLengthAtCell(cellId);
24108 oppositePoint[spaceId] = point[spaceId];
24109 pointBR[spaceId] = point[spaceId];
24110 pointTL[spaceId] = point[spaceId];
24112 pointBR[spaceId1] = oppositePoint[spaceId1];
24113 pointBR[spaceId2] = point[spaceId2];
24114 pointTL[spaceId1] = point[spaceId1];
24115 pointTL[spaceId2] = oppositePoint[spaceId2];
24118 for(
MInt i = 0; i < nDim; i++) {
24119 pointP[i] = point[i];
24120 pointM[i] = point[i];
24121 pointW[i] = point[i];
24122 pointE[i] = point[i];
24124 pointP[spaceId1] += eps;
24125 pointM[spaceId1] -= eps;
24126 pointW[spaceId2] += eps;
24127 pointE[spaceId2] -= eps;
24129 pointInside = m_solver->m_geometry->pointIsInside2(point);
24131 MBool pointBRInside_ =
false;
24132 MBool pointTLInside_ =
false;
24135 auto pointBRInside = [
this, &pointBRInside_, &pointBR]() {
24136 static MFloat lastPoint[3] = {MFloatNaN, MFloatNaN, MFloatNaN};
24138 if(std::equal(&pointBR[0], &pointBR[0] + nDim, &lastPoint[0])) {
24139 return pointBRInside_;
24142 pointBRInside_ = m_solver->m_geometry->pointIsInside2(pointBR);
24143 std::copy_n(&pointBR[0], nDim, &lastPoint[0]);
24144 return pointBRInside_;
24148 auto pointTLInside = [
this, &pointTLInside_, &pointTL]() {
24149 static MFloat lastPoint[3] = {MFloatNaN, MFloatNaN, MFloatNaN};
24150 if(std::equal(&pointTL[0], &pointTL[0] + nDim, &lastPoint[0])) {
24151 return pointTLInside_;
24153 pointTLInside_ = m_solver->m_geometry->pointIsInside2(pointTL);
24154 std::copy_n(&pointTL[0], nDim, &lastPoint[0]);
24155 return pointTLInside_;
24163 const MInt BRInCorner[6] = {2, 3, 4, 6, 1, 5};
24164 const MInt TLInCorner[6] = {4, 5, 1, 3, 2, 6};
24165 const MInt pointInCorner[6] = {0, 1, 0, 2, 0, 4};
24166 const MInt oppositeInCorner[6] = {6, 7, 5, 7, 3, 7};
24181 MBool bndryRfnJump =
false;
24182 bndryRfnJump = Context::getSolverProperty<MBool>(
"bndryRfnJump", m_solverId, AT_, &bndryRfnJump);
24184 if(bndryRfnJump == 1) {
24186 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] == face
24187 || m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] == face
24188 || m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3] == face) {
24189 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] == BRInCorner[face]) {
24190 if(pointBRInside() ==
false) {
24191 pointBRInside_ =
true;
24193 pointBRInside_ =
false;
24196 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] == TLInCorner[face]) {
24197 if(pointTLInside() ==
false) {
24198 pointTLInside_ =
true;
24200 pointTLInside_ =
false;
24203 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] == pointInCorner[face]) {
24204 if(pointInside ==
false) {
24205 pointInside =
true;
24207 pointInside =
false;
24215 faceCentroid[face * nDim + spaceId] = point[spaceId];
24219 for(
MInt i = 0; i < nDim; i++) {
24220 delta[face * nDim + i] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoint[0]][i]
24221 - m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoint[1]][i];
24223 if(delta[nDimFaceSpaceId1] * delta[nDimFaceSpaceId2] > 0) {
24224 positiveSlope =
true;
24226 positiveSlope =
false;
24229 for(
MInt i = 0; i < nDim; i++) {
24230 delta[face * nDim + i] = fabs(delta[face * nDim + i]);
24234 cutLineLength[face] = sqrt(
POW2(delta[nDimFaceSpaceId1]) +
POW2(delta[nDimFaceSpaceId2]));
24237 for(
MInt i = 0; i < nDim; i++) {
24238 cutLineCentroid[face * nDim + i] =
24240 * (m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoint[0]][i]
24241 + m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoint[1]][i]);
24249 const MInt space0Relative = cutEdges[0] / 2;
24250 const MInt space1Relative = cutEdges[1] / 2;
24251 const MInt space0 = (space0Relative + spaceId + 1) % nDim;
24252 const MInt side0 = cutEdges[0] % 2;
24253 const MInt space1 = (space1Relative + spaceId + 1) % nDim;
24254 const MInt side1 = cutEdges[1] % 2;
24257 normalVector[face * nDim + spaceId] = 0;
24258 normalVector[nDimFaceSpaceId1] = delta[nDimFaceSpaceId2] / cutLineLength[face];
24259 normalVector[nDimFaceSpaceId2] = delta[nDimFaceSpaceId1] / cutLineLength[face];
24266 if(space0 != space1) {
24268 faceGeometryIsTriangle[face] =
true;
24269 faceVolume[face] = F1B2 * (delta[nDimFaceSpaceId1] * delta[nDimFaceSpaceId2]);
24271 trianglePoint[space0] = point[space0] + m_solver->c_cellLengthAtCell(cellId) * (
MFloat)side0;
24272 trianglePoint[space1] = point[space1] + m_solver->c_cellLengthAtCell(cellId) * (
MFloat)side1;
24273 trianglePoint[spaceId] = point[spaceId];
24275 for(
MInt i = 0; i < nDim; i++) {
24276 trianglePointP[i] = trianglePoint[i];
24277 trianglePointM[i] = trianglePoint[i];
24278 trianglePointW[i] = trianglePoint[i];
24279 trianglePointE[i] = trianglePoint[i];
24281 trianglePointP[spaceId1] += eps;
24282 trianglePointM[spaceId1] -= eps;
24283 trianglePointW[spaceId2] += eps;
24284 trianglePointE[spaceId2] -= eps;
24286 faceCentroid[face * nDim + space0] =
24287 trianglePoint[space0] + F2B3 * (F1B2 - (
MFloat)side0) * delta[face * nDim + space0];
24288 faceCentroid[face * nDim + space1] =
24289 trianglePoint[space1] + F2B3 * (F1B2 - (
MFloat)side1) * delta[face * nDim + space1];
24291 for(
MInt i = 0; i < nDim; i++) {
24292 triangleCentroid[face * nDim + i] = faceCentroid[face * nDim + i];
24296 MBool problemFace =
false;
24297 if(bndryRfnJump == 1) {
24298 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 0] == face) {
24301 problemFace =
true;
24304 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 2] == face) {
24307 problemFace =
true;
24310 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 3] == face) {
24313 problemFace =
true;
24316 MInt triangleCase = -1;
24317 MBool trianglePointInside =
false;
24318 if(bndryRfnJump == 1) {
24319 if(m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1] != -1) {
24320 if(trianglePoint[0] - point[0] < eps && trianglePoint[1] - point[1] < eps
24321 && trianglePoint[2] - point[2] < eps) {
24324 trianglePointInside = pointInside;
24326 if(trianglePoint[0] - pointBR[0] < eps && trianglePoint[1] - pointBR[1] < eps
24327 && trianglePoint[2] - pointBR[2] < eps && triangleCase == -1) {
24330 trianglePointInside = pointBRInside();
24332 if(trianglePoint[0] - pointTL[0] < eps && trianglePoint[1] - pointTL[1] < eps
24333 && trianglePoint[2] - pointTL[2] < eps && triangleCase == -1) {
24336 trianglePointInside = pointTLInside();
24338 if(triangleCase == -1) {
24341 trianglePointInside = m_solver->m_geometry->pointIsInside2(trianglePoint);
24343 if(oppositeInCorner[face]
24344 == m_solver->m_bndryRfnJumpInformation[m_bndryCells->a[bndryId].m_cellId * 4 + 1]) {
24345 trianglePointInside = 1 - trianglePointInside;
24351 if(problemFace ==
true) {
24355 if(trianglePointInside ==
false) {
24357 noNonFluidEdges[face] = 2;
24358 nonFluidSideEdge[edgeCode[4 * face + 2 * space0Relative + ((side0 + 1) % 2)]] =
true;
24359 nonFluidSideEdge[edgeCode[4 * face + 2 * space1Relative + ((side1 + 1) % 2)]] =
true;
24363 shapeIsInside[face] =
true;
24364 cutOutVolume = faceVolume[face];
24365 faceVolume[face] = gridFaceVolume[face] - faceVolume[face];
24366 faceCentroid[face * nDim + space0] = F1 / faceVolume[face]
24367 * ((gridFaceVolume[face] * m_solver->a_coordinate(cellId, space0))
24368 - (cutOutVolume * faceCentroid[face * nDim + space0]));
24369 faceCentroid[face * nDim + space1] = F1 / faceVolume[face]
24370 * ((gridFaceVolume[face] * m_solver->a_coordinate(cellId, space1))
24371 - (cutOutVolume * faceCentroid[face * nDim + space1]));
24374 noNonFluidEdges[face] = 0;
24376 for(
MInt e = 0; e < 4; e++) {
24377 if(nonFluidSideEdge[edgeCode[4 * face + e]]) {
24378 cerr <<
"triangle case: " << triangleCase << endl;
24379 for(
MInt i = 0; i < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; i++) {
24380 cerr <<
"cut point: " << i <<
" cut edge: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[i]
24383 cerr <<
cellId <<
" " << bndryId << endl;
24384 cerr <<
"Error non-fluid edge was true for edge " << edgeCode[4 * face + e] <<
" face " << face
24386 cerr <<
"All face data " << noNonFluidEdges[0] << noNonFluidEdges[1] << noNonFluidEdges[2]
24387 << noNonFluidEdges[3] << noNonFluidEdges[4] << noNonFluidEdges[5] << endl;
24388 cerr <<
"All edge data " << nonFluidSideEdge[edgeCode[0]] << nonFluidSideEdge[edgeCode[1]]
24389 << nonFluidSideEdge[edgeCode[2]] << nonFluidSideEdge[edgeCode[3]] <<
" "
24390 << nonFluidSideEdge[edgeCode[4]] << nonFluidSideEdge[edgeCode[5]]
24391 << nonFluidSideEdge[edgeCode[6]] << nonFluidSideEdge[edgeCode[7]] <<
" "
24392 << nonFluidSideEdge[edgeCode[8]] << nonFluidSideEdge[edgeCode[9]]
24393 << nonFluidSideEdge[edgeCode[10]] << nonFluidSideEdge[edgeCode[11]] << endl;
24394 cerr <<
"cell " <<
cellId <<
" domain " << domainId() <<
" "
24395 <<
"bndryId " << bndryId <<
" " << m_solver->a_coordinate(cellId, 0) <<
" "
24396 << m_solver->a_coordinate(cellId, 1) <<
" " << m_solver->a_coordinate(cellId, 2) << endl;
24397 cerr <<
" " << endl;
24399 nonFluidSideEdge[edgeCode[4 * face + e]] =
false;
24403 if(problemFace ==
false) {
24406 if(m_solver->m_geometry->pointIsInside2(trianglePoint)) {
24408 shapeIsInside[face] =
true;
24409 cutOutVolume = faceVolume[face];
24410 faceVolume[face] = gridFaceVolume[face] - faceVolume[face];
24411 faceCentroid[face * nDim + space0] = F1 / faceVolume[face]
24412 * ((gridFaceVolume[face] * m_solver->a_coordinate(cellId, space0))
24413 - (cutOutVolume * faceCentroid[face * nDim + space0]));
24414 faceCentroid[face * nDim + space1] = F1 / faceVolume[face]
24415 * ((gridFaceVolume[face] * m_solver->a_coordinate(cellId, space1))
24416 - (cutOutVolume * faceCentroid[face * nDim + space1]));
24419 noNonFluidEdges[face] = 0;
24421 for(
MInt e = 0; e < 4; e++) {
24422 if(nonFluidSideEdge[edgeCode[4 * face + e]]) {
24423 cerr <<
cellId <<
" " << bndryId << endl;
24424 cerr <<
"Error non-fluid edge was true for edge " << edgeCode[4 * face + e] <<
" face " << face
24426 cerr <<
"All face data " << noNonFluidEdges[0] << noNonFluidEdges[1] << noNonFluidEdges[2]
24427 << noNonFluidEdges[3] << noNonFluidEdges[4] << noNonFluidEdges[5] << endl;
24428 cerr <<
"All edge data " << nonFluidSideEdge[edgeCode[0]] << nonFluidSideEdge[edgeCode[1]]
24429 << nonFluidSideEdge[edgeCode[2]] << nonFluidSideEdge[edgeCode[3]] <<
" "
24430 << nonFluidSideEdge[edgeCode[4]] << nonFluidSideEdge[edgeCode[5]]
24431 << nonFluidSideEdge[edgeCode[6]] << nonFluidSideEdge[edgeCode[7]] <<
" "
24432 << nonFluidSideEdge[edgeCode[8]] << nonFluidSideEdge[edgeCode[9]]
24433 << nonFluidSideEdge[edgeCode[10]] << nonFluidSideEdge[edgeCode[11]] << endl;
24434 cerr <<
"cell " <<
cellId <<
" domain " << domainId() <<
" "
24435 <<
"bndryId " << bndryId <<
" " << m_solver->a_coordinate(cellId, 0) <<
" "
24436 << m_solver->a_coordinate(cellId, 1) <<
" " << m_solver->a_coordinate(cellId, 2) << endl;
24437 cerr <<
" " << endl;
24438 cerr <<
"triangle case: " << triangleCase << endl;
24439 for(
MInt i = 0; i < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; i++) {
24440 cerr <<
"cut point: " << i <<
" cut edge: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[i]
24444 nonFluidSideEdge[edgeCode[4 * face + e]] =
false;
24449 noNonFluidEdges[face] = 2;
24450 nonFluidSideEdge[edgeCode[4 * face + 2 * space0Relative + ((side0 + 1) % 2)]] =
true;
24451 nonFluidSideEdge[edgeCode[4 * face + 2 * space1Relative + ((side1 + 1) % 2)]] =
true;
24456 if(pointTLInside()) {
24457 if(pointBRInside()) {
24459 normalVector[nDimFaceSpaceId1] = -normalVector[nDimFaceSpaceId1];
24460 normalVector[nDimFaceSpaceId2] = -normalVector[nDimFaceSpaceId2];
24463 normalVector[nDimFaceSpaceId2] = -normalVector[nDimFaceSpaceId2];
24466 if(pointBRInside()) {
24468 normalVector[nDimFaceSpaceId1] = -normalVector[nDimFaceSpaceId1];
24471 normalVector[nDimFaceSpaceId1] = -normalVector[nDimFaceSpaceId1];
24472 normalVector[nDimFaceSpaceId2] = -normalVector[nDimFaceSpaceId2];
24476 if(pointTLInside()) {
24477 if(pointBRInside()) {
24481 normalVector[nDimFaceSpaceId2] = -normalVector[nDimFaceSpaceId2];
24484 if(pointBRInside()) {
24486 normalVector[nDimFaceSpaceId1] = -normalVector[nDimFaceSpaceId1];
24494 noNonFluidEdges[face] = 1;
24495 if(space0 == spaceId1) {
24498 m_solver->c_cellLengthAtCell(cellId) * (cutLineCentroid[nDimFaceSpaceId2] - point[spaceId2]);
24502 faceVolume[face] = gridFaceVolume[face] - faceVolume[face];
24503 nonFluidSideEdge[edgeCode[4 * face + 2]] =
true;
24508 const MFloat maxY = cutLineCentroid[nDimFaceSpaceId2] + F1B2 * delta[nDimFaceSpaceId2];
24509 cc0[0] = m_solver->a_coordinate(cellId, spaceId1);
24510 cc0[1] = F1B2 * (oppositePoint[spaceId2] + maxY);
24511 if(positiveSlope) {
24512 cc1[0] = point[spaceId1] + F1B3 * m_solver->c_cellLengthAtCell(cellId);
24513 normalVector[nDimFaceSpaceId1] = -normalVector[nDimFaceSpaceId1];
24515 cc1[0] = point[spaceId1] + F2B3 * m_solver->c_cellLengthAtCell(cellId);
24517 cc1[1] = maxY - F1B3 * delta[nDimFaceSpaceId2];
24518 rectVolume = (oppositePoint[spaceId2] - maxY) * m_solver->c_cellLengthAtCell(cellId);
24519 triVolume = faceVolume[face] - rectVolume;
24521 nonFluidSideEdge[edgeCode[4 * face + 3]] =
true;
24526 normalVector[nDimFaceSpaceId2] = -normalVector[nDimFaceSpaceId2];
24527 const MFloat minY = cutLineCentroid[nDimFaceSpaceId2] - F1B2 * delta[nDimFaceSpaceId2];
24528 cc0[0] = m_solver->a_coordinate(cellId, spaceId1);
24529 cc0[1] = F1B2 * (point[spaceId2] + minY);
24530 if(positiveSlope) {
24531 cc1[0] = point[spaceId1] + F2B3 * m_solver->c_cellLengthAtCell(cellId);
24533 normalVector[nDimFaceSpaceId1] = -normalVector[nDimFaceSpaceId1];
24534 cc1[0] = point[spaceId1] + F1B3 * m_solver->c_cellLengthAtCell(cellId);
24536 cc1[1] = minY + F1B3 * delta[nDimFaceSpaceId2];
24537 rectVolume = (minY - point[spaceId2]) * m_solver->c_cellLengthAtCell(cellId);
24538 triVolume = faceVolume[face] - rectVolume;
24543 m_solver->c_cellLengthAtCell(cellId) * (cutLineCentroid[nDimFaceSpaceId1] - point[spaceId1]);
24547 faceVolume[face] = gridFaceVolume[face] - faceVolume[face];
24548 nonFluidSideEdge[edgeCode[4 * face]] =
true;
24553 const MFloat maxX = cutLineCentroid[nDimFaceSpaceId1] + F1B2 * delta[nDimFaceSpaceId1];
24554 cc0[0] = F1B2 * (oppositePoint[spaceId1] + maxX);
24555 cc0[1] = m_solver->a_coordinate(cellId, spaceId2);
24556 cc1[0] = maxX - F1B3 * delta[nDimFaceSpaceId1];
24557 if(positiveSlope) {
24558 normalVector[nDimFaceSpaceId2] = -normalVector[nDimFaceSpaceId2];
24559 cc1[1] = point[spaceId2] + F1B3 * m_solver->c_cellLengthAtCell(cellId);
24561 cc1[1] = point[spaceId2] + F2B3 * m_solver->c_cellLengthAtCell(cellId);
24563 rectVolume = (oppositePoint[spaceId1] - maxX) * m_solver->c_cellLengthAtCell(cellId);
24564 triVolume = faceVolume[face] - rectVolume;
24566 nonFluidSideEdge[edgeCode[4 * face + 1]] =
true;
24571 normalVector[nDimFaceSpaceId1] = -normalVector[nDimFaceSpaceId1];
24572 const MFloat minX = cutLineCentroid[nDimFaceSpaceId1] - F1B2 * delta[nDimFaceSpaceId1];
24573 cc0[0] = F1B2 * (point[spaceId1] + minX);
24574 cc0[1] = m_solver->a_coordinate(cellId, spaceId2);
24575 cc1[0] = minX + F1B3 * delta[nDimFaceSpaceId1];
24576 if(positiveSlope) {
24577 cc1[1] = point[spaceId2] + F2B3 * m_solver->c_cellLengthAtCell(cellId);
24579 normalVector[nDimFaceSpaceId2] = -normalVector[nDimFaceSpaceId2];
24580 cc1[1] = point[spaceId2] + F1B3 * m_solver->c_cellLengthAtCell(cellId);
24582 rectVolume = (minX - point[spaceId1]) * m_solver->c_cellLengthAtCell(cellId);
24583 triVolume = faceVolume[face] - rectVolume;
24587 faceCentroid[nDimFaceSpaceId1] = (rectVolume * cc0[0] + triVolume * cc1[0]) / faceVolume[face];
24588 faceCentroid[nDimFaceSpaceId2] = (rectVolume * cc0[1] + triVolume * cc1[1]) / faceVolume[face];
24593 MBool createSrfc =
true;
24596 if(m_solver->a_hasNeighbor(cellId, face) > 0) {
24597 nghbrId = m_solver->c_neighborId(cellId, face);
24599 if(m_solver->c_parentId(cellId) > -1) {
24600 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId), face) > 0)
24601 nghbrId = m_solver->c_neighborId(m_solver->c_parentId(cellId), face);
24603 createSrfc =
false;
24605 createSrfc =
false;
24608 if(m_solver->c_noChildren(nghbrId) > 0) createSrfc =
false;
24610 const MInt otherSideId = (sideId + 1) % 2;
24611 const MInt srfcId = m_solver->a_noSurfaces();
24612 m_surfaces.append();
24613 m_solver->a_surfaceOrientation(srfcId) = spaceId;
24614 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
24615 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) =
cellId;
24616 for(
MInt i = 0; i < nDim; i++) {
24617 m_solver->a_surfaceCoordinate(srfcId, i) = faceCentroid[face * nDim + i];
24619 m_solver->a_surfaceArea(srfcId) = faceVolume[face];
24620 m_bndryCells->a[bndryId].m_associatedSrfc[face] = srfcId;
24627 for(
MInt e = 0; e < 4; e++) {
24628 nonFluidSideEdge[edgeCode[4 * face + e]] =
true;
24640 for(
MInt face = 0; face < m_noDirs; face++) {
24641 MBool nonFluidSide =
true;
24642 for(
MInt e = 0; e < 4; e++) {
24643 if(!nonFluidSideEdge[edgeCode[4 * face + e]]) {
24644 nonFluidSide =
false;
24649 m_bndryCells->a[bndryId].m_externalFaces[face] =
true;
24650 faceVolume[face] = F0;
24657 switch(noCutFaces) {
24659 cerr <<
"case 0 " << endl;
24660 cerr << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 1) <<
" "
24661 << m_solver->a_coordinate(cellId, 2) <<
" " << F1B2 * m_solver->c_cellLengthAtCell(cellId) <<
" "
24662 << m_solver->a_level(cellId) << endl;
24663 mTerm(1, AT_,
"case 0");
24673 for(
MInt face = 0; face < m_noDirs; face++) {
24674 if(cutFaces[face]) {
24678 if(face1 == -1) face1 = face;
24684 for(
MInt e = 0; e < 4; e++) {
24686 if(cutEdgesAll[edgeCode[4 * face0 + e]]) {
24687 cutEdges[edgeCounter] = e;
24693 if(edgeCounter != 2) cerr <<
"ERROR create cut face, tetraeter shape, not enough cut edges" << endl;
24695 for(
MInt e = 0; e < 4; e++) {
24696 if(cutEdgesAll[edgeCode[4 * face1 + e]]) {
24697 if(faceCode[2 * edgeCode[4 * face1 + e]] != face0 && faceCode[2 * edgeCode[4 * face1 + e] + 1] != face0) {
24704 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
24705 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cp] == edgeCode[4 * face1 + cutEdges[2]]) {
24710 const MInt face0Space = face0 / 2;
24711 const MInt face0Side = face0 % 2;
24715 for(
MInt i = 0; i < nDim; i++) {
24716 m_bndryCells->a[bndryId].m_coordinates[i] =
24717 F3B4 * triangleCentroid[face0 * nDim + i]
24718 + F1B4 * m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoint[0]][i];
24723 * (m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoint[0]][face0Space]
24724 - (negativePoint[face0Space] + (
MFloat)face0Side * m_solver->c_cellLengthAtCell(cellId)));
24725 if(shapeIsInside[face0]) {
24726 m_bndryCells->a[bndryId].m_volume = F1B3 * (gridFaceVolume[face0] - faceVolume[face0]) * h;
24728 m_bndryCells->a[bndryId].m_volume = F1B3 * faceVolume[face0] * h;
24732 if(shapeIsInside[face0]) {
24733 cutOutVolume = m_bndryCells->a[bndryId].m_volume;
24734 m_bndryCells->a[bndryId].m_volume =
24735 m_solver->grid().gridCellVolume(m_solver->a_level(cellId)) - m_bndryCells->a[bndryId].m_volume;
24736 for(
MInt i = 0; i < nDim; i++) {
24737 m_bndryCells->a[bndryId].m_coordinates[i] =
24738 F1 / m_bndryCells->a[bndryId].m_volume
24739 * (m_solver->grid().gridCellVolume(m_solver->a_level(cellId)) * m_solver->a_coordinate(cellId, i)
24740 - cutOutVolume * m_bndryCells->a[bndryId].m_coordinates[i]);
24744 for(
MInt i = 0; i < nDim; i++) {
24745 m_bndryCells->a[bndryId].m_coordinates[i] -= m_solver->a_coordinate(cellId, i);
24749 for(
MInt i = 0; i < nDim; i++) {
24750 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i] = faceVolume[2 * i + 1] - faceVolume[2 * i];
24752 m_bndryCells->a[bndryId].m_srfcs[0]->m_area =
24753 sqrt(
POW2(m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[0])
24754 +
POW2(m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[1])
24755 +
POW2(m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[2]));
24758 for(
MInt i = 0; i < nDim; i++) {
24759 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i] =
24760 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i] / m_bndryCells->a[bndryId].m_srfcs[0]->m_area;
24764 for(
MInt i = 0; i < nDim; i++) {
24765 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[i] =
24766 F2B3 * cutLineCentroid[face0 * nDim + i]
24767 + F1B3 * m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoint[0]][i];
24777 cutLineLength[6] = F0;
24778 for(
MInt face = 0; face < m_noDirs; face += 2) {
24779 if(cutFaces[face]) {
24780 if(cutFaces[face + 1]) {
24781 cutLineLength[7] = cutLineLength[face] + cutLineLength[face + 1];
24782 if(cutLineLength[7] > cutLineLength[6]) {
24785 cutLineLength[6] = cutLineLength[7];
24791 const MInt spaceId = face0 / 2;
24792 const MInt spaceId1 = (spaceId + 1) % nDim;
24793 const MInt spaceId2 = (spaceId1 + 1) % nDim;
24797 const MFloat Fvol = F1 / (faceVolume[face0] + faceVolume[face1]);
24798 const MFloat dA = faceVolume[face1] - faceVolume[face0];
24799 dfcc[0] = faceCentroid[face1 * nDim + spaceId1] - faceCentroid[face0 * nDim + spaceId1];
24800 dfcc[1] = faceCentroid[face1 * nDim + spaceId2] - faceCentroid[face0 * nDim + spaceId2];
24802 m_bndryCells->a[bndryId].m_coordinates[spaceId] =
24803 faceCentroid[face0 * nDim + spaceId]
24804 + F1B3 * (F1 + Fvol * faceVolume[face1]) * m_solver->c_cellLengthAtCell(cellId);
24805 m_bndryCells->a[bndryId].m_coordinates[spaceId1] =
24807 * (faceVolume[face0] * faceCentroid[face0 * nDim + spaceId1]
24808 + F1B2 * (faceVolume[face0] * dfcc[0] + dA * faceCentroid[face0 * nDim + spaceId1])
24809 + F1B3 * dA * dfcc[0]);
24810 m_bndryCells->a[bndryId].m_coordinates[spaceId2] =
24812 * (faceVolume[face0] * faceCentroid[face0 * nDim + spaceId2]
24813 + F1B2 * (faceVolume[face0] * dfcc[1] + dA * faceCentroid[face0 * nDim + spaceId2])
24814 + F1B3 * dA * dfcc[1]);
24816 for(
MInt i = 0; i < nDim; i++) {
24817 m_bndryCells->a[bndryId].m_coordinates[i] -= m_solver->a_coordinate(cellId, i);
24821 for(
MInt i = 0; i < nDim; i++) {
24822 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i] = faceVolume[2 * i + 1] - faceVolume[2 * i];
24824 m_bndryCells->a[bndryId].m_srfcs[0]->m_area =
24825 sqrt(
POW2(m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[0])
24826 +
POW2(m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[1])
24827 +
POW2(m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[2]));
24830 for(
MInt i = 0; i < nDim; i++) {
24831 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i] =
24832 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i] / m_bndryCells->a[bndryId].m_srfcs[0]->m_area;
24836 for(
MInt i = 0; i < nDim; i++) {
24837 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[i] =
24838 F1B2 * (cutLineCentroid[face0 * nDim + i] + cutLineCentroid[face1 * nDim + i]);
24842 m_bndryCells->a[bndryId].m_volume =
24844 * (faceVolume[0] * faceCentroid[0 * nDim + 0] - faceVolume[1] * faceCentroid[1 * nDim + 0]
24845 + faceVolume[2] * faceCentroid[2 * nDim + 1] - faceVolume[3] * faceCentroid[3 * nDim + 1]
24846 + faceVolume[4] * faceCentroid[4 * nDim + 2] - faceVolume[5] * faceCentroid[5 * nDim + 2]
24847 + m_bndryCells->a[bndryId].m_srfcs[0]->m_area
24848 * (m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[0]
24849 * m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[0]
24850 + m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[1]
24851 * m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[1]
24852 + m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[2]
24853 * m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[2]));
24859 cerr <<
"this case has not yet been implemented" << endl;
24860 cerr <<
"cell " <<
cellId << endl;
24861 cerr <<
"coordinates"
24862 <<
" " << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 1) <<
" "
24863 << m_solver->a_coordinate(cellId, 2) << endl;
24864 cerr <<
"number of cut faces: " << noCutFaces << endl;
24865 mTerm(1, AT_,
"this case has not yet been implemented");
24897template <MInt nDim,
class SysEqn>
24898template <
class _, std::enable_if_t<nDim == 3, _*>>
24902 static constexpr MInt cornerIndices[8][3] = {{-1, -1, -1}, {1, -1, -1}, {-1, 1, -1}, {1, 1, -1},
24903 {-1, -1, 1}, {1, -1, 1}, {-1, 1, 1}, {1, 1, 1}};
24905 static constexpr MInt cornersMCtoSOLVER[8] = {2, 0, 1, 3, 6, 4, 5, 7};
24906 static constexpr MInt cornersSOLVERtoMC[8] = {1, 2, 0, 3, 5, 6, 4, 7};
24907 static constexpr MInt edgesMCtoSOLVER[12] = {0, 2, 1, 3, 4, 6, 5, 7, 10, 8, 9, 11};
24908 static constexpr MInt facesMCtoSOLVER[6] = {0, 2, 1, 3, 4, 5};
24909 static constexpr MInt neighborCorner[6] = {1, -1, 2, -2, 4, -4};
24910 static constexpr MInt cornerFaceMapping[24] = {0, 2, 4, 1, 2, 4, 0, 3, 4, 1, 3, 4,
24911 0, 2, 5, 1, 2, 5, 0, 3, 5, 1, 3, 5};
24912 static constexpr MInt faceCornerMapping[24] = {0, 2, 4, 6, 1, 3, 5, 7, 0, 1, 4, 5,
24913 2, 3, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7};
24915 unsigned char outcode_MC = 0;
24916 MInt noCells = m_bndryCells->size();
24919 MFloat corner[8][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
24921 MInt presentCases[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
24922 MInt* presentSubCases[15];
24923 const MInt maxNoSubCases = 48;
24924 MIntScratchSpace presentSubCases_scratch(15 * maxNoSubCases, AT_,
"presentSubCases_scratch");
24925 for(
MInt i = 0; i < 15; i++)
24926 presentSubCases[i] = &presentSubCases_scratch.
p[maxNoSubCases * i];
24927 for(
MInt i = 0; i < 15; i++) {
24928 for(
MInt j = 0; j < maxNoSubCases; j++) {
24929 presentSubCases[i][j] = 0;
24932 MBool currentOutcode =
false;
24938 MFloat* faceCentroid[6];
24940 for(
MInt i = 0; i < 6; i++)
24941 faceCentroid[i] = &faceCentroid_scratch.
p[i * nDim];
24942 MFloat* faceCentroid_0[6];
24944 for(
MInt i = 0; i < 6; i++)
24945 faceCentroid_0[i] = &faceCentroid_0_scratch.
p[i * nDim];
24946 MFloat* faceCentroid_00[6];
24947 MFloatScratchSpace faceCentroid_00_scratch(nDim * 6, AT_,
"faceCentroid_00_scratch");
24948 for(
MInt i = 0; i < 6; i++)
24949 faceCentroid_00[i] = &faceCentroid_00_scratch.
p[i * nDim];
24952 for(
MInt i = 0; i < 6; i++)
24953 normal[i] = &normal_scratch.
p[i * nDim];
24954 const MInt maxNoPyramids = 13;
24955 MFloat* pyraCentroid[maxNoPyramids];
24956 MFloatScratchSpace pyraCentroid_scratch(nDim * maxNoPyramids, AT_,
"pyraCentroid_scratch");
24957 for(
MInt i = 0; i < maxNoPyramids; i++)
24958 pyraCentroid[i] = &pyraCentroid_scratch.
p[i * nDim];
24963 MFloatScratchSpace faceVolume_0_scratch(F2 * m_noDirs, AT_,
"faceVolume_0_scratch");
24965 MFloatScratchSpace faceVolume_00_scratch(F2 * m_noDirs, AT_,
"faceVolume_00_scratch");
24971 MInt currentSubCase;
24991 MInt splitCorner1 = -1;
24992 MInt splitCorner2 = -1;
24993 MInt splitCorner12 = -1;
24994 MInt splitCorner22 = -1;
25002 MInt* facepointers[6] = {&face1, &face2, &face3, &face4, &face5, &face6};
25003 MInt cutPoints[12] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
25012 MFloat M[3] = {0, 0, 0};
25013 MFloat dummy_1[3] = {0, 0, 0};
25014 MBool nfs_cur[6] = {
false,
false,
false,
false,
false,
false};
25015 MBool nfs_cur_0[6] = {
false,
false,
false,
false,
false,
false};
25016 MBool nfs_cur_00[6] = {
false,
false,
false,
false,
false,
false};
25017 MBool faceCut[6] = {
false,
false,
false,
false,
false,
false};
25018 MBool faceCut_0[6] = {
false,
false,
false,
false,
false,
false};
25019 MBool faceCut_00[6] = {
false,
false,
false,
false,
false,
false};
25026 static constexpr MInt opposite[6] = {1, 0, 3, 2, 5, 4};
25027 MInt bndryId2 = -1, bndryId3 = -1;
25028 MInt cellId2 = -1, cellId3 = -1;
25031 MIntScratchSpace disambiguation_scratch(noCells, AT_,
"disambiguation_scratch");
25033 MIntScratchSpace ambiguousCells_scratch(noCells, AT_,
"ambiguousCells_scratch");
25043 for(
MInt i = 0; i < m_bndryCells->size(); i++) {
25044 ambiguousCells[i] = -1;
25045 disambiguation[i] = -1;
25050 MInt noSplitCells = 0;
25051 MInt noSplitFaces = 0;
25052 MInt noAmbiguousCells = 0;
25057 stack<MInt> ambStack;
25060 MFloat* splitFaceCentroid[2];
25061 MFloatScratchSpace splitFaceCentroid_scratch(nDim * 2, AT_,
"splitFaceCentroid_scratch");
25062 for(
MInt i = 0; i < 2; i++)
25063 splitFaceCentroid[i] = &splitFaceCentroid_scratch.
p[i * nDim];
25064 MFloat* splitFaceNormal[2];
25065 MFloatScratchSpace splitFaceNormal_scratch(nDim * 2, AT_,
"splitFaceNormal_scratch");
25066 for(
MInt i = 0; i < 2; i++)
25067 splitFaceNormal[i] = &splitFaceNormal_scratch.
p[i * nDim];
25070 MFloat* splitFaceCentroid2[2];
25071 MFloatScratchSpace splitFaceCentroid2_scratch(nDim * 2, AT_,
"splitFaceCentroid2_scratch");
25072 for(
MInt i = 0; i < 2; i++)
25073 splitFaceCentroid2[i] = &splitFaceCentroid2_scratch.
p[i * nDim];
25074 MFloat* splitFaceNormal2[2];
25075 MFloatScratchSpace splitFaceNormal2_scratch(nDim * 2, AT_,
"splitFaceNormal2_scratch");
25076 for(
MInt i = 0; i < 2; i++)
25077 splitFaceNormal2[i] = &splitFaceNormal2_scratch.
p[i * nDim];
25078 MInt splitFaceId = -1;
25079 MInt splitFaceId2 = -1;
25080 MInt splitSurfaceIndexCounter = 2;
25082 MBool keepNghbrs =
true;
25083 MInt disamb_tmp = 0;
25084 MInt disambPointer[16][21];
25085 const MInt* disambPointer_dummy =
nullptr;
25090 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
25091 cellId = m_bndryCells->a[bndryId].m_cellId;
25092 m_bndryCells->a[bndryId].m_noSrfcs = 0;
25095 for(
MInt f = 0; f < m_noDirs; f++) {
25096 m_bndryCells->a[bndryId].m_externalFaces[f] =
false;
25099 if(m_solver->c_noChildren(cellId) > 0) {
25102 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
25103 m_bndryCells->a[bndryId].m_volume = F0;
25111 for(
MInt i = 0; i < 8; i++) {
25112 for(
MInt dim = 0; dim < nDim; dim++) {
25114 m_solver->a_coordinate(cellId, dim) + cornerIndices[i][dim] * F1B2 * m_solver->c_cellLengthAtCell(cellId);
25116 currentOutcode = !((
MBool)m_solver->m_geometry->pointIsInside2(corner[i]));
25117 if(currentOutcode) outcode_MC = outcode_MC | (1 << cornersSOLVERtoMC[i]);
25121 currentCase = (
MInt)cases[outcode_MC][0];
25122 mcCases[bndryId] = currentCase;
25123 currentSubCase = (
MInt)cases[outcode_MC][1];
25124 subCases[bndryId] = currentSubCase;
25125 if(!caseStatesSTL[currentCase][0]) {
25126 cerr <<
"Error in createCutFaceMGC: Case not implemented: " << currentCase << endl;
25131 disambiguation[bndryId] = -1;
25132 if(!caseStatesSTL[mcCases[bndryId]][1]) {
25133 ambIds[bndryId] = noAmbiguousCells;
25134 ambiguousCells[noAmbiguousCells++] = bndryId;
25140 MIntScratchSpace cornerCellMapping_scratch(8 * noAmbiguousCells, AT_,
"cornerCellMapping_scratch");
25141 MInt* cornerCellMapping = cornerCellMapping_scratch.
getPointer();
25142 for(
MInt i = 0; i < noAmbiguousCells; i++) {
25143 bdAmbId = ambiguousCells[i];
25144 cellId = m_bndryCells->a[bdAmbId].m_cellId;
25148 for(
MInt j = 0; j < 8; j++) {
25149 for(
MInt dim = 0; dim < nDim; dim++) {
25150 corner[j][dim] = m_solver->a_coordinate(cellId, dim)
25151 + cornerIndices[j][dim] * F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
25153 currentOutcode = !((
MBool)m_solver->m_geometry->pointIsInside2(corner[j]));
25154 if(currentOutcode) outcode_MC = outcode_MC | (1 << cornersSOLVERtoMC[j]);
25156 for(
MInt j = 0; j < 8; j++) {
25157 mcCorner = cornersSOLVERtoMC[j];
25158 if(!(outcode_MC & 1 << mcCorner))
25159 cornerCellMapping[i * 8 + j] = -1;
25161 cornerCellMapping[i * 8 + j] = cellId;
25166 for(
MInt ambId = 0; ambId < noAmbiguousCells; ambId++) {
25167 bdAmbId = ambiguousCells[ambId];
25168 disambiguation[bdAmbId] = 0;
25169 cellId = m_bndryCells->a[bdAmbId].m_cellId;
25170 currentCase = mcCases[bdAmbId];
25171 currentSubCase = subCases[bdAmbId];
25174 switch(currentCase) {
25179 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
25194 stringstream errorMessage;
25195 errorMessage <<
" Error in FvBndryCnd3D::createCutFaceMGC: cell in ambigous cells does not have an "
25196 "ambiguous case... cellId: "
25197 << cellId <<
" case: " << currentCase <<
" bndryId: " << bdAmbId << endl;
25198 writeStlFileOfCell(cellId,
"errorcell.stl");
25199 mTerm(1, AT_, errorMessage.str());
25203 for(
MInt i = 0; i < faceMax; i++) {
25206 switch(currentCase) {
25208 faceTMP = facesMCtoSOLVER[tiling3_1STL[currentSubCase][2 + i]];
25212 faceTMP = facesMCtoSOLVER[tiling6_1STL[currentSubCase][2 + i]];
25215 faceTMP = facesMCtoSOLVER[tiling7_1STL[currentSubCase][3 + i]];
25219 faceTMP = facesMCtoSOLVER[tiling10_1STL[currentSubCase][2 + i]];
25223 faceTMP = facesMCtoSOLVER[tiling12_1STL[currentSubCase][2 + i]];
25226 stringstream errorMessage;
25227 errorMessage <<
"ERROR: Switch variable 'currentCase' with value " << currentCase <<
" not matching any case."
25229 mTerm(1, AT_, errorMessage.str());
25232 nghbrCellId = m_solver->c_neighborId(cellId, faceTMP);
25233 if(nghbrCellId < 0 || !m_solver->a_hasNeighbor(cellId, faceTMP)) {
25234 stringstream errorMessage;
25235 errorMessage <<
" Error in FvBndryCnd3D::createCutFaceMGC: no neighbor in ambiguous direction... exiting."
25237 errorMessage <<
" cellId: " << cellId <<
", ambiguous face: " << faceTMP << endl;
25238 writeStlFileOfCell(cellId,
"errorcell.stl");
25239 mTerm(1, AT_, errorMessage.str());
25242 for(
MInt dim = 0; dim < nDim; dim++) {
25243 corner[0][dim] = (m_solver->a_coordinate(cellId, dim) + m_solver->a_coordinate(nghbrCellId, dim)) * F1B2;
25245 currentOutcode = (
MBool)m_solver->m_geometry->pointIsInside2(corner[0]);
25248 if(currentOutcode) {
25249 disambiguation[bdAmbId] +=
IPOW2(faceMax - i - 1);
25255 for(
MInt ambId = 0; ambId < noAmbiguousCells; ambId++) {
25256 bdAmbId = ambiguousCells[ambId];
25257 cellId = m_bndryCells->a[bdAmbId].m_cellId;
25258 currentCase = mcCases[bdAmbId];
25259 currentSubCase = subCases[bdAmbId];
25261 switch(currentCase) {
25263 if(currentSubCase < 12 && disambiguation[bdAmbId] == 1) {
25264 splitCell[bdAmbId] =
true;
25266 }
else if(currentSubCase >= 12 && disambiguation[bdAmbId] == 1) {
25267 splitFace[bdAmbId] =
true;
25272 if(currentSubCase < 4) {
25273 splitCell[bdAmbId] =
true;
25278 if(currentSubCase < 24 && disambiguation[bdAmbId] == 1) {
25279 splitCell[bdAmbId] =
true;
25281 }
else if(currentSubCase >= 24 && disambiguation[bdAmbId] == 1) {
25282 splitFace[bdAmbId] =
true;
25287 if(currentSubCase < 8) {
25288 switch(disambiguation[bdAmbId]) {
25295 splitFace[bdAmbId] =
true;
25301 splitCell[bdAmbId] =
true;
25305 splitCell[bdAmbId] =
true;
25310 stringstream errorMessage;
25311 errorMessage <<
"ERROR: Switch variable 'disambiguation[bdAmbId]' with value " << disambiguation[bdAmbId]
25312 <<
" not matching any case." << endl;
25313 mTerm(1, AT_, errorMessage.str());
25317 switch(disambiguation[bdAmbId]) {
25324 splitFace[bdAmbId] =
true;
25331 splitFace[bdAmbId] =
true;
25336 splitCell[bdAmbId] =
true;
25340 stringstream errorMessage;
25341 errorMessage <<
"ERROR: Switch variable 'disambiguation[bdAmbId]' with value " << disambiguation[bdAmbId]
25342 <<
" not matching any case." << endl;
25343 mTerm(1, AT_, errorMessage.str());
25349 if(disambiguation[bdAmbId] == 3) {
25350 splitCell[bdAmbId] =
true;
25353 if(disambiguation[bdAmbId] == 2 || disambiguation[bdAmbId] == 1) {
25354 stringstream errorMessage;
25355 errorMessage <<
" found case 10 cell with disambiguation " << disambiguation[bdAmbId] <<
" and cellId "
25356 << cellId <<
". This means cell is a case 10.2 cell which is not implemented. Exiting..."
25358 mTerm(1, AT_, errorMessage.str());
25362 if(disambiguation[bdAmbId] == 3) {
25363 splitCell[bdAmbId] =
true;
25366 if(disambiguation[bdAmbId] == 2 || disambiguation[bdAmbId] == 1) {
25367 stringstream errorMessage;
25368 errorMessage <<
" found case 12 cell with disambiguation " << disambiguation[bdAmbId] <<
" and cellId "
25369 << cellId <<
". This means cell is a case 12.2 cell which is not implemented. Exiting..."
25371 mTerm(1, AT_, errorMessage.str());
25375 stringstream errorMessage;
25376 errorMessage <<
"ERROR: Switch variable 'currentCase' with value " << currentCase <<
" not matching any case."
25378 mTerm(1, AT_, errorMessage.str());
25394 const MInt maxNoSplitChildrenPerCell = 3;
25395 mAlloc(m_splitSurfaces, (2 + noSplitFaces) * 2 * maxNoSplitChildrenPerCell,
"m_splitSurfaces", -1, AT_);
25396 mAlloc(m_splitParents, noCells + noSplitCells,
"m_splitPartents", -1, AT_);
25397 mAlloc(m_splitChildren, (noCells + noSplitCells) * maxNoSplitChildrenPerCell,
"m_splitChildren", -1, AT_);
25400 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
25402 cellId = m_bndryCells->a[bndryId].m_cellId;
25403 gridCellVolume = m_solver->grid().gridCellVolume(m_solver->a_level(cellId));
25406 coordinates_Cell[0] = 0;
25407 coordinates_Cell[1] = 0;
25408 coordinates_Cell[2] = 0;
25412 for(
MInt cutPoint = 0; cutPoint < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cutPoint++) {
25413 cutPoints[m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPoint]] = cutPoint;
25416 for(
MInt i = 0; i < nDim; i++) {
25417 faceVolume[2 * i] =
POW2(m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId)));
25418 faceVolume[2 * i + 1] = faceVolume[2 * i];
25419 for(
MInt j = 0; j < 3; j++) {
25420 faceCentroid[2 * i][j] = m_solver->a_coordinate(cellId, j);
25421 faceCentroid[2 * i + 1][j] = m_solver->a_coordinate(cellId, j);
25423 faceCentroid[2 * i][i] -= F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
25424 faceCentroid[2 * i + 1][i] += F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
25428 if(!m_solver->c_isLeafCell(cellId)) {
25429 m_bndryCells->a[bndryId].m_volume = gridCellVolume;
25430 for(
MInt dim = 0; dim < 3; dim++) {
25431 m_bndryCells->a[bndryId].m_coordinates[dim] = m_solver->a_coordinate(cellId, dim);
25433 m_bndryCells->a[bndryId].m_noSrfcs = 0;
25434 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = faceVolume[0];
25435 for(
MInt dim = 0; dim < 3; dim++) {
25436 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = faceCentroid[0][dim];
25437 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = F1 / sqrt(F3);
25439 for(
MInt i = 0; i < nDim; i++) {
25440 m_bndryCells->a[bndryId].m_coordinates[i] -= m_solver->a_coordinate(cellId, i);
25446 for(
MInt i = 0; i < 8; i++) {
25447 for(
MInt dim = 0; dim < nDim; dim++) {
25448 corner[i][dim] = m_solver->a_coordinate(cellId, dim)
25449 + cornerIndices[i][dim] * F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
25452 for(
MInt i = 0; i < 6; i++) {
25453 faceCut[i] =
false;
25454 faceCut_0[i] =
false;
25459 currentCase = mcCases[bndryId];
25460 presentCases[currentCase]++;
25461 currentSubCase = subCases[bndryId];
25462 presentSubCases[currentCase][currentSubCase]++;
25464 if(!(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints == caseCutPoints[currentCase])) {
25465 cerr <<
"FvBndryCnd3D::createCutFaceMGC - Error: number of cut points not correct!" << endl;
25466 cerr <<
"Case: " << currentCase <<
" cutPointsTheory: " << caseCutPoints[currentCase]
25467 <<
" actual Cut Points: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints << endl;
25468 cerr <<
"Cell level: " << m_solver->a_level(cellId) << endl;
25469 stringstream fileName;
25470 fileName << cellId <<
".stl";
25471 writeStlFileOfCell(cellId, (fileName.str()).c_str());
25472 cerr <<
"Wrote stl-file of cell. FileName: " << (fileName.str()) << endl;
25474 if(!caseStatesSTL[currentCase][0]) {
25475 cerr <<
"FvBndryCnd3D::createCutFaceMGC - Error: Case not implemented: " << currentCase << endl;
25476 cerr <<
"Cell level: " << m_solver->a_level(cellId) << endl;
25477 stringstream fileName;
25478 fileName << cellId <<
".stl";
25479 writeStlFileOfCell(cellId, (fileName.str()).c_str());
25480 cerr <<
"Wrote stl-file of cell. FileName: " << (fileName.str()) << endl;
25486 if(!caseStatesSTL[currentCase][1]) {
25487 switch(currentCase) {
25489 for(
MInt i = 0; i < 6; i++) {
25490 faceVolume_0[i] = faceVolume[i];
25491 for(
MInt j = 0; j < 3; j++) {
25492 faceCentroid_0[i][j] = faceCentroid[i][j];
25495 cellVolume_0 = gridCellVolume;
25496 for(
MInt i = 0; i < 3; i++) {
25497 cellCentroid_0[i] = m_solver->a_coordinate(cellId, i);
25501 if((currentSubCase < 12 && disambiguation[bndryId] == 0)
25502 || (currentSubCase >= 12 && disambiguation[bndryId] == 1)) {
25506 m_bndryCells->a[bndryId].m_noSrfcs = 1;
25508 for(
MInt face = 0; face < 6; face++) {
25509 nfs_cur[face] = nfs3_2[currentSubCase][face];
25512 p_0 = corner[cornersMCtoSOLVER[tiling3_2STL[currentSubCase][0]]];
25513 p_0s = corner[cornersMCtoSOLVER[tiling3_2STL[currentSubCase][1]]];
25515 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][2]];
25516 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25517 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][3]];
25518 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25519 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][4]];
25520 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25521 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][5]];
25522 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25523 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][6]];
25524 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25525 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][7]];
25526 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25527 face1 = facesMCtoSOLVER[tiling3_2STL[currentSubCase][8]];
25528 face2 = facesMCtoSOLVER[tiling3_2STL[currentSubCase][9]];
25529 face3 = facesMCtoSOLVER[tiling3_2STL[currentSubCase][10]];
25530 face4 = facesMCtoSOLVER[tiling3_2STL[currentSubCase][11]];
25531 face5 = facesMCtoSOLVER[tiling3_2STL[currentSubCase][12]];
25533 computeTri(p_0, p_1, p_2, &faceVolume[face1], faceCentroid[face1], normal[face1]);
25534 computeTri(p_0, p_2, p_3, &faceVolume[face2], faceCentroid[face2], normal[face2]);
25535 computeTri(p_0s, p_2s, p_3s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
25536 computeTri(p_0s, p_1s, p_2s, &faceVolume[face4], faceCentroid[face4], normal[face4]);
25537 computePoly6(p_0, p_1, p_3s, p_0s, p_1s, p_3, &faceVolume[face5], faceCentroid[face5], normal[face5]);
25539 computePoly6(p_1, p_2, p_3, p_1s, p_2s, p_3s, &area_c, coordinates_c, normalVec_c);
25541 maia::math::vecAvg<3>(M, p_0, p_0s, p_1, p_1s, p_2, p_2s, p_3, p_3s);
25543 for(
MInt i = 0; i < 5; i++) {
25544 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
25545 &pyraVolume[i], pyraCentroid[i]);
25547 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[5], pyraCentroid[5]);
25549 for(
MInt i = 0; i < 6; i++) {
25550 volume_C += pyraVolume[i];
25551 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
25553 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
25555 if(currentSubCase >= 12) {
25557 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
25558 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
25559 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
25560 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
25561 p_1ss = corner[cornersMCtoSOLVER[tiling3_2STL[currentSubCase][13]]];
25562 p_2ss = corner[cornersMCtoSOLVER[tiling3_2STL[currentSubCase][14]]];
25563 splitCorner1 = cornersMCtoSOLVER[tiling3_2STL[currentSubCase][13]];
25564 splitCorner2 = cornersMCtoSOLVER[tiling3_2STL[currentSubCase][14]];
25565 computeTri(p_1s, p_1ss, p_3, &splitFaceVolume[0], splitFaceCentroid[0], splitFaceNormal[0]);
25566 computeTri(p_1, p_2ss, p_3s, &splitFaceVolume[1], splitFaceCentroid[1], splitFaceNormal[1]);
25567 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
25569 correctNormal(normalVec_c);
25570 splitFaceId = face5;
25573 m_bndryCells->a[bndryId].m_volume = volume_C;
25575 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
25576 for(
MInt dim = 0; dim < 3; dim++) {
25577 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
25578 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
25579 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
25582 faceCut[face1] =
true;
25583 faceCut[face2] =
true;
25584 faceCut[face3] =
true;
25585 faceCut[face4] =
true;
25586 faceCut[face5] =
true;
25589 for(
MInt i = 0; i < nDim; i++) {
25590 if(!nfs_cur[2 * i + 1]) faceVolume[2 * i + 1] = 0;
25591 if(!nfs_cur[2 * i]) faceVolume[2 * i] = 0;
25592 faceDiff[i] = faceVolume[2 * i + 1] - faceVolume[2 * i];
25593 absA +=
POW2(faceDiff[i]);
25596 if(currentSubCase < 12) {
25597 for(
MInt i = 0; i < nDim; i++) {
25598 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i] = faceDiff[i] / sqrt(absA);
25600 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = sqrt(absA);
25605 if(currentSubCase < 12) {
25607 cellId2 = createSplitCell_MGC(cellId, 1);
25608 bndryId2 = m_solver->a_bndryId(cellId2);
25609 m_splitParents[bndryId2] = bndryId;
25610 m_splitChildren[bndryId * 3 + 0] = bndryId2;
25612 cerr <<
" problem in FvBndryCnd3D::createCutFaceMGC, assuming cell 0 is no split cell failed! " << endl;
25613 m_bndryCells->a[bndryId].m_noSrfcs = 1;
25614 m_bndryCells->a[bndryId2].m_noSrfcs = 1;
25616 m_bndryCells->a[bndryId].m_noSrfcs = 2;
25619 for(
MInt face = 0; face < 6; face++) {
25620 nfs_cur[face] = nfs3_1[currentSubCase][face];
25624 subCaseDummy = tiling3_1STL[currentSubCase][0];
25625 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
25626 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
25627 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25628 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
25629 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25630 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
25631 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25632 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
25633 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
25634 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
25636 faceCut[face1] =
true;
25637 faceCut[face2] =
true;
25638 faceCut[face3] =
true;
25640 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
25641 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
25642 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
25644 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
25646 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
25648 if(currentSubCase >= 12) {
25649 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
25650 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
25651 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
25653 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
25655 correctNormal(normalVec_c);
25657 for(
MInt face = 0; face < 6; face++) {
25658 nfs_cur[face] = nfs1[subCaseDummy][face];
25663 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
25664 for(
MInt dim = 0; dim < 3; dim++) {
25665 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
25666 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
25668 m_bndryCells->a[bndryId].m_volume = volume_C;
25669 for(
MInt dim = 0; dim < 3; dim++) {
25670 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
25673 if(currentSubCase >= 12) {
25674 faceVolume_0[face1] = faceVolume[face1];
25675 faceVolume_0[face2] = faceVolume[face2];
25676 faceVolume_0[face3] = faceVolume[face3];
25677 cellVolume_0 = volume_C;
25678 for(
MInt i = 0; i < 3; i++) {
25679 cellCentroid_0[i] = coordinates_Cell[i];
25680 faceCentroid_0[face1][i] = faceCentroid[face1][i];
25681 faceCentroid_0[face2][i] = faceCentroid[face2][i];
25682 faceCentroid_0[face3][i] = faceCentroid[face3][i];
25687 subCaseDummy = tiling3_1STL[currentSubCase][1];
25688 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
25689 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
25690 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25691 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
25692 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25693 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
25694 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25695 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
25696 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
25697 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
25699 if(currentSubCase < 12) {
25700 for(
MInt face = 0; face < 6; face++) {
25701 nfs_cur_0[face] = nfs1[subCaseDummy][face];
25704 faceCut_0[face1] =
true;
25705 faceCut_0[face2] =
true;
25706 faceCut_0[face3] =
true;
25708 computeTri(p_0, p_1, p_3, &faceVolume_0[face1], faceCentroid_0[face1]);
25709 computeTri(p_0, p_3, p_2, &faceVolume_0[face2], faceCentroid_0[face2]);
25710 computeTri(p_0, p_2, p_1, &faceVolume_0[face3], faceCentroid_0[face3]);
25712 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
25714 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
25717 m_bndryCells->a[bndryId2].m_srfcs[0]->m_area = area_c;
25718 for(
MInt dim = 0; dim < 3; dim++) {
25719 m_bndryCells->a[bndryId2].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
25720 m_bndryCells->a[bndryId2].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
25723 m_bndryCells->a[bndryId2].m_volume = volume_C;
25724 for(
MInt dim = 0; dim < 3; dim++) {
25725 m_bndryCells->a[bndryId2].m_coordinates[dim] = coordinates_Cell[dim];
25729 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]] = cellId2;
25732 faceCut[face1] =
true;
25733 faceCut[face2] =
true;
25734 faceCut[face3] =
true;
25736 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
25737 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
25738 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
25740 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
25742 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
25744 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
25745 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
25746 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
25748 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
25750 correctNormal(normalVec_c);
25753 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
25754 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
25755 for(
MInt dim = 0; dim < 3; dim++) {
25756 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
25757 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
25760 m_bndryCells->a[bndryId].m_volume = volume_C;
25761 for(
MInt dim = 0; dim < 3; dim++) {
25762 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
25769 for(
MInt i = 0; i < 6; i++) {
25770 faceVolume_0[i] = faceVolume[i];
25771 for(
MInt j = 0; j < 3; j++) {
25772 faceCentroid_0[i][j] = faceCentroid[i][j];
25775 cellVolume_0 = gridCellVolume;
25776 for(
MInt i = 0; i < 3; i++) {
25777 cellCentroid_0[i] = m_solver->a_coordinate(cellId, i);
25781 if(currentSubCase < 4) {
25783 cellId2 = createSplitCell_MGC(cellId, 1);
25784 bndryId2 = m_solver->a_bndryId(cellId2);
25785 m_splitParents[bndryId2] = bndryId;
25786 m_splitChildren[bndryId * 3 + 0] = bndryId2;
25788 cerr <<
" problem in FvBndryCnd3D::createCutFaceMGC, assuming cell 0 is no split cell failed! " << endl;
25791 m_bndryCells->a[bndryId].m_noSrfcs = 1;
25794 subCaseDummy = tiling4_1STL[currentSubCase][0];
25795 for(
MInt face = 0; face < 6; face++) {
25796 nfs_cur[face] = nfs1[subCaseDummy][face];
25798 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
25799 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
25800 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25801 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
25802 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25803 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
25804 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25805 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
25806 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
25807 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
25809 faceCut[face1] =
true;
25810 faceCut[face2] =
true;
25811 faceCut[face3] =
true;
25813 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
25814 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
25815 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
25817 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
25819 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
25821 m_bndryCells->a[bndryId].m_volume = volume_C;
25822 for(
MInt dim = 0; dim < 3; dim++) {
25823 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
25827 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
25828 for(
MInt dim = 0; dim < 3; dim++) {
25829 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
25830 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
25835 m_bndryCells->a[bndryId2].m_noSrfcs = 1;
25837 subCaseDummy = tiling4_1STL[currentSubCase][1];
25838 for(
MInt face = 0; face < 6; face++) {
25839 nfs_cur_0[face] = nfs1[subCaseDummy][face];
25841 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
25842 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
25843 p_1 = m_bndryCells->a[bndryId2].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25844 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
25845 p_2 = m_bndryCells->a[bndryId2].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25846 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
25847 p_3 = m_bndryCells->a[bndryId2].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25848 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
25849 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
25850 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
25852 faceCut_0[face1] =
true;
25853 faceCut_0[face2] =
true;
25854 faceCut_0[face3] =
true;
25856 computeTri(p_0, p_1, p_3, &faceVolume_0[face1], faceCentroid_0[face1]);
25857 computeTri(p_0, p_3, p_2, &faceVolume_0[face2], faceCentroid_0[face2]);
25858 computeTri(p_0, p_2, p_1, &faceVolume_0[face3], faceCentroid_0[face3]);
25860 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
25862 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
25864 m_bndryCells->a[bndryId2].m_volume = volume_C;
25865 for(
MInt dim = 0; dim < 3; dim++) {
25866 m_bndryCells->a[bndryId2].m_coordinates[dim] = coordinates_Cell[dim];
25870 m_bndryCells->a[bndryId2].m_srfcs[0]->m_area = area_c;
25871 for(
MInt dim = 0; dim < 3; dim++) {
25872 m_bndryCells->a[bndryId2].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
25873 m_bndryCells->a[bndryId2].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
25877 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]] = cellId2;
25880 m_bndryCells->a[bndryId].m_noSrfcs = 2;
25881 for(
MInt face = 0; face < 6; face++) {
25882 nfs_cur[face] = nfs4_1[currentSubCase][face];
25885 subCaseDummy = tiling4_1STL[currentSubCase][0];
25886 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
25887 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
25888 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25889 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
25890 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25891 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
25892 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25893 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
25894 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
25895 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
25897 faceCut[face1] =
true;
25898 faceCut[face2] =
true;
25899 faceCut[face3] =
true;
25901 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
25902 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
25903 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
25905 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
25907 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
25909 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
25910 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
25911 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
25913 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
25915 correctNormal(normalVec_c);
25918 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
25919 for(
MInt dim = 0; dim < 3; dim++) {
25920 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
25921 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
25924 faceVolume_0[face1] = faceVolume[face1];
25925 faceVolume_0[face2] = faceVolume[face2];
25926 faceVolume_0[face3] = faceVolume[face3];
25927 cellVolume_0 = volume_C;
25928 for(
MInt i = 0; i < 3; i++) {
25929 cellCentroid_0[i] = coordinates_Cell[i];
25930 faceCentroid_0[face1][i] = faceCentroid[face1][i];
25931 faceCentroid_0[face2][i] = faceCentroid[face2][i];
25932 faceCentroid_0[face3][i] = faceCentroid[face3][i];
25936 subCaseDummy = tiling4_1STL[currentSubCase][1];
25937 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
25938 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
25939 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25940 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
25941 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25942 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
25943 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
25944 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
25945 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
25946 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
25948 faceCut[face1] =
true;
25949 faceCut[face2] =
true;
25950 faceCut[face3] =
true;
25952 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
25953 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
25954 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
25956 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
25958 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
25960 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
25961 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
25962 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
25964 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
25966 correctNormal(normalVec_c);
25969 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
25970 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
25971 for(
MInt dim = 0; dim < 3; dim++) {
25972 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
25973 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
25976 m_bndryCells->a[bndryId].m_volume = volume_C;
25977 for(
MInt dim = 0; dim < 3; dim++) {
25978 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
25984 for(
MInt i = 0; i < 6; i++) {
25985 faceVolume_0[i] = faceVolume[i];
25986 for(
MInt j = 0; j < 3; j++) {
25987 faceCentroid_0[i][j] = faceCentroid[i][j];
25990 cellVolume_0 = gridCellVolume;
25991 for(
MInt i = 0; i < 3; i++) {
25992 cellCentroid_0[i] = m_solver->a_coordinate(cellId, i);
25994 if((currentSubCase < 24 && disambiguation[bndryId] == 1)
25995 || (currentSubCase >= 24 && disambiguation[bndryId] == 0)) {
25998 if(currentSubCase < 24) {
26000 cellId2 = createSplitCell_MGC(cellId, 1);
26001 bndryId2 = m_solver->a_bndryId(cellId2);
26002 m_splitParents[bndryId2] = bndryId;
26003 m_splitChildren[bndryId * 3 + 0] = bndryId2;
26005 cerr <<
" problem in FvBndryCnd3D::createCutFaceMGC, assuming cell 0 is no split cell failed! " << endl;
26006 m_bndryCells->a[bndryId].m_noSrfcs = 1;
26007 m_bndryCells->a[bndryId2].m_noSrfcs = 1;
26009 m_bndryCells->a[bndryId].m_noSrfcs = 2;
26012 for(
MInt face = 0; face < 6; face++) {
26013 nfs_cur[face] = nfs6_1[currentSubCase][face];
26017 subCaseDummy = tiling6_1STL[currentSubCase][0];
26018 p_0 = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][0]]];
26019 p_0s = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][1]]];
26020 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
26021 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26022 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
26023 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26024 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
26025 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26026 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
26027 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26028 face1 = facesMCtoSOLVER[tiling2STL[subCaseDummy][6]];
26029 face2 = facesMCtoSOLVER[tiling2STL[subCaseDummy][7]];
26030 face3 = facesMCtoSOLVER[tiling2STL[subCaseDummy][8]];
26031 face4 = facesMCtoSOLVER[tiling2STL[subCaseDummy][9]];
26033 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2], normal[face2]);
26034 computeTri(p_0s, p_3s, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
26035 computeTrapez(p_0, p_0s, p_3s, p_3, &faceVolume[face1], faceCentroid[face1], normal[face1]);
26036 computeTrapez(p_2, p_2s, p_0s, p_0, &faceVolume[face4], faceCentroid[face4], normal[face4]);
26038 computePoly4(p_3, p_3s, p_2s, p_2, &area_c, coordinates_c, normalVec_c);
26040 maia::math::vecAvg<3>(M, p_0, p_0s, p_2, p_2s, p_3, p_3s);
26042 for(
MInt i = 0; i < 4; i++) {
26043 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
26044 &pyraVolume[i], pyraCentroid[i]);
26046 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[4], pyraCentroid[4]);
26047 for(
MInt i = 0; i < 5; i++) {
26048 volume_C += pyraVolume[i];
26049 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
26051 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
26053 if(currentSubCase >= 24) {
26054 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
26055 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
26056 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
26057 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
26059 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
26061 correctNormal(normalVec_c);
26063 for(
MInt face = 0; face < 6; face++) {
26064 nfs_cur[face] = nfs2[subCaseDummy][face];
26068 faceCut[face1] =
true;
26069 faceCut[face2] =
true;
26070 faceCut[face3] =
true;
26071 faceCut[face4] =
true;
26074 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
26075 for(
MInt dim = 0; dim < 3; dim++) {
26076 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
26077 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
26079 m_bndryCells->a[bndryId].m_volume = volume_C;
26080 for(
MInt dim = 0; dim < 3; dim++) {
26081 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
26084 if(currentSubCase >= 24) {
26085 faceVolume_0[face1] = faceVolume[face1];
26086 faceVolume_0[face2] = faceVolume[face2];
26087 faceVolume_0[face3] = faceVolume[face3];
26088 faceVolume_0[face4] = faceVolume[face4];
26089 cellVolume_0 = volume_C;
26091 for(
MInt i = 0; i < 3; i++) {
26092 cellCentroid_0[i] = coordinates_Cell[i];
26093 faceCentroid_0[face1][i] = faceCentroid[face1][i];
26094 faceCentroid_0[face2][i] = faceCentroid[face2][i];
26095 faceCentroid_0[face3][i] = faceCentroid[face3][i];
26096 faceCentroid_0[face4][i] = faceCentroid[face4][i];
26097 coordinates_Cell[i] = 0;
26102 subCaseDummy = tiling6_1STL[currentSubCase][1];
26103 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
26104 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
26105 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26106 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
26107 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26108 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
26109 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26110 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
26111 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
26112 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
26114 if(currentSubCase < 24) {
26115 for(
MInt face = 0; face < 6; face++) {
26116 nfs_cur_0[face] = nfs1[subCaseDummy][face];
26119 faceCut_0[face1] =
true;
26120 faceCut_0[face2] =
true;
26121 faceCut_0[face3] =
true;
26123 computeTri(p_0, p_1, p_3, &faceVolume_0[face1], faceCentroid_0[face1]);
26124 computeTri(p_0, p_3, p_2, &faceVolume_0[face2], faceCentroid_0[face2]);
26125 computeTri(p_0, p_2, p_1, &faceVolume_0[face3], faceCentroid_0[face3]);
26127 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
26129 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
26132 m_bndryCells->a[bndryId2].m_srfcs[0]->m_area = area_c;
26133 for(
MInt dim = 0; dim < 3; dim++) {
26134 m_bndryCells->a[bndryId2].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
26135 m_bndryCells->a[bndryId2].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
26138 m_bndryCells->a[bndryId2].m_volume = volume_C;
26139 for(
MInt dim = 0; dim < 3; dim++) {
26140 m_bndryCells->a[bndryId2].m_coordinates[dim] = coordinates_Cell[dim];
26144 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]] = cellId2;
26146 faceCut[face1] =
true;
26147 faceCut[face2] =
true;
26148 faceCut[face3] =
true;
26150 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
26151 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
26152 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
26154 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
26156 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
26158 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
26159 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
26160 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
26162 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
26164 correctNormal(normalVec_c);
26167 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
26168 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
26169 for(
MInt dim = 0; dim < 3; dim++) {
26170 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
26171 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
26174 m_bndryCells->a[bndryId].m_volume = volume_C;
26175 for(
MInt dim = 0; dim < 3; dim++) {
26176 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
26185 m_bndryCells->a[bndryId].m_noSrfcs = 3;
26187 for(
MInt face = 0; face < 6; face++) {
26188 nfs_cur[face] = nfs6_1[currentSubCase][face];
26190 p_0 = corner[cornersMCtoSOLVER[tiling6_2STL[currentSubCase][0]]];
26191 p_1 = corner[cornersMCtoSOLVER[tiling6_2STL[currentSubCase][1]]];
26192 p_2 = corner[cornersMCtoSOLVER[tiling6_2STL[currentSubCase][2]]];
26193 p_4 = corner[cornersMCtoSOLVER[tiling6_2STL[currentSubCase][3]]];
26194 p_5 = corner[cornersMCtoSOLVER[tiling6_2STL[currentSubCase][4]]];
26196 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][5]];
26197 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26198 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][6]];
26199 p_0ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26200 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][7]];
26201 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26202 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][8]];
26203 p_1ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26204 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][9]];
26205 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26206 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][10]];
26207 p_2ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26208 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][11]];
26209 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26210 face1 = facesMCtoSOLVER[tiling6_2STL[currentSubCase][12]];
26211 face2 = facesMCtoSOLVER[tiling6_2STL[currentSubCase][13]];
26212 face3 = facesMCtoSOLVER[tiling6_2STL[currentSubCase][14]];
26213 face4 = facesMCtoSOLVER[tiling6_2STL[currentSubCase][15]];
26214 face5 = facesMCtoSOLVER[tiling6_2STL[currentSubCase][16]];
26215 face6 = facesMCtoSOLVER[tiling6_2STL[currentSubCase][17]];
26217 computePoly6(p_1, p_1s, p_2s, p_2, p_2ss, p_1ss, &faceVolume[face1], faceCentroid[face1], normal[face1]);
26218 computeTrapez(p_0, p_1, p_1s, p_0s, &faceVolume[face2], faceCentroid[face2], normal[face2]);
26219 computeTrapez(p_0, p_1, p_1ss, p_0ss, &faceVolume[face3], faceCentroid[face3], normal[face3]);
26220 computeTri(p_2, p_3, p_2ss, &faceVolume[face4], faceCentroid[face4], normal[face4]);
26221 computeTri(p_2s, p_2, p_3, &faceVolume[face5], faceCentroid[face5], normal[face5]);
26222 computeTri(p_0, p_0s, p_0ss, &faceVolume[face6], faceCentroid[face6], normal[face6]);
26224 maia::math::vecAvg<3>(M, p_0s, p_0ss, p_1s, p_1ss, p_2s, p_2ss, p_3, p_0, p_1, p_2);
26226 for(
MInt i = 0; i < 6; i++) {
26227 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
26228 &pyraVolume[i], pyraCentroid[i]);
26231 computePoly4(p_0s, p_3, p_2s, p_1s, &area_c, coordinates_c, normalVec_c);
26232 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[6], pyraCentroid[6]);
26233 if(currentSubCase >= 24) correctNormal(normalVec_c);
26234 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
26235 for(
MInt dim = 0; dim < 3; dim++) {
26236 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
26237 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
26240 computePoly4(p_0ss, p_1ss, p_2ss, p_3, &area_c, coordinates_c, normalVec_c);
26241 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[7], pyraCentroid[7]);
26242 if(currentSubCase >= 24) correctNormal(normalVec_c);
26243 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
26244 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
26245 for(
MInt dim = 0; dim < 3; dim++) {
26246 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
26247 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
26250 computePoly3(p_0s, p_0ss, p_3, &area_c, coordinates_c, normalVec_c);
26251 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[8], pyraCentroid[8]);
26252 if(currentSubCase >= 24) correctNormal(normalVec_c);
26253 m_bndryCells->a[bndryId].m_srfcs[2]->m_area = area_c;
26254 m_bndryCells->a[bndryId].m_srfcs[2]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
26255 for(
MInt dim = 0; dim < 3; dim++) {
26256 m_bndryCells->a[bndryId].m_srfcs[2]->m_coordinates[dim] = coordinates_c[dim];
26257 m_bndryCells->a[bndryId].m_srfcs[2]->m_normalVector[dim] = normalVec_c[dim];
26260 for(
MInt i = 0; i < 9; i++) {
26261 volume_C += pyraVolume[i];
26262 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
26264 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
26266 if(currentSubCase >= 24) {
26268 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
26269 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
26270 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
26271 correctFace(&faceVolume[face5], faceCentroid[face5], &faceVolume_0[face5], faceCentroid_0[face5]);
26272 correctFace(&faceVolume[face6], faceCentroid[face6], &faceVolume_0[face6], faceCentroid_0[face6]);
26273 splitCorner1 = cornersMCtoSOLVER[tiling6_2STL[currentSubCase][3]];
26274 splitCorner2 = cornersMCtoSOLVER[tiling6_2STL[currentSubCase][4]];
26275 computeTri(p_4, p_2s, p_1s, &splitFaceVolume[0], splitFaceCentroid[0], splitFaceNormal[0]);
26276 computeTri(p_5, p_1ss, p_2ss, &splitFaceVolume[1], splitFaceCentroid[1], splitFaceNormal[1]);
26278 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
26280 splitFaceId = face1;
26283 m_bndryCells->a[bndryId].m_volume = volume_C;
26284 for(
MInt dim = 0; dim < 3; dim++) {
26285 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
26288 faceCut[face1] =
true;
26289 faceCut[face2] =
true;
26290 faceCut[face3] =
true;
26291 faceCut[face4] =
true;
26292 faceCut[face5] =
true;
26293 faceCut[face6] =
true;
26299 disamb_tmp = disambiguation[bndryId];
26300 if(currentSubCase >= 8) disamb_tmp = 7 - disamb_tmp;
26302 switch(disamb_tmp) {
26306 for(
MInt i = 0; i < 6; i++) {
26307 faceVolume_0[i] = faceVolume[i];
26308 for(
MInt j = 0; j < 3; j++) {
26309 faceCentroid_0[i][j] = faceCentroid[i][j];
26312 cellVolume_0 = gridCellVolume;
26313 for(
MInt i = 0; i < 3; i++) {
26314 cellCentroid_0[i] = m_solver->a_coordinate(cellId, i);
26317 if(currentSubCase >= 8) {
26319 cellId2 = createSplitCell_MGC(cellId, 1);
26320 bndryId2 = m_solver->a_bndryId(cellId2);
26321 m_splitParents[bndryId2] = bndryId;
26322 m_splitChildren[bndryId * 3 + 0] = bndryId2;
26324 cerr <<
" problem in FvBndryCnd3D::createCutFaceMGC, assuming cell 0 is no split cell failed! "
26326 m_bndryCells->a[bndryId].m_noSrfcs = 1;
26327 m_bndryCells->a[bndryId2].m_noSrfcs = 1;
26329 m_bndryCells->a[bndryId].m_noSrfcs = 2;
26332 for(
MInt face = 0; face < 6; face++) {
26333 nfs_cur[face] = nfs7_1[currentSubCase][face];
26337 subCaseDummy = tiling7_4_1STL[currentSubCase][0];
26338 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
26339 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
26340 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26341 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
26342 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26343 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
26344 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26345 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
26346 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
26347 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
26349 faceCut[face1] =
true;
26350 faceCut[face2] =
true;
26351 faceCut[face3] =
true;
26353 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
26354 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
26355 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
26357 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
26359 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
26361 if(currentSubCase < 8) {
26362 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
26363 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
26364 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
26366 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
26368 correctNormal(normalVec_c);
26370 for(
MInt face = 0; face < 6; face++) {
26371 nfs_cur[face] = nfs1[subCaseDummy][face];
26376 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
26377 for(
MInt dim = 0; dim < 3; dim++) {
26378 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
26379 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
26381 m_bndryCells->a[bndryId].m_volume = volume_C;
26382 for(
MInt dim = 0; dim < 3; dim++) {
26383 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
26386 if(currentSubCase < 8) {
26387 faceVolume_0[face1] = faceVolume[face1];
26388 faceVolume_0[face2] = faceVolume[face2];
26389 faceVolume_0[face3] = faceVolume[face3];
26390 cellVolume_0 = volume_C;
26392 for(
MInt i = 0; i < 3; i++) {
26393 cellCentroid_0[i] = coordinates_Cell[i];
26394 faceCentroid_0[face1][i] = faceCentroid[face1][i];
26395 faceCentroid_0[face2][i] = faceCentroid[face2][i];
26396 faceCentroid_0[face3][i] = faceCentroid[face3][i];
26397 coordinates_Cell[i] = 0;
26401 for(
MInt i = 0; i < 3; i++) {
26402 coordinates_Cell[i] = 0;
26407 subCaseDummy = tiling7_4_1STL[currentSubCase][1];
26409 p_0 = corner[cornersMCtoSOLVER[tiling9STL[subCaseDummy][0]]];
26410 p_1 = corner[cornersMCtoSOLVER[tiling9STL[subCaseDummy][1]]];
26411 p_2 = corner[cornersMCtoSOLVER[tiling9STL[subCaseDummy][2]]];
26412 p_3 = corner[cornersMCtoSOLVER[tiling9STL[subCaseDummy][3]]];
26414 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][4]];
26415 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26416 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][5]];
26417 p_1ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26418 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][6]];
26419 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26420 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][7]];
26421 p_2ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26422 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][8]];
26423 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26424 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][9]];
26425 p_3ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26426 face1 = facesMCtoSOLVER[tiling9STL[subCaseDummy][10]];
26427 face2 = facesMCtoSOLVER[tiling9STL[subCaseDummy][11]];
26428 face3 = facesMCtoSOLVER[tiling9STL[subCaseDummy][12]];
26429 face4 = facesMCtoSOLVER[tiling9STL[subCaseDummy][13]];
26430 face5 = facesMCtoSOLVER[tiling9STL[subCaseDummy][14]];
26431 face6 = facesMCtoSOLVER[tiling9STL[subCaseDummy][15]];
26433 if(currentSubCase >= 8) {
26434 for(
MInt face = 0; face < 6; face++) {
26435 nfs_cur_0[face] = nfs9[subCaseDummy][face];
26436 faceCut_0[face] =
true;
26439 computePoly5(p_0, p_3, p_3ss, p_2s, p_2, &faceVolume_0[face1], faceCentroid_0[face1], normal[face1]);
26440 computePoly5(p_0, p_1, p_1ss, p_3s, p_3, &faceVolume_0[face3], faceCentroid_0[face3], normal[face3]);
26441 computePoly5(p_0, p_2, p_2ss, p_1s, p_1, &faceVolume_0[face5], faceCentroid_0[face5], normal[face5]);
26442 computeTri(p_1, p_1s, p_1ss, &faceVolume_0[face2], faceCentroid_0[face2], normal[face2]);
26443 computeTri(p_2, p_2s, p_2ss, &faceVolume_0[face4], faceCentroid_0[face4], normal[face4]);
26444 computeTri(p_3, p_3s, p_3ss, &faceVolume_0[face6], faceCentroid_0[face6], normal[face6]);
26446 computePoly6(p_1ss, p_1s, p_2ss, p_2s, p_3ss, p_3s, &area_c, coordinates_c, normalVec_c);
26448 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_3, p_1s, p_2s, p_3s, p_1ss, p_2ss, p_3ss);
26450 for(
MInt i = 0; i < 6; i++) {
26451 computePyra(&faceVolume_0[*facepointers[i]], faceCentroid_0[*facepointers[i]],
26452 normal[*facepointers[i]], M, &pyraVolume[i], pyraCentroid[i]);
26454 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[6], pyraCentroid[6]);
26455 for(
MInt i = 0; i < 7; i++) {
26456 volume_C += pyraVolume[i];
26457 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
26459 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
26462 m_bndryCells->a[bndryId2].m_srfcs[0]->m_area = area_c;
26463 for(
MInt dim = 0; dim < 3; dim++) {
26464 m_bndryCells->a[bndryId2].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
26465 m_bndryCells->a[bndryId2].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
26468 m_bndryCells->a[bndryId2].m_volume = volume_C;
26469 for(
MInt dim = 0; dim < 3; dim++) {
26470 m_bndryCells->a[bndryId2].m_coordinates[dim] = coordinates_Cell[dim];
26474 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling9STL[subCaseDummy][0]]] = cellId2;
26475 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling9STL[subCaseDummy][1]]] = cellId2;
26476 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling9STL[subCaseDummy][2]]] = cellId2;
26477 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling9STL[subCaseDummy][3]]] = cellId2;
26480 for(
MInt face = 0; face < 6; face++) {
26481 faceCut[face] =
true;
26484 computePoly5(p_0, p_3, p_3ss, p_2s, p_2, &faceVolume[face1], faceCentroid[face1], normal[face1]);
26485 computePoly5(p_0, p_1, p_1ss, p_3s, p_3, &faceVolume[face3], faceCentroid[face3], normal[face3]);
26486 computePoly5(p_0, p_2, p_2ss, p_1s, p_1, &faceVolume[face5], faceCentroid[face5], normal[face5]);
26487 computeTri(p_1, p_1s, p_1ss, &faceVolume[face2], faceCentroid[face2], normal[face2]);
26488 computeTri(p_2, p_2s, p_2ss, &faceVolume[face4], faceCentroid[face4], normal[face4]);
26489 computeTri(p_3, p_3s, p_3ss, &faceVolume[face6], faceCentroid[face6], normal[face6]);
26491 computePoly6(p_1ss, p_1s, p_2ss, p_2s, p_3ss, p_3s, &area_c, coordinates_c, normalVec_c);
26493 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_3, p_1s, p_2s, p_3s, p_1ss, p_2ss, p_3ss);
26495 for(
MInt i = 0; i < 6; i++) {
26496 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]],
26497 M, &pyraVolume[i], pyraCentroid[i]);
26499 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[6], pyraCentroid[6]);
26500 for(
MInt i = 0; i < 7; i++) {
26501 volume_C += pyraVolume[i];
26502 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
26504 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
26506 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
26507 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
26508 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
26509 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
26510 correctFace(&faceVolume[face5], faceCentroid[face5], &faceVolume_0[face5], faceCentroid_0[face5]);
26511 correctFace(&faceVolume[face6], faceCentroid[face6], &faceVolume_0[face6], faceCentroid_0[face6]);
26513 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
26515 correctNormal(normalVec_c);
26518 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
26519 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
26520 for(
MInt dim = 0; dim < 3; dim++) {
26521 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
26522 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
26525 m_bndryCells->a[bndryId].m_volume = volume_C;
26526 for(
MInt dim = 0; dim < 3; dim++) {
26527 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
26536 for(
MInt i = 0; i < 6; i++) {
26537 faceVolume_0[i] = faceVolume[i];
26538 faceVolume_00[i] = faceVolume[i];
26539 for(
MInt j = 0; j < 3; j++) {
26540 faceCentroid_0[i][j] = faceCentroid[i][j];
26543 cellVolume_0 = gridCellVolume;
26544 for(
MInt i = 0; i < 3; i++) {
26545 cellCentroid_0[i] = m_solver->a_coordinate(cellId, i);
26548 for(
MInt face = 0; face < 6; face++) {
26549 nfs_cur[face] = nfs7_1[currentSubCase][face];
26552 if(disamb_tmp == 1) disambPointer_dummy = &tiling7_3_1STL[0][0];
26553 if(disamb_tmp == 2) disambPointer_dummy = &tiling7_3_2STL[0][0];
26554 if(disamb_tmp == 4) disambPointer_dummy = &tiling7_3_4STL[0][0];
26556 for(
MInt i = 0; i < 16; i++)
26557 for(
MInt j = 0; j < 21; j++)
26558 disambPointer[i][j] = disambPointer_dummy[i * 21 + j];
26560 p_0 = corner[cornersMCtoSOLVER[disambPointer[currentSubCase][0]]];
26561 p_1 = corner[cornersMCtoSOLVER[disambPointer[currentSubCase][1]]];
26562 p_2 = corner[cornersMCtoSOLVER[disambPointer[currentSubCase][2]]];
26563 p_3 = corner[cornersMCtoSOLVER[disambPointer[currentSubCase][3]]];
26564 p_4 = corner[cornersMCtoSOLVER[disambPointer[currentSubCase][4]]];
26565 p_5 = corner[cornersMCtoSOLVER[disambPointer[currentSubCase][5]]];
26566 cutDummy = edgesMCtoSOLVER[disambPointer[currentSubCase][6]];
26567 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26568 cutDummy = edgesMCtoSOLVER[disambPointer[currentSubCase][7]];
26569 p_1ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26570 cutDummy = edgesMCtoSOLVER[disambPointer[currentSubCase][8]];
26571 p_1sss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26572 cutDummy = edgesMCtoSOLVER[disambPointer[currentSubCase][9]];
26573 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26574 cutDummy = edgesMCtoSOLVER[disambPointer[currentSubCase][10]];
26575 p_2ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26576 cutDummy = edgesMCtoSOLVER[disambPointer[currentSubCase][11]];
26577 p_2sss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26578 cutDummy = edgesMCtoSOLVER[disambPointer[currentSubCase][12]];
26579 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26580 cutDummy = edgesMCtoSOLVER[disambPointer[currentSubCase][13]];
26581 p_3ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26582 cutDummy = edgesMCtoSOLVER[disambPointer[currentSubCase][14]];
26583 p_3sss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26585 face1 = facesMCtoSOLVER[disambPointer[currentSubCase][15]];
26586 face2 = facesMCtoSOLVER[disambPointer[currentSubCase][16]];
26587 face3 = facesMCtoSOLVER[disambPointer[currentSubCase][17]];
26588 face4 = facesMCtoSOLVER[disambPointer[currentSubCase][18]];
26589 face5 = facesMCtoSOLVER[disambPointer[currentSubCase][19]];
26590 face6 = facesMCtoSOLVER[disambPointer[currentSubCase][20]];
26591 if(currentSubCase < 8) {
26593 m_bndryCells->a[bndryId].m_noSrfcs = 2;
26596 computePoly6(p_1, p_1sss, p_3sss, p_3, p_3s, p_1ss, &faceVolume[face2], faceCentroid[face2],
26598 computePoly6(p_1, p_1s, p_2ss, p_2, p_2sss, p_1sss, &faceVolume[face3], faceCentroid[face3],
26600 computeTri(p_1, p_1ss, p_1s, &faceVolume[face4], faceCentroid[face4], normal[face4]);
26601 computeTri(p_2, p_2ss, p_2s, &faceVolume[face5], faceCentroid[face5], normal[face5]);
26602 computeTri(p_3, p_3ss, p_3s, &faceVolume[face6], faceCentroid[face6], normal[face6]);
26603 splitCorner1 = cornersMCtoSOLVER[disambPointer[currentSubCase][3]];
26604 splitCorner2 = cornersMCtoSOLVER[disambPointer[currentSubCase][2]];
26605 computeTri(p_3, p_3sss, p_3ss, &splitFaceVolume[0], splitFaceCentroid[0], splitFaceNormal[0]);
26606 computeTri(p_2, p_2s, p_2sss, &splitFaceVolume[1], splitFaceCentroid[1], splitFaceNormal[1]);
26608 splitFaceId = face1;
26609 maia::math::vecAvg<3>(M, p_1s, p_1ss, p_1sss, p_2s, p_2ss, p_2sss, p_3s, p_3ss, p_3sss);
26611 faceVolume[face1] = F0;
26613 for(
MInt i = 0; i < 6; i++) {
26614 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]],
26615 M, &pyraVolume[i], pyraCentroid[i]);
26617 computePyra(&splitFaceVolume[0], splitFaceCentroid[0], splitFaceNormal[0], M, &pyraVolume[6],
26619 computePyra(&splitFaceVolume[1], splitFaceCentroid[1], splitFaceNormal[1], M, &pyraVolume[7],
26623 computePoly5(p_1sss, p_2sss, p_2s, p_3ss, p_3sss, &area_c, coordinates_c, normalVec_c);
26624 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[8], pyraCentroid[8]);
26625 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
26626 for(
MInt dim = 0; dim < 3; dim++) {
26627 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
26628 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
26631 computePoly6(p_1s, p_1ss, p_3s, p_3ss, p_2s, p_2ss, &area_c, coordinates_c, normalVec_c);
26632 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[9], pyraCentroid[9]);
26633 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
26634 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
26635 for(
MInt dim = 0; dim < 3; dim++) {
26636 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
26637 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
26640 for(
MInt i = 0; i < 10; i++) {
26641 volume_C += pyraVolume[i];
26642 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
26644 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
26646 m_bndryCells->a[bndryId].m_volume = volume_C;
26647 for(
MInt dim = 0; dim < 3; dim++) {
26648 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
26651 faceCut[face1] =
true;
26652 faceCut[face2] =
true;
26653 faceCut[face3] =
true;
26654 faceCut[face4] =
true;
26655 faceCut[face5] =
true;
26656 faceCut[face6] =
true;
26660 m_bndryCells->a[bndryId].m_noSrfcs = 3;
26663 computeTri(p_3, p_3sss, p_3ss, &faceVolume[face1], faceCentroid[face1], normal[face1]);
26664 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
26665 faceVolume_0[face1] = faceVolume[face1];
26666 computeTri(p_2, p_2s, p_2sss, &faceVolume[face1], faceCentroid[face1], normal[face1]);
26667 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
26669 computeTri(p_4, p_1ss, p_3s, &splitFaceVolume[0], splitFaceCentroid[0], splitFaceNormal[0]);
26670 computeTri(p_0, p_3sss, p_1sss, &splitFaceVolume[1], splitFaceCentroid[1], splitFaceNormal[1]);
26671 splitCorner1 = cornersMCtoSOLVER[disambPointer[currentSubCase][4]];
26672 splitCorner2 = cornersMCtoSOLVER[disambPointer[currentSubCase][0]];
26674 computeTri(p_5, p_2ss, p_1s, &splitFaceVolume2[0], splitFaceCentroid2[0], splitFaceNormal2[0]);
26675 computeTri(p_0, p_1sss, p_2sss, &splitFaceVolume2[1], splitFaceCentroid2[1], splitFaceNormal2[1]);
26676 splitCorner12 = cornersMCtoSOLVER[disambPointer[currentSubCase][5]];
26677 splitCorner22 = cornersMCtoSOLVER[disambPointer[currentSubCase][0]];
26679 computeTri(p_1, p_1ss, p_1s, &faceVolume[face4], faceCentroid[face4], normal[face4]);
26680 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
26681 computeTri(p_2, p_2ss, p_2s, &faceVolume[face5], faceCentroid[face5], normal[face5]);
26682 correctFace(&faceVolume[face5], faceCentroid[face5], &faceVolume_0[face5], faceCentroid_0[face5]);
26683 computeTri(p_3, p_3ss, p_3s, &faceVolume[face6], faceCentroid[face6], normal[face6]);
26684 correctFace(&faceVolume[face6], faceCentroid[face6], &faceVolume_0[face6], faceCentroid_0[face6]);
26686 splitFaceId = face2;
26687 splitFaceId2 = face3;
26688 maia::math::vecAvg<3>(M, p_1s, p_1ss, p_1sss, p_2s, p_2ss, p_2sss, p_3s, p_3ss, p_3sss);
26690 faceVolume[face2] = F0;
26691 faceVolume[face3] = F0;
26693 for(
MInt i = 0; i < 6; i++) {
26694 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]],
26695 M, &pyraVolume[i], pyraCentroid[i]);
26697 computePyra(&splitFaceVolume[0], splitFaceCentroid[0], splitFaceNormal[0], M, &pyraVolume[6],
26699 computePyra(&splitFaceVolume[1], splitFaceCentroid[1], splitFaceNormal[1], M, &pyraVolume[7],
26701 computePyra(&splitFaceVolume2[0], splitFaceCentroid2[0], splitFaceNormal2[0], M, &pyraVolume[8],
26703 computePyra(&splitFaceVolume2[1], splitFaceCentroid2[1], splitFaceNormal2[1], M, &pyraVolume[9],
26706 computePoly5(p_1ss, p_1sss, p_3sss, p_3ss, p_3s, &area_c, coordinates_c, normalVec_c);
26707 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[10], pyraCentroid[10]);
26708 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
26709 for(
MInt dim = 0; dim < 3; dim++) {
26710 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
26711 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
26714 computePoly5(p_1sss, p_1s, p_2ss, p_2s, p_2sss, &area_c, coordinates_c, normalVec_c);
26715 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[11], pyraCentroid[11]);
26716 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
26717 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
26718 for(
MInt dim = 0; dim < 3; dim++) {
26719 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
26720 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
26723 computePoly3(p_1s, p_1sss, p_1ss, &area_c, coordinates_c, normalVec_c);
26724 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[12], pyraCentroid[12]);
26725 m_bndryCells->a[bndryId].m_srfcs[2]->m_area = area_c;
26726 m_bndryCells->a[bndryId].m_srfcs[2]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
26727 for(
MInt dim = 0; dim < 3; dim++) {
26728 m_bndryCells->a[bndryId].m_srfcs[2]->m_coordinates[dim] = coordinates_c[dim];
26729 m_bndryCells->a[bndryId].m_srfcs[2]->m_normalVector[dim] = normalVec_c[dim];
26732 for(
MInt i = 0; i < 13; i++) {
26733 volume_C += pyraVolume[i];
26734 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
26736 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
26738 m_bndryCells->a[bndryId].m_volume = volume_C;
26739 for(
MInt dim = 0; dim < 3; dim++) {
26740 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
26743 faceCut[face1] =
true;
26744 faceCut[face2] =
true;
26745 faceCut[face3] =
true;
26746 faceCut[face4] =
true;
26747 faceCut[face5] =
true;
26748 faceCut[face6] =
true;
26757 if(disamb_tmp == 3) disambPointer_dummy = &tiling7_2_3STL[0][0];
26758 if(disamb_tmp == 5) disambPointer_dummy = &tiling7_2_5STL[0][0];
26759 if(disamb_tmp == 6) disambPointer_dummy = &tiling7_2_6STL[0][0];
26761 for(
MInt i = 0; i < 16; i++)
26762 for(
MInt j = 0; j < 2; j++)
26763 disambPointer[i][j] = disambPointer_dummy[i * 2 + j];
26765 for(
MInt i = 0; i < 6; i++) {
26766 faceVolume_0[i] = faceVolume[i];
26767 for(
MInt j = 0; j < 3; j++) {
26768 faceCentroid_0[i][j] = faceCentroid[i][j];
26771 cellVolume_0 = gridCellVolume;
26772 for(
MInt i = 0; i < 3; i++) {
26773 cellCentroid_0[i] = m_solver->a_coordinate(cellId, i);
26776 if(currentSubCase < 8) {
26778 cellId2 = createSplitCell_MGC(cellId, 1);
26779 bndryId2 = m_solver->a_bndryId(cellId2);
26780 m_splitParents[bndryId2] = bndryId;
26781 m_splitChildren[bndryId * 3 + 0] = bndryId2;
26783 cerr <<
" problem in FvBndryCnd3D::createCutFaceMGC, assuming cell 0 is no split cell failed! "
26785 m_bndryCells->a[bndryId].m_noSrfcs = 1;
26786 m_bndryCells->a[bndryId2].m_noSrfcs = 1;
26788 m_bndryCells->a[bndryId].m_noSrfcs = 2;
26791 for(
MInt face = 0; face < 6; face++) {
26792 nfs_cur[face] = nfs7_1[currentSubCase][face];
26796 subCaseDummy = disambPointer[currentSubCase][0];
26797 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
26798 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
26799 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26800 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
26801 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26802 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
26803 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26804 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
26805 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
26806 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
26808 faceCut[face1] =
true;
26809 faceCut[face2] =
true;
26810 faceCut[face3] =
true;
26812 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
26813 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
26814 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
26816 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
26818 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
26820 if(currentSubCase >= 8) {
26821 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
26822 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
26823 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
26825 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
26827 correctNormal(normalVec_c);
26829 for(
MInt face = 0; face < 6; face++) {
26830 nfs_cur[face] = nfs1[subCaseDummy][face];
26835 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
26836 for(
MInt dim = 0; dim < 3; dim++) {
26837 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
26838 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
26840 m_bndryCells->a[bndryId].m_volume = volume_C;
26841 for(
MInt dim = 0; dim < 3; dim++) {
26842 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
26845 if(currentSubCase >= 8) {
26846 faceVolume_0[face1] = faceVolume[face1];
26847 faceVolume_0[face2] = faceVolume[face2];
26848 faceVolume_0[face3] = faceVolume[face3];
26849 cellVolume_0 = volume_C;
26851 for(
MInt i = 0; i < 3; i++) {
26852 cellCentroid_0[i] = coordinates_Cell[i];
26853 faceCentroid_0[face1][i] = faceCentroid[face1][i];
26854 faceCentroid_0[face2][i] = faceCentroid[face2][i];
26855 faceCentroid_0[face3][i] = faceCentroid[face3][i];
26856 coordinates_Cell[i] = 0;
26860 for(
MInt i = 0; i < 3; i++) {
26861 coordinates_Cell[i] = 0;
26866 subCaseDummy = disambPointer[currentSubCase][1];
26871 p_0 = corner[cornersMCtoSOLVER[tiling3_2STL[subCaseDummy][0]]];
26872 p_0s = corner[cornersMCtoSOLVER[tiling3_2STL[subCaseDummy][1]]];
26874 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][2]];
26875 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26876 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][3]];
26877 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26878 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][4]];
26879 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26880 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][5]];
26881 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26882 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][6]];
26883 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26884 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][7]];
26885 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
26886 face1 = facesMCtoSOLVER[tiling3_2STL[subCaseDummy][8]];
26887 face2 = facesMCtoSOLVER[tiling3_2STL[subCaseDummy][9]];
26888 face3 = facesMCtoSOLVER[tiling3_2STL[subCaseDummy][10]];
26889 face4 = facesMCtoSOLVER[tiling3_2STL[subCaseDummy][11]];
26890 face5 = facesMCtoSOLVER[tiling3_2STL[subCaseDummy][12]];
26892 if(currentSubCase < 8) {
26893 for(
MInt face = 0; face < 6; face++) {
26894 nfs_cur_0[face] = nfs3_2[subCaseDummy][face];
26896 faceCut_0[face1] =
true;
26897 faceCut_0[face2] =
true;
26898 faceCut_0[face3] =
true;
26899 faceCut_0[face4] =
true;
26900 faceCut_0[face5] =
true;
26902 computeTri(p_0, p_1, p_2, &faceVolume_0[face1], faceCentroid_0[face1], normal[face1]);
26903 computeTri(p_0, p_2, p_3, &faceVolume_0[face2], faceCentroid_0[face2], normal[face2]);
26904 computeTri(p_0s, p_2s, p_3s, &faceVolume_0[face3], faceCentroid_0[face3], normal[face3]);
26905 computeTri(p_0s, p_1s, p_2s, &faceVolume_0[face4], faceCentroid_0[face4], normal[face4]);
26906 computePoly6(p_0, p_1, p_3s, p_0s, p_1s, p_3, &faceVolume_0[face5], faceCentroid_0[face5],
26909 computePoly6(p_1, p_2, p_3, p_1s, p_2s, p_3s, &area_c, coordinates_c, normalVec_c);
26911 maia::math::vecAvg<3>(M, p_0, p_0s, p_1, p_1s, p_2, p_2s, p_3, p_3s);
26913 for(
MInt i = 0; i < 5; i++) {
26914 computePyra(&faceVolume_0[*facepointers[i]], faceCentroid_0[*facepointers[i]],
26915 normal[*facepointers[i]], M, &pyraVolume[i], pyraCentroid[i]);
26917 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[5], pyraCentroid[5]);
26919 for(
MInt i = 0; i < 6; i++) {
26920 volume_C += pyraVolume[i];
26921 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
26923 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
26926 for(
MInt i = 0; i < nDim; i++) {
26927 if(!nfs_cur_0[2 * i + 1]) faceVolume_0[2 * i + 1] = 0;
26928 if(!nfs_cur_0[2 * i]) faceVolume_0[2 * i] = 0;
26929 faceDiff[i] = faceVolume_0[2 * i + 1] - faceVolume_0[2 * i];
26930 absA +=
POW2(faceDiff[i]);
26933 for(
MInt i = 0; i < nDim; i++) {
26934 normalVec_c[i] = faceDiff[i] / sqrt(absA);
26936 area_c = sqrt(absA);
26940 m_bndryCells->a[bndryId2].m_srfcs[0]->m_area = area_c;
26941 for(
MInt dim = 0; dim < 3; dim++) {
26942 m_bndryCells->a[bndryId2].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
26943 m_bndryCells->a[bndryId2].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
26946 m_bndryCells->a[bndryId2].m_volume = volume_C;
26947 for(
MInt dim = 0; dim < 3; dim++) {
26948 m_bndryCells->a[bndryId2].m_coordinates[dim] = coordinates_Cell[dim];
26952 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling3_2STL[subCaseDummy][0]]] = cellId2;
26953 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling3_2STL[subCaseDummy][1]]] = cellId2;
26955 faceCut[face1] =
true;
26956 faceCut[face2] =
true;
26957 faceCut[face3] =
true;
26958 faceCut[face4] =
true;
26959 faceCut[face5] =
true;
26961 computeTri(p_0, p_1, p_2, &faceVolume[face1], faceCentroid[face1], normal[face1]);
26962 computeTri(p_0, p_2, p_3, &faceVolume[face2], faceCentroid[face2], normal[face2]);
26963 computeTri(p_0s, p_2s, p_3s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
26964 computeTri(p_0s, p_1s, p_2s, &faceVolume[face4], faceCentroid[face4], normal[face4]);
26965 computePoly6(p_0, p_1, p_3s, p_0s, p_1s, p_3, &faceVolume[face5], faceCentroid[face5], normal[face5]);
26967 computePoly6(p_1, p_2, p_3, p_1s, p_2s, p_3s, &area_c, coordinates_c, normalVec_c);
26969 maia::math::vecAvg<3>(M, p_0, p_0s, p_1, p_1s, p_2, p_2s, p_3, p_3s);
26971 for(
MInt i = 0; i < 5; i++) {
26972 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]],
26973 M, &pyraVolume[i], pyraCentroid[i]);
26975 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[5], pyraCentroid[5]);
26977 for(
MInt i = 0; i < 6; i++) {
26978 volume_C += pyraVolume[i];
26979 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
26981 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
26984 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
26985 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
26986 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
26987 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
26988 p_1ss = corner[cornersMCtoSOLVER[tiling3_2STL[subCaseDummy][13]]];
26989 p_2ss = corner[cornersMCtoSOLVER[tiling3_2STL[subCaseDummy][14]]];
26990 splitCorner1 = cornersMCtoSOLVER[tiling3_2STL[subCaseDummy][13]];
26991 splitCorner2 = cornersMCtoSOLVER[tiling3_2STL[subCaseDummy][14]];
26992 computeTri(p_1s, p_1ss, p_3, &splitFaceVolume[0], splitFaceCentroid[0], splitFaceNormal[0]);
26993 computeTri(p_1, p_2ss, p_3s, &splitFaceVolume[1], splitFaceCentroid[1], splitFaceNormal[1]);
26994 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
26996 correctNormal(normalVec_c);
26997 splitFaceId = face5;
27000 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
27001 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
27002 for(
MInt dim = 0; dim < 3; dim++) {
27003 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
27004 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
27007 m_bndryCells->a[bndryId].m_volume = volume_C;
27008 for(
MInt dim = 0; dim < 3; dim++) {
27009 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
27015 if(currentSubCase < 8) {
27017 cellId2 = createSplitCell_MGC(cellId, 1);
27018 bndryId2 = m_solver->a_bndryId(cellId2);
27019 cellId3 = createSplitCell_MGC(cellId, 2);
27020 bndryId3 = m_solver->a_bndryId(cellId3);
27021 m_splitParents[bndryId2] = bndryId;
27022 m_splitParents[bndryId3] = bndryId;
27023 m_splitChildren[bndryId * 3 + 0] = bndryId2;
27024 m_splitChildren[bndryId * 3 + 1] = bndryId3;
27026 cerr <<
" problem in FvBndryCnd3D::createCutFaceMGC, assuming cell 0 is no split cell failed! "
27028 m_bndryCells->a[bndryId].m_noSrfcs = 1;
27029 m_bndryCells->a[bndryId2].m_noSrfcs = 1;
27030 m_bndryCells->a[bndryId3].m_noSrfcs = 1;
27032 m_bndryCells->a[bndryId].m_noSrfcs = 3;
27035 for(
MInt face = 0; face < 6; face++) {
27036 nfs_cur[face] = nfs7_1[currentSubCase][face];
27040 subCaseDummy = tiling7_1STL[currentSubCase][0];
27041 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
27042 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
27043 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27044 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
27045 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27046 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
27047 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27048 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
27049 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
27050 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
27052 faceCut[face1] =
true;
27053 faceCut[face2] =
true;
27054 faceCut[face3] =
true;
27056 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
27057 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
27058 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
27060 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
27062 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
27064 if(currentSubCase >= 8) {
27065 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
27066 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
27067 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
27069 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
27071 correctNormal(normalVec_c);
27073 for(
MInt face = 0; face < 6; face++) {
27074 nfs_cur[face] = nfs1[subCaseDummy][face];
27079 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
27080 for(
MInt dim = 0; dim < 3; dim++) {
27081 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
27082 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
27084 m_bndryCells->a[bndryId].m_volume = volume_C;
27085 for(
MInt dim = 0; dim < 3; dim++) {
27086 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
27089 if(currentSubCase >= 8) {
27090 faceVolume_0[face1] = faceVolume[face1];
27091 faceVolume_0[face2] = faceVolume[face2];
27092 faceVolume_0[face3] = faceVolume[face3];
27093 cellVolume_0 = volume_C;
27094 for(
MInt i = 0; i < 3; i++) {
27095 cellCentroid_0[i] = coordinates_Cell[i];
27096 faceCentroid_0[face1][i] = faceCentroid[face1][i];
27097 faceCentroid_0[face2][i] = faceCentroid[face2][i];
27098 faceCentroid_0[face3][i] = faceCentroid[face3][i];
27103 subCaseDummy = tiling7_1STL[currentSubCase][1];
27104 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
27105 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
27106 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27107 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
27108 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27109 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
27110 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27111 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
27112 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
27113 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
27115 if(currentSubCase < 8) {
27116 for(
MInt face = 0; face < 6; face++) {
27117 nfs_cur_0[face] = nfs1[subCaseDummy][face];
27120 faceCut_0[face1] =
true;
27121 faceCut_0[face2] =
true;
27122 faceCut_0[face3] =
true;
27124 computeTri(p_0, p_1, p_3, &faceVolume_0[face1], faceCentroid_0[face1]);
27125 computeTri(p_0, p_3, p_2, &faceVolume_0[face2], faceCentroid_0[face2]);
27126 computeTri(p_0, p_2, p_1, &faceVolume_0[face3], faceCentroid_0[face3]);
27128 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
27130 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
27133 m_bndryCells->a[bndryId2].m_srfcs[0]->m_area = area_c;
27134 for(
MInt dim = 0; dim < 3; dim++) {
27135 m_bndryCells->a[bndryId2].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
27136 m_bndryCells->a[bndryId2].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
27139 m_bndryCells->a[bndryId2].m_volume = volume_C;
27140 for(
MInt dim = 0; dim < 3; dim++) {
27141 m_bndryCells->a[bndryId2].m_coordinates[dim] = coordinates_Cell[dim];
27144 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]] = cellId2;
27146 faceCut[face1] =
true;
27147 faceCut[face2] =
true;
27148 faceCut[face3] =
true;
27150 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
27151 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
27152 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
27154 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
27156 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
27158 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
27159 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
27160 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
27162 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
27164 correctNormal(normalVec_c);
27167 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
27168 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
27169 for(
MInt dim = 0; dim < 3; dim++) {
27170 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
27171 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
27174 m_bndryCells->a[bndryId].m_volume = volume_C;
27175 for(
MInt dim = 0; dim < 3; dim++) {
27176 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
27180 if(currentSubCase >= 8) {
27181 faceVolume_0[face1] = faceVolume[face1];
27182 faceVolume_0[face2] = faceVolume[face2];
27183 faceVolume_0[face3] = faceVolume[face3];
27184 cellVolume_0 = volume_C;
27185 for(
MInt i = 0; i < 3; i++) {
27186 cellCentroid_0[i] = coordinates_Cell[i];
27187 faceCentroid_0[face1][i] = faceCentroid[face1][i];
27188 faceCentroid_0[face2][i] = faceCentroid[face2][i];
27189 faceCentroid_0[face3][i] = faceCentroid[face3][i];
27194 subCaseDummy = tiling7_1STL[currentSubCase][2];
27195 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
27196 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
27197 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27198 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
27199 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27200 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
27201 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27202 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
27203 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
27204 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
27206 if(currentSubCase < 8) {
27207 for(
MInt face = 0; face < 6; face++) {
27208 nfs_cur_00[face] = nfs1[subCaseDummy][face];
27211 faceCut_00[face1] =
true;
27212 faceCut_00[face2] =
true;
27213 faceCut_00[face3] =
true;
27215 computeTri(p_0, p_1, p_3, &faceVolume_00[face1], faceCentroid_00[face1]);
27216 computeTri(p_0, p_3, p_2, &faceVolume_00[face2], faceCentroid_00[face2]);
27217 computeTri(p_0, p_2, p_1, &faceVolume_00[face3], faceCentroid_00[face3]);
27219 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
27221 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
27224 m_bndryCells->a[bndryId3].m_srfcs[0]->m_area = area_c;
27225 for(
MInt dim = 0; dim < 3; dim++) {
27226 m_bndryCells->a[bndryId3].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
27227 m_bndryCells->a[bndryId3].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
27230 m_bndryCells->a[bndryId3].m_volume = volume_C;
27231 for(
MInt dim = 0; dim < 3; dim++) {
27232 m_bndryCells->a[bndryId3].m_coordinates[dim] = coordinates_Cell[dim];
27236 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]] = cellId3;
27239 faceCut[face1] =
true;
27240 faceCut[face2] =
true;
27241 faceCut[face3] =
true;
27243 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
27244 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
27245 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
27247 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
27249 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
27251 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
27252 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
27253 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
27255 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
27257 correctNormal(normalVec_c);
27260 m_bndryCells->a[bndryId].m_srfcs[2]->m_area = area_c;
27261 m_bndryCells->a[bndryId].m_srfcs[2]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
27262 for(
MInt dim = 0; dim < 3; dim++) {
27263 m_bndryCells->a[bndryId].m_srfcs[2]->m_coordinates[dim] = coordinates_c[dim];
27264 m_bndryCells->a[bndryId].m_srfcs[2]->m_normalVector[dim] = normalVec_c[dim];
27267 m_bndryCells->a[bndryId].m_volume = volume_C;
27268 for(
MInt dim = 0; dim < 3; dim++) {
27269 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
27275 stringstream errorMessage;
27276 errorMessage <<
"ERROR: Switch variable 'disamb_tmp' with value " << disamb_tmp
27277 <<
" not matching any case." << endl;
27278 mTerm(1, AT_, errorMessage.str());
27284 for(
MInt i = 0; i < 6; i++) {
27285 faceVolume_0[i] = faceVolume[i];
27286 for(
MInt j = 0; j < 3; j++) {
27287 faceCentroid_0[i][j] = faceCentroid[i][j];
27290 cellVolume_0 = gridCellVolume;
27291 for(
MInt i = 0; i < 3; i++) {
27292 cellCentroid_0[i] = m_solver->a_coordinate(cellId, i);
27295 if(disambiguation[bndryId] == 3) {
27297 cellId2 = createSplitCell_MGC(cellId, 1);
27298 bndryId2 = m_solver->a_bndryId(cellId2);
27299 m_splitParents[bndryId2] = bndryId;
27300 m_splitChildren[bndryId * 3 + 0] = bndryId2;
27302 cerr <<
" problem in FvBndryCnd3D::createCutFaceMGC, assuming cell 0 is no split cell failed! " << endl;
27303 m_bndryCells->a[bndryId].m_noSrfcs = 1;
27304 m_bndryCells->a[bndryId2].m_noSrfcs = 1;
27307 subCaseDummy = tiling10_2STL[currentSubCase][0];
27308 for(
MInt face = 0; face < 6; face++) {
27309 nfs_cur[face] = nfs2[subCaseDummy][face];
27311 p_0 = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][0]]];
27312 p_0s = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][1]]];
27313 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
27314 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27315 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
27316 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27317 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
27318 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27319 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
27320 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27321 face1 = facesMCtoSOLVER[tiling2STL[subCaseDummy][6]];
27322 face2 = facesMCtoSOLVER[tiling2STL[subCaseDummy][7]];
27323 face3 = facesMCtoSOLVER[tiling2STL[subCaseDummy][8]];
27324 face4 = facesMCtoSOLVER[tiling2STL[subCaseDummy][9]];
27326 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2], normal[face2]);
27327 computeTri(p_0s, p_3s, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
27328 computeTrapez(p_0, p_0s, p_3s, p_3, &faceVolume[face1], faceCentroid[face1], normal[face1]);
27329 computeTrapez(p_2, p_2s, p_0s, p_0, &faceVolume[face4], faceCentroid[face4], normal[face4]);
27331 computePoly4(p_3, p_3s, p_2s, p_2, &area_c, coordinates_c, normalVec_c);
27333 maia::math::vecAvg<3>(M, p_0, p_0s, p_2, p_2s, p_3, p_3s);
27335 for(
MInt i = 0; i < 4; i++) {
27336 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
27337 &pyraVolume[i], pyraCentroid[i]);
27339 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[4], pyraCentroid[4]);
27340 for(
MInt i = 0; i < 5; i++) {
27341 volume_C += pyraVolume[i];
27342 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
27344 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
27346 faceCut[face1] =
true;
27347 faceCut[face2] =
true;
27348 faceCut[face3] =
true;
27349 faceCut[face4] =
true;
27352 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
27353 for(
MInt dim = 0; dim < 3; dim++) {
27354 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
27355 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
27358 m_bndryCells->a[bndryId].m_volume = volume_C;
27360 for(
MInt dim = 0; dim < 3; dim++) {
27361 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
27362 coordinates_Cell[dim] = F0;
27366 subCaseDummy = tiling10_2STL[currentSubCase][1];
27367 for(
MInt face = 0; face < 6; face++) {
27368 nfs_cur_0[face] = nfs2[subCaseDummy][face];
27370 p_0 = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][0]]];
27371 p_0s = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][1]]];
27372 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
27373 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27374 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
27375 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27376 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
27377 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27378 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
27379 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27380 face1 = facesMCtoSOLVER[tiling2STL[subCaseDummy][6]];
27381 face2 = facesMCtoSOLVER[tiling2STL[subCaseDummy][7]];
27382 face3 = facesMCtoSOLVER[tiling2STL[subCaseDummy][8]];
27383 face4 = facesMCtoSOLVER[tiling2STL[subCaseDummy][9]];
27385 computeTri(p_0, p_3, p_2, &faceVolume_0[face2], faceCentroid_0[face2], normal[face2]);
27386 computeTri(p_0s, p_3s, p_2s, &faceVolume_0[face3], faceCentroid_0[face3], normal[face3]);
27387 computeTrapez(p_0, p_0s, p_3s, p_3, &faceVolume_0[face1], faceCentroid_0[face1], normal[face1]);
27388 computeTrapez(p_2, p_2s, p_0s, p_0, &faceVolume_0[face4], faceCentroid_0[face4], normal[face4]);
27390 computePoly4(p_3, p_3s, p_2s, p_2, &area_c, coordinates_c, normalVec_c);
27392 maia::math::vecAvg<3>(M, p_0, p_0s, p_2, p_2s, p_3, p_3s);
27394 for(
MInt i = 0; i < 4; i++) {
27395 computePyra(&faceVolume_0[*facepointers[i]], faceCentroid_0[*facepointers[i]], normal[*facepointers[i]],
27396 M, &pyraVolume[i], pyraCentroid[i]);
27398 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[4], pyraCentroid[4]);
27399 for(
MInt i = 0; i < 5; i++) {
27400 volume_C += pyraVolume[i];
27401 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
27403 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
27405 faceCut_0[face1] =
true;
27406 faceCut_0[face2] =
true;
27407 faceCut_0[face3] =
true;
27408 faceCut_0[face4] =
true;
27411 m_bndryCells->a[bndryId2].m_srfcs[0]->m_area = area_c;
27412 for(
MInt dim = 0; dim < 3; dim++) {
27413 m_bndryCells->a[bndryId2].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
27414 m_bndryCells->a[bndryId2].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
27417 m_bndryCells->a[bndryId2].m_volume = volume_C;
27418 for(
MInt dim = 0; dim < 3; dim++) {
27419 m_bndryCells->a[bndryId2].m_coordinates[dim] = coordinates_Cell[dim];
27423 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling2STL[subCaseDummy][0]]] = cellId2;
27424 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling2STL[subCaseDummy][1]]] = cellId2;
27426 }
else if(disambiguation[bndryId] == 0) {
27429 m_bndryCells->a[bndryId].m_noSrfcs = 2;
27430 for(
MInt face = 0; face < 6; face++) {
27431 nfs_cur[face] = nfs10[currentSubCase][face];
27435 subCaseDummy = tiling10_1STL[currentSubCase][0];
27436 p_0 = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][0]]];
27437 p_0s = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][1]]];
27438 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
27439 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27440 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
27441 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27442 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
27443 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27444 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
27445 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27446 face1 = facesMCtoSOLVER[tiling2STL[subCaseDummy][6]];
27447 face2 = facesMCtoSOLVER[tiling2STL[subCaseDummy][7]];
27448 face3 = facesMCtoSOLVER[tiling2STL[subCaseDummy][8]];
27449 face4 = facesMCtoSOLVER[tiling2STL[subCaseDummy][9]];
27451 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2], normal[face2]);
27452 computeTri(p_0s, p_3s, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
27453 computeTrapez(p_0, p_0s, p_3s, p_3, &faceVolume[face1], faceCentroid[face1], normal[face1]);
27454 computeTrapez(p_2, p_2s, p_0s, p_0, &faceVolume[face4], faceCentroid[face4], normal[face4]);
27456 computePoly4(p_3, p_3s, p_2s, p_2, &area_c, coordinates_c, normalVec_c);
27458 maia::math::vecAvg<3>(M, p_0, p_0s, p_2, p_2s, p_3, p_3s);
27460 for(
MInt i = 0; i < 4; i++) {
27461 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
27462 &pyraVolume[i], pyraCentroid[i]);
27464 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[4], pyraCentroid[4]);
27465 for(
MInt i = 0; i < 5; i++) {
27466 volume_C += pyraVolume[i];
27467 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
27469 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
27471 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
27472 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
27473 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
27474 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
27476 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
27478 correctNormal(normalVec_c);
27480 faceCut[face1] =
true;
27481 faceCut[face2] =
true;
27482 faceCut[face3] =
true;
27483 faceCut[face4] =
true;
27486 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
27487 for(
MInt dim = 0; dim < 3; dim++) {
27488 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
27489 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
27492 faceVolume_0[face1] = faceVolume[face1];
27493 faceVolume_0[face2] = faceVolume[face2];
27494 faceVolume_0[face3] = faceVolume[face3];
27495 faceVolume_0[face4] = faceVolume[face4];
27496 cellVolume_0 = volume_C;
27498 for(
MInt i = 0; i < 3; i++) {
27499 cellCentroid_0[i] = coordinates_Cell[i];
27500 faceCentroid_0[face1][i] = faceCentroid[face1][i];
27501 faceCentroid_0[face2][i] = faceCentroid[face2][i];
27502 faceCentroid_0[face3][i] = faceCentroid[face3][i];
27503 faceCentroid_0[face4][i] = faceCentroid[face4][i];
27504 coordinates_Cell[i] = 0;
27508 subCaseDummy = tiling10_1STL[currentSubCase][1];
27509 p_0 = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][0]]];
27510 p_0s = corner[cornersMCtoSOLVER[tiling2STL[subCaseDummy][1]]];
27511 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
27512 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27513 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
27514 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27515 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
27516 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27517 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
27518 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27519 face1 = facesMCtoSOLVER[tiling2STL[subCaseDummy][6]];
27520 face2 = facesMCtoSOLVER[tiling2STL[subCaseDummy][7]];
27521 face3 = facesMCtoSOLVER[tiling2STL[subCaseDummy][8]];
27522 face4 = facesMCtoSOLVER[tiling2STL[subCaseDummy][9]];
27524 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2], normal[face2]);
27525 computeTri(p_0s, p_3s, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
27526 computeTrapez(p_0, p_0s, p_3s, p_3, &faceVolume[face1], faceCentroid[face1], normal[face1]);
27527 computeTrapez(p_2, p_2s, p_0s, p_0, &faceVolume[face4], faceCentroid[face4], normal[face4]);
27529 computePoly4(p_3, p_3s, p_2s, p_2, &area_c, coordinates_c, normalVec_c);
27531 maia::math::vecAvg<3>(M, p_0, p_0s, p_2, p_2s, p_3, p_3s);
27533 for(
MInt i = 0; i < 4; i++) {
27534 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
27535 &pyraVolume[i], pyraCentroid[i]);
27537 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[4], pyraCentroid[4]);
27538 for(
MInt i = 0; i < 5; i++) {
27539 volume_C += pyraVolume[i];
27540 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
27542 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
27544 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
27545 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
27546 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
27547 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
27549 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
27551 correctNormal(normalVec_c);
27553 faceCut[face1] =
true;
27554 faceCut[face2] =
true;
27555 faceCut[face3] =
true;
27556 faceCut[face4] =
true;
27559 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
27560 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
27561 for(
MInt dim = 0; dim < 3; dim++) {
27562 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
27563 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
27566 m_bndryCells->a[bndryId].m_volume = volume_C;
27567 for(
MInt dim = 0; dim < 3; dim++) {
27568 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
27574 for(
MInt i = 0; i < 6; i++) {
27575 faceVolume_0[i] = faceVolume[i];
27576 for(
MInt j = 0; j < 3; j++) {
27577 faceCentroid_0[i][j] = faceCentroid[i][j];
27580 cellVolume_0 = gridCellVolume;
27581 for(
MInt i = 0; i < 3; i++) {
27582 cellCentroid_0[i] = m_solver->a_coordinate(cellId, i);
27585 if(disambiguation[bndryId] == 3) {
27587 cellId2 = createSplitCell_MGC(cellId, 1);
27588 bndryId2 = m_solver->a_bndryId(cellId2);
27589 m_splitParents[bndryId2] = bndryId;
27590 m_splitChildren[bndryId * 3 + 0] = bndryId2;
27592 cerr <<
" problem in FvBndryCnd3D::createCutFaceMGC, assuming cell 0 is no split cell failed! " << endl;
27593 m_bndryCells->a[bndryId].m_noSrfcs = 1;
27594 m_bndryCells->a[bndryId2].m_noSrfcs = 1;
27597 subCaseDummy = tiling12_1STL[23 - currentSubCase][0];
27598 for(
MInt face = 0; face < 6; face++) {
27599 nfs_cur[face] = nfs5[subCaseDummy][face];
27601 p_0 = corner[cornersMCtoSOLVER[tiling5STL[subCaseDummy][0]]];
27602 p_1 = corner[cornersMCtoSOLVER[tiling5STL[subCaseDummy][1]]];
27603 p_2 = corner[cornersMCtoSOLVER[tiling5STL[subCaseDummy][2]]];
27604 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][3]];
27605 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27606 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][4]];
27607 p_0ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27608 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][5]];
27609 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27610 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][6]];
27611 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27612 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][7]];
27613 p_2ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27614 face1 = facesMCtoSOLVER[tiling5STL[subCaseDummy][8]];
27615 face2 = facesMCtoSOLVER[tiling5STL[subCaseDummy][9]];
27616 face3 = facesMCtoSOLVER[tiling5STL[subCaseDummy][10]];
27617 face4 = facesMCtoSOLVER[tiling5STL[subCaseDummy][11]];
27618 face5 = facesMCtoSOLVER[tiling5STL[subCaseDummy][12]];
27620 computePoly5(p_0, p_0ss, p_2ss, p_2, p_1, &faceVolume[face1], faceCentroid[face1], normal[face1]);
27621 computeTri(p_0ss, p_0, p_0s, &faceVolume[face2], faceCentroid[face2], normal[face2]);
27622 computeTrapez(p_0, p_1, p_1s, p_0s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
27623 computeTrapez(p_1, p_1s, p_2s, p_2, &faceVolume[face4], faceCentroid[face4], normal[face4]);
27624 computeTri(p_2s, p_2, p_2ss, &faceVolume[face5], faceCentroid[face5], normal[face5]);
27626 computePoly5(p_0s, p_1s, p_2s, p_2ss, p_0ss, &area_c, coordinates_c, normalVec_c);
27628 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_0s, p_1s, p_2s, p_0ss, p_2ss);
27630 for(
MInt i = 0; i < 5; i++) {
27631 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
27632 &pyraVolume[i], pyraCentroid[i]);
27634 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[5], pyraCentroid[5]);
27635 for(
MInt i = 0; i < 6; i++) {
27636 volume_C += pyraVolume[i];
27637 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
27639 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
27641 faceCut[face1] =
true;
27642 faceCut[face2] =
true;
27643 faceCut[face3] =
true;
27644 faceCut[face4] =
true;
27645 faceCut[face5] =
true;
27648 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
27649 for(
MInt dim = 0; dim < 3; dim++) {
27650 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
27651 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
27654 m_bndryCells->a[bndryId].m_volume = volume_C;
27656 for(
MInt dim = 0; dim < 3; dim++) {
27657 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
27658 coordinates_Cell[dim] = m_solver->a_coordinate(cellId, dim);
27662 subCaseDummy = tiling12_1STL[23 - currentSubCase][1];
27663 for(
MInt face = 0; face < 6; face++) {
27664 nfs_cur_0[face] = nfs1[subCaseDummy][face];
27666 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
27667 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
27668 p_1 = m_bndryCells->a[bndryId2].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27669 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
27670 p_2 = m_bndryCells->a[bndryId2].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27671 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
27672 p_3 = m_bndryCells->a[bndryId2].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27673 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
27674 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
27675 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
27677 faceCut_0[face1] =
true;
27678 faceCut_0[face2] =
true;
27679 faceCut_0[face3] =
true;
27681 computeTri(p_0, p_1, p_3, &faceVolume_0[face1], faceCentroid_0[face1]);
27682 computeTri(p_0, p_3, p_2, &faceVolume_0[face2], faceCentroid_0[face2]);
27683 computeTri(p_0, p_2, p_1, &faceVolume_0[face3], faceCentroid_0[face3]);
27685 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
27687 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
27689 m_bndryCells->a[bndryId2].m_volume = volume_C;
27690 for(
MInt dim = 0; dim < 3; dim++) {
27691 m_bndryCells->a[bndryId2].m_coordinates[dim] = coordinates_Cell[dim];
27695 m_bndryCells->a[bndryId2].m_srfcs[0]->m_area = area_c;
27696 for(
MInt dim = 0; dim < 3; dim++) {
27697 m_bndryCells->a[bndryId2].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
27698 m_bndryCells->a[bndryId2].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
27702 cornerCellMapping[ambIds[bndryId] * 8 + cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]] = cellId2;
27704 }
else if(disambiguation[bndryId] == 0) {
27707 m_bndryCells->a[bndryId].m_noSrfcs = 2;
27708 for(
MInt face = 0; face < 6; face++) {
27709 nfs_cur[face] = nfs12_1[currentSubCase][face];
27713 subCaseDummy = tiling12_1STL[currentSubCase][0];
27715 p_0 = corner[cornersMCtoSOLVER[tiling5STL[subCaseDummy][0]]];
27716 p_1 = corner[cornersMCtoSOLVER[tiling5STL[subCaseDummy][1]]];
27717 p_2 = corner[cornersMCtoSOLVER[tiling5STL[subCaseDummy][2]]];
27718 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][3]];
27719 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27720 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][4]];
27721 p_0ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27722 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][5]];
27723 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27724 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][6]];
27725 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27726 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][7]];
27727 p_2ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27728 face1 = facesMCtoSOLVER[tiling5STL[subCaseDummy][8]];
27729 face2 = facesMCtoSOLVER[tiling5STL[subCaseDummy][9]];
27730 face3 = facesMCtoSOLVER[tiling5STL[subCaseDummy][10]];
27731 face4 = facesMCtoSOLVER[tiling5STL[subCaseDummy][11]];
27732 face5 = facesMCtoSOLVER[tiling5STL[subCaseDummy][12]];
27734 computePoly5(p_0, p_0ss, p_2ss, p_2, p_1, &faceVolume[face1], faceCentroid[face1], normal[face1]);
27735 computeTri(p_0ss, p_0, p_0s, &faceVolume[face2], faceCentroid[face2], normal[face2]);
27736 computeTrapez(p_0, p_1, p_1s, p_0s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
27737 computeTrapez(p_1, p_1s, p_2s, p_2, &faceVolume[face4], faceCentroid[face4], normal[face4]);
27738 computeTri(p_2s, p_2, p_2ss, &faceVolume[face5], faceCentroid[face5], normal[face5]);
27740 computePoly5(p_0s, p_1s, p_2s, p_2ss, p_0ss, &area_c, coordinates_c, normalVec_c);
27742 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_0s, p_1s, p_2s, p_0ss, p_2ss);
27744 for(
MInt i = 0; i < 5; i++) {
27745 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
27746 &pyraVolume[i], pyraCentroid[i]);
27748 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[5], pyraCentroid[5]);
27749 for(
MInt i = 0; i < 6; i++) {
27750 volume_C += pyraVolume[i];
27751 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
27753 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
27755 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
27756 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
27757 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
27758 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
27759 correctFace(&faceVolume[face5], faceCentroid[face5], &faceVolume_0[face5], faceCentroid_0[face5]);
27761 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
27763 correctNormal(normalVec_c);
27765 faceCut[face1] =
true;
27766 faceCut[face2] =
true;
27767 faceCut[face3] =
true;
27768 faceCut[face4] =
true;
27769 faceCut[face5] =
true;
27772 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
27773 for(
MInt dim = 0; dim < 3; dim++) {
27774 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
27775 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
27778 faceVolume_0[face1] = faceVolume[face1];
27779 faceVolume_0[face2] = faceVolume[face2];
27780 faceVolume_0[face3] = faceVolume[face3];
27781 faceVolume_0[face4] = faceVolume[face4];
27782 faceVolume_0[face5] = faceVolume[face5];
27783 cellVolume_0 = volume_C;
27785 for(
MInt i = 0; i < 3; i++) {
27786 cellCentroid_0[i] = coordinates_Cell[i];
27787 faceCentroid_0[face1][i] = faceCentroid[face1][i];
27788 faceCentroid_0[face2][i] = faceCentroid[face2][i];
27789 faceCentroid_0[face3][i] = faceCentroid[face3][i];
27790 faceCentroid_0[face4][i] = faceCentroid[face4][i];
27791 faceCentroid_0[face5][i] = faceCentroid[face5][i];
27792 coordinates_Cell[i] = 0;
27796 subCaseDummy = tiling12_1STL[currentSubCase][1];
27797 p_0 = corner[cornersMCtoSOLVER[tiling1STL[subCaseDummy][0]]];
27798 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
27799 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27800 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
27801 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27802 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
27803 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
27804 face1 = facesMCtoSOLVER[tiling1STL[subCaseDummy][4]];
27805 face2 = facesMCtoSOLVER[tiling1STL[subCaseDummy][5]];
27806 face3 = facesMCtoSOLVER[tiling1STL[subCaseDummy][6]];
27808 faceCut[face1] =
true;
27809 faceCut[face2] =
true;
27810 faceCut[face3] =
true;
27812 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
27813 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
27814 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
27816 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
27818 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
27820 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
27821 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
27822 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
27824 correctCell(&volume_C, coordinates_Cell, &cellVolume_0, cellCentroid_0);
27826 correctNormal(normalVec_c);
27829 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area_c;
27830 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
27831 for(
MInt dim = 0; dim < 3; dim++) {
27832 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = coordinates_c[dim];
27833 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normalVec_c[dim];
27836 m_bndryCells->a[bndryId].m_volume = volume_C;
27837 for(
MInt dim = 0; dim < 3; dim++) {
27838 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
27844 mTerm(1, AT_,
"Unknown case probably in disamb_tmp");
27848 for(
MInt i = 0; i < nDim; i++) {
27849 m_bndryCells->a[bndryId].m_coordinates[i] -= m_solver->a_coordinate(cellId, i);
27851 if(splitCell[bndryId]) {
27852 for(
MInt i = 0; i < nDim; i++) {
27853 m_bndryCells->a[bndryId2].m_coordinates[i] -= m_solver->a_coordinate(cellId2, i);
27856 if(currentCase == 7 && disamb_tmp == 7) {
27857 for(
MInt i = 0; i < nDim; i++) {
27858 m_bndryCells->a[bndryId3].m_coordinates[i] -= m_solver->a_coordinate(cellId3, i);
27864 if(!splitFace[bndryId]) {
27865 for(
MInt face = 0; face < 6; face++) {
27866 m_bndryCells->a[bndryId].m_associatedSrfc[face] = -1;
27867 if(!faceCut[face])
continue;
27869 spaceId = face / 2;
27870 if(nfs_cur[face]) {
27871 if(m_solver->a_hasNeighbor(cellId, face) > 0)
27872 nghbrId = m_solver->c_neighborId(cellId, face);
27874 if(m_solver->c_parentId(cellId) > -1) {
27875 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId), face) > 0)
27876 nghbrId = m_solver->c_neighborId(m_solver->c_parentId(cellId), face);
27882 if(m_solver->c_noChildren(nghbrId) > 0)
continue;
27883 otherSideId = (sideId + 1) % 2;
27884 srfcId = m_solver->a_noSurfaces();
27885 m_surfaces.append();
27886 m_solver->a_surfaceOrientation(srfcId) = spaceId;
27887 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
27888 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) = cellId;
27889 for(
MInt dim = 0; dim < nDim; dim++) {
27890 m_solver->a_surfaceCoordinate(srfcId, dim) = faceCentroid[face][dim];
27892 m_solver->a_surfaceArea(srfcId) = faceVolume[face];
27893 m_bndryCells->a[bndryId].m_associatedSrfc[face] = srfcId;
27895 stringstream errorMessage;
27896 errorMessage <<
"Error in FvBndryCnd3D::createCutFaceMGC - 1. Problem with face " << face << endl;
27897 errorMessage <<
"bndryId: " << bndryId << endl;
27898 errorMessage <<
"cellId: " << cellId << endl;
27899 errorMessage <<
"bndryCnd: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
27900 errorMessage <<
"case, subcase: " << currentCase <<
", " << currentSubCase << endl;
27901 errorMessage <<
"disamb: " << disambiguation[bndryId] << endl;
27902 errorMessage <<
"face Volumes: " << faceVolume[0] <<
", " << faceVolume[1] <<
", " << faceVolume[2] <<
", "
27903 << faceVolume[3] <<
", " << faceVolume[4] <<
", " << faceVolume[5] << endl;
27904 errorMessage <<
"faceCentroids: ";
27905 for(
MInt i = 0; i < 6; i++) {
27906 errorMessage << faceCentroid[i][0] <<
", " << faceCentroid[i][1] <<
", " << faceCentroid[i][2] <<
"; "
27909 errorMessage <<
"area_c = " << area_c << endl;
27910 errorMessage <<
"normalVec_c = " << normalVec_c[0] <<
", " << normalVec_c[1] <<
", " << normalVec_c[2]
27912 errorMessage <<
"coordinates_c = " << coordinates_c[0] <<
", " << coordinates_c[1] <<
", "
27913 << coordinates_c[2] << endl;
27914 errorMessage <<
"coordinates_Cell = " << coordinates_Cell[0] <<
", " << coordinates_Cell[1] <<
", "
27915 << coordinates_Cell[2] << endl;
27916 errorMessage <<
"volume_C = " << volume_C << endl;
27917 mTerm(1, AT_, errorMessage.str());
27921 if(splitFace[bndryId]) {
27922 for(
MInt face = 0; face < 6; face++) {
27923 m_bndryCells->a[bndryId].m_associatedSrfc[face] = -1;
27924 if(!faceCut[face])
continue;
27926 spaceId = face / 2;
27927 if(nfs_cur[face]) {
27928 if(m_solver->a_hasNeighbor(cellId, face) > 0)
27929 nghbrId = m_solver->c_neighborId(cellId, face);
27931 if(m_solver->c_parentId(cellId) > -1) {
27932 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId), face) > 0)
27933 nghbrId = m_solver->c_neighborId(m_solver->c_parentId(cellId), face);
27939 if(m_solver->c_noChildren(nghbrId) > 0)
continue;
27940 otherSideId = (sideId + 1) % 2;
27941 if(face == splitFaceId) {
27943 srfcId = m_solver->a_noSurfaces();
27944 m_surfaces.append();
27945 m_solver->a_surfaceOrientation(srfcId) = spaceId;
27946 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
27947 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) = cellId;
27948 for(
MInt dim = 0; dim < nDim; dim++) {
27949 m_solver->a_surfaceCoordinate(srfcId, dim) = splitFaceCentroid[0][dim];
27951 m_solver->a_surfaceArea(srfcId) = splitFaceVolume[0];
27952 m_splitSurfaces[splitSurfaceIndexCounter * 6] = srfcId;
27953 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 1] = splitCorner1;
27954 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 2] = splitCorner1 + neighborCorner[face];
27956 srfcId = m_solver->a_noSurfaces();
27957 m_surfaces.append();
27958 m_solver->a_surfaceOrientation(srfcId) = spaceId;
27959 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
27960 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) = cellId;
27961 for(
MInt dim = 0; dim < nDim; dim++) {
27962 m_solver->a_surfaceCoordinate(srfcId, dim) = splitFaceCentroid[1][dim];
27964 m_solver->a_surfaceArea(srfcId) = splitFaceVolume[1];
27965 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 3] = srfcId;
27966 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 3 + 1] = splitCorner2;
27967 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 3 + 2] = splitCorner2 + neighborCorner[face];
27969 m_bndryCells->a[bndryId].m_associatedSrfc[face] = -splitSurfaceIndexCounter;
27970 splitSurfaceIndexCounter++;
27972 srfcId = m_solver->a_noSurfaces();
27973 m_surfaces.append();
27974 m_solver->a_surfaceOrientation(srfcId) = spaceId;
27975 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
27976 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) = cellId;
27977 for(
MInt dim = 0; dim < nDim; dim++) {
27978 m_solver->a_surfaceCoordinate(srfcId, dim) = faceCentroid[face][dim];
27980 m_solver->a_surfaceArea(srfcId) = faceVolume[face];
27981 m_bndryCells->a[bndryId].m_associatedSrfc[face] = srfcId;
27984 stringstream errorMessage;
27985 errorMessage <<
"Error in FvBndryCnd3D::createCutFaceMGC - 2. Problem with face " << face << endl;
27986 errorMessage <<
"bndryId: " << bndryId << endl;
27987 errorMessage <<
"cellId: " << cellId << endl;
27988 errorMessage <<
"bndryCnd: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
27989 errorMessage <<
"case, subcase: " << currentCase <<
", " << currentSubCase << endl;
27990 errorMessage <<
"disamb: " << disambiguation[bndryId] << endl;
27991 errorMessage <<
"face Volumes: " << faceVolume[0] <<
", " << faceVolume[1] <<
", " << faceVolume[2] <<
", "
27992 << faceVolume[3] <<
", " << faceVolume[4] <<
", " << faceVolume[5] << endl;
27993 errorMessage <<
"faceCentroids: ";
27994 for(
MInt i = 0; i < 6; i++) {
27995 errorMessage << faceCentroid[i][0] <<
", " << faceCentroid[i][1] <<
", " << faceCentroid[i][2] <<
"; "
27998 errorMessage <<
"area_c = " << area_c << endl;
27999 errorMessage <<
"normalVec_c = " << normalVec_c[0] <<
", " << normalVec_c[1] <<
", " << normalVec_c[2]
28001 errorMessage <<
"coordinates_c = " << coordinates_c[0] <<
", " << coordinates_c[1] <<
", "
28002 << coordinates_c[2] << endl;
28003 errorMessage <<
"coordinates_Cell = " << coordinates_Cell[0] <<
", " << coordinates_Cell[1] <<
", "
28004 << coordinates_Cell[2] << endl;
28005 errorMessage <<
"volume_C = " << volume_C << endl;
28006 mTerm(1, AT_, errorMessage.str());
28010 if(currentCase == 7 && currentSubCase >= 8
28011 && (disamb_tmp == 1 || disamb_tmp == 2
28012 || disamb_tmp == 4)) {
28014 for(
MInt face = 0; face < 6; face++) {
28015 if(face != splitFaceId2)
continue;
28016 if(!faceCut[face])
continue;
28018 spaceId = face / 2;
28019 if(nfs_cur[face]) {
28020 if(m_solver->a_hasNeighbor(cellId, face) > 0)
28021 nghbrId = m_solver->c_neighborId(cellId, face);
28023 if(m_solver->c_parentId(cellId) > -1) {
28024 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId), face) > 0)
28025 nghbrId = m_solver->c_neighborId(m_solver->c_parentId(cellId), face);
28031 if(m_solver->c_noChildren(nghbrId) > 0)
continue;
28032 otherSideId = (sideId + 1) % 2;
28034 srfcId = m_solver->a_noSurfaces();
28035 m_surfaces.append();
28036 m_solver->a_surfaceOrientation(srfcId) = spaceId;
28037 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
28038 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) = cellId;
28039 for(
MInt dim = 0; dim < nDim; dim++) {
28040 m_solver->a_surfaceCoordinate(srfcId, dim) = splitFaceCentroid2[0][dim];
28042 m_solver->a_surfaceArea(srfcId) = splitFaceVolume2[0];
28043 m_splitSurfaces[splitSurfaceIndexCounter * 6] = srfcId;
28044 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 1] = splitCorner12;
28045 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 2] = splitCorner12 + neighborCorner[face];
28047 srfcId = m_solver->a_noSurfaces();
28048 m_surfaces.append();
28049 m_solver->a_surfaceOrientation(srfcId) = spaceId;
28050 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
28051 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) = cellId;
28052 for(
MInt dim = 0; dim < nDim; dim++) {
28053 m_solver->a_surfaceCoordinate(srfcId, dim) = splitFaceCentroid2[1][dim];
28055 m_solver->a_surfaceArea(srfcId) = splitFaceVolume2[1];
28056 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 3] = srfcId;
28057 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 3 + 1] = splitCorner22;
28058 m_splitSurfaces[splitSurfaceIndexCounter * 6 + 3 + 2] = splitCorner22 + neighborCorner[face];
28060 m_bndryCells->a[bndryId].m_associatedSrfc[face] = -splitSurfaceIndexCounter;
28061 splitSurfaceIndexCounter++;
28063 stringstream errorMessage;
28064 errorMessage <<
"Error in FvBndryCnd3D::createCutFaceMGC - 3. Problem with face " << face << endl;
28065 errorMessage <<
"bndryId: " << bndryId << endl;
28066 errorMessage <<
"cellId: " << cellId << endl;
28067 errorMessage <<
"bndryCnd: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
28068 errorMessage <<
"case, subcase: " << currentCase <<
", " << currentSubCase << endl;
28069 errorMessage <<
"disamb: " << disambiguation[bndryId] << endl;
28070 errorMessage <<
"face Volumes: " << faceVolume[0] <<
", " << faceVolume[1] <<
", " << faceVolume[2] <<
", "
28071 << faceVolume[3] <<
", " << faceVolume[4] <<
", " << faceVolume[5] << endl;
28072 errorMessage <<
"faceCentroids: ";
28073 for(
MInt i = 0; i < 6; i++) {
28074 errorMessage << faceCentroid[i][0] <<
", " << faceCentroid[i][1] <<
", " << faceCentroid[i][2] <<
"; "
28077 errorMessage <<
"area_c = " << area_c << endl;
28078 errorMessage <<
"normalVec_c = " << normalVec_c[0] <<
", " << normalVec_c[1] <<
", " << normalVec_c[2]
28080 errorMessage <<
"coordinates_c = " << coordinates_c[0] <<
", " << coordinates_c[1] <<
", "
28081 << coordinates_c[2] << endl;
28082 errorMessage <<
"coordinates_Cell = " << coordinates_Cell[0] <<
", " << coordinates_Cell[1] <<
", "
28083 << coordinates_Cell[2] << endl;
28084 errorMessage <<
"volume_C = " << volume_C << endl;
28085 mTerm(1, AT_, errorMessage.str());
28089 if(splitCell[bndryId]) {
28090 for(
MInt face = 0; face < 6; face++) {
28091 m_bndryCells->a[bndryId2].m_associatedSrfc[face] = -1;
28092 if(!faceCut_0[face])
continue;
28094 spaceId = face / 2;
28095 if(nfs_cur_0[face]) {
28097 MInt splitChildId = cellId2;
28098 if(m_solver->a_hasProperty(cellId2, SolverCell::IsSplitClone))
28099 cellId2 = m_solver->m_splitChildToSplitCell.find(cellId2)->second;
28100 if(m_solver->a_hasNeighbor(cellId2, face) > 0)
28101 nghbrId = m_solver->c_neighborId(cellId2, face);
28103 if(m_solver->c_parentId(cellId2) > -1) {
28104 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId2), face) > 0)
28105 nghbrId = m_solver->c_neighborId(m_solver->c_parentId(cellId2), face);
28111 cellId2 = splitChildId;
28112 if(m_solver->c_noChildren(nghbrId) > 0)
continue;
28113 otherSideId = (sideId + 1) % 2;
28114 srfcId = m_solver->a_noSurfaces();
28115 m_surfaces.append();
28116 m_solver->a_surfaceOrientation(srfcId) = spaceId;
28117 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
28118 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) = cellId2;
28119 for(
MInt dim = 0; dim < nDim; dim++) {
28120 m_solver->a_surfaceCoordinate(srfcId, dim) = faceCentroid_0[face][dim];
28122 m_solver->a_surfaceArea(srfcId) = faceVolume_0[face];
28123 m_bndryCells->a[bndryId2].m_associatedSrfc[face] = srfcId;
28125 stringstream errorMessage;
28126 errorMessage <<
"Error in FvBndryCnd3D::createCutFaceMGC - 4. Problem with face " << face << endl;
28127 errorMessage <<
"bndryId: " << bndryId2 << endl;
28128 errorMessage <<
"cellId: " << cellId2 << endl;
28129 errorMessage <<
"split cell! Twin: " << bndryId << endl;
28130 errorMessage <<
"bndryCnd: " << m_bndryCells->a[bndryId2].m_srfcs[0]->m_bndryCndId;
28131 errorMessage <<
"case, subcase: " << currentCase <<
", " << currentSubCase << endl;
28132 errorMessage <<
"disamb: " << disambiguation[bndryId] << endl;
28133 errorMessage <<
"face Volumes: " << faceVolume_0[0] <<
", " << faceVolume_0[1] <<
", " << faceVolume_0[2]
28134 <<
", " << faceVolume_0[3] <<
", " << faceVolume_0[4] <<
", " << faceVolume_0[5] << endl;
28135 errorMessage <<
"faceCentroids: ";
28136 for(
MInt i = 0; i < 6; i++) {
28137 errorMessage << faceCentroid_0[i][0] <<
", " << faceCentroid_0[i][1] <<
", " << faceCentroid_0[i][2]
28140 errorMessage <<
"area_c = " << area_c << endl;
28141 errorMessage <<
"normalVec_c = " << normalVec_c[0] <<
", " << normalVec_c[1] <<
", " << normalVec_c[2]
28143 errorMessage <<
"coordinates_c = " << coordinates_c[0] <<
", " << coordinates_c[1] <<
", "
28144 << coordinates_c[2] << endl;
28145 errorMessage <<
"coordinates_Cell = " << coordinates_Cell[0] <<
", " << coordinates_Cell[1] <<
", "
28146 << coordinates_Cell[2] << endl;
28147 errorMessage <<
"volume_C = " << volume_C << endl;
28148 mTerm(1, AT_, errorMessage.str());
28153 if(currentCase == 7 && disamb_tmp == 7) {
28154 for(
MInt face = 0; face < 6; face++) {
28155 m_bndryCells->a[bndryId3].m_associatedSrfc[face] = -1;
28156 if(!faceCut_00[face])
continue;
28158 spaceId = face / 2;
28159 if(nfs_cur_00[face]) {
28161 MInt splitChildId = cellId3;
28162 if(m_solver->a_hasProperty(cellId3, SolverCell::IsSplitClone))
28163 cellId3 = m_solver->m_splitChildToSplitCell.find(cellId3)->second;
28164 if(m_solver->a_hasNeighbor(cellId3, face) > 0)
28165 nghbrId = m_solver->c_neighborId(cellId3, face);
28167 if(m_solver->c_parentId(cellId3) > -1) {
28168 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId3), face) > 0)
28169 nghbrId = m_solver->c_neighborId(m_solver->c_parentId(cellId3), face);
28175 cellId3 = splitChildId;
28176 if(m_solver->c_noChildren(nghbrId) > 0)
continue;
28177 otherSideId = (sideId + 1) % 2;
28178 srfcId = m_solver->a_noSurfaces();
28179 m_surfaces.append();
28180 m_solver->a_surfaceOrientation(srfcId) = spaceId;
28181 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
28182 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) = cellId3;
28183 for(
MInt dim = 0; dim < nDim; dim++) {
28184 m_solver->a_surfaceCoordinate(srfcId, dim) = faceCentroid_00[face][dim];
28186 m_solver->a_surfaceArea(srfcId) = faceVolume_00[face];
28187 m_bndryCells->a[bndryId3].m_associatedSrfc[face] = srfcId;
28189 stringstream errorMessage;
28190 errorMessage <<
"Error in FvBndryCnd3D::createCutFaceMGC - 5. Problem with face " << face << endl;
28191 errorMessage <<
"bndryId: " << bndryId3 << endl;
28192 errorMessage <<
"cellId: " << cellId3 << endl;
28193 errorMessage <<
"split cell! Twin (triple): " << bndryId << endl;
28194 errorMessage <<
"bndryCnd: " << m_bndryCells->a[bndryId3].m_srfcs[0]->m_bndryCndId;
28195 errorMessage <<
"case, subcase: " << currentCase <<
", " << currentSubCase << endl;
28196 errorMessage <<
"disamb: " << disambiguation[bndryId] << endl;
28197 errorMessage <<
"face Volumes: " << faceVolume_00[0] <<
", " << faceVolume_00[1] <<
", " << faceVolume_00[2]
28198 <<
", " << faceVolume_00[3] <<
", " << faceVolume_00[4] <<
", " << faceVolume_00[5] << endl;
28199 errorMessage <<
"faceCentroids: ";
28200 for(
MInt i = 0; i < 6; i++) {
28201 errorMessage << faceCentroid_00[i][0] <<
", " << faceCentroid_00[i][1] <<
", " << faceCentroid_00[i][2]
28204 errorMessage <<
"area_c = " << area_c << endl;
28205 errorMessage <<
"normalVec_c = " << normalVec_c[0] <<
", " << normalVec_c[1] <<
", " << normalVec_c[2]
28207 errorMessage <<
"coordinates_c = " << coordinates_c[0] <<
", " << coordinates_c[1] <<
", "
28208 << coordinates_c[2] << endl;
28209 errorMessage <<
"coordinates_Cell = " << coordinates_Cell[0] <<
", " << coordinates_Cell[1] <<
", "
28210 << coordinates_Cell[2] << endl;
28211 mTerm(1, AT_, errorMessage.str());
28216 for(
MInt face = 0; face < 6; face++) {
28217 if(!nfs_cur[face]) {
28218 m_bndryCells->a[bndryId].m_externalFaces[face] =
true;
28221 if(splitCell[bndryId]) {
28222 for(
MInt face = 0; face < 6; face++) {
28223 if(!nfs_cur_0[face]) {
28224 m_bndryCells->a[bndryId2].m_externalFaces[face] =
true;
28228 if(currentCase == 7 && disamb_tmp == 7) {
28229 for(
MInt face = 0; face < 6; face++) {
28230 if(!nfs_cur_00[face]) {
28231 m_bndryCells->a[bndryId3].m_externalFaces[face] =
true;
28236 m_bndryCells->a[bndryId].m_noSrfcs = 1;
28237 stringstream fileName;
28238 switch(currentCase) {
28240 cerr <<
"FvBndryCnd3D::createCutFaceMGC - Error: Cell is not a boundary cell!" << endl;
28241 cerr <<
"CellId: " << cellId <<
" BndryId: " << bndryId << endl;
28242 cerr <<
"Cell level: " << m_solver->a_level(cellId) << endl;
28243 fileName << cellId <<
".stl";
28244 writeStlFileOfCell(cellId, (fileName.str()).c_str());
28245 cerr <<
"Wrote stl-file of cell. FileName: " << (fileName.str()) << endl;
28249 for(
MInt face = 0; face < 6; face++) {
28250 nfs_cur[face] = nfs1[currentSubCase][face];
28252 p_0 = corner[cornersMCtoSOLVER[tiling1STL[currentSubCase][0]]];
28254 if(currentSubCase < 8) {
28256 for(
MInt i = 0; i < 6; i++) {
28257 faceVolume_0[i] = faceVolume[i];
28258 for(
MInt j = 0; j < 3; j++) {
28259 faceCentroid_0[i][j] = faceCentroid[i][j];
28263 cutDummy = edgesMCtoSOLVER[tiling1STL[currentSubCase][1]];
28264 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28265 cutDummy = edgesMCtoSOLVER[tiling1STL[currentSubCase][2]];
28266 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28267 cutDummy = edgesMCtoSOLVER[tiling1STL[currentSubCase][3]];
28268 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28269 face1 = facesMCtoSOLVER[tiling1STL[currentSubCase][4]];
28270 face2 = facesMCtoSOLVER[tiling1STL[currentSubCase][5]];
28271 face3 = facesMCtoSOLVER[tiling1STL[currentSubCase][6]];
28273 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1]);
28274 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2]);
28275 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3]);
28277 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
28279 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
28281 if(currentSubCase >= 8) {
28282 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
28283 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
28284 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
28286 correctCell(&volume_C, coordinates_Cell, &gridCellVolume, &m_solver->a_coordinate(cellId, 0));
28288 correctNormal(normalVec_c);
28291 m_bndryCells->a[bndryId].m_volume = volume_C;
28293 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
28294 for(
MInt dim = 0; dim < 3; dim++) {
28295 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
28296 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
28297 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
28302 for(
MInt face = 0; face < 6; face++) {
28303 nfs_cur[face] = nfs2[currentSubCase][face];
28306 p_0 = corner[cornersMCtoSOLVER[tiling2STL[currentSubCase][0]]];
28307 p_0s = corner[cornersMCtoSOLVER[tiling2STL[currentSubCase][1]]];
28308 if(currentSubCase < 12) {
28310 for(
MInt i = 0; i < 6; i++) {
28311 faceVolume_0[i] = faceVolume[i];
28312 for(
MInt j = 0; j < 3; j++) {
28313 faceCentroid_0[i][j] = faceCentroid[i][j];
28318 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][2]];
28319 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28320 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][3]];
28321 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28322 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][4]];
28323 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28324 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][5]];
28325 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28326 face1 = facesMCtoSOLVER[tiling2STL[currentSubCase][6]];
28327 face2 = facesMCtoSOLVER[tiling2STL[currentSubCase][7]];
28328 face3 = facesMCtoSOLVER[tiling2STL[currentSubCase][8]];
28329 face4 = facesMCtoSOLVER[tiling2STL[currentSubCase][9]];
28331 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2], normal[face2]);
28332 computeTri(p_0s, p_3s, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
28333 computeTrapez(p_0, p_0s, p_3s, p_3, &faceVolume[face1], faceCentroid[face1], normal[face1]);
28334 computeTrapez(p_2, p_2s, p_0s, p_0, &faceVolume[face4], faceCentroid[face4], normal[face4]);
28336 computePoly4(p_3, p_3s, p_2s, p_2, &area_c, coordinates_c, normalVec_c);
28338 maia::math::vecAvg<3>(M, p_0, p_0s, p_2, p_2s, p_3, p_3s);
28340 for(
MInt i = 0; i < 4; i++) {
28341 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
28342 &pyraVolume[i], pyraCentroid[i]);
28344 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[4], pyraCentroid[4]);
28345 for(
MInt i = 0; i < 5; i++) {
28346 volume_C += pyraVolume[i];
28347 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
28349 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
28351 if(currentSubCase >= 12) {
28352 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
28353 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
28354 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
28355 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
28357 correctCell(&volume_C, coordinates_Cell, &gridCellVolume, &m_solver->a_coordinate(cellId, 0));
28359 correctNormal(normalVec_c);
28362 m_bndryCells->a[bndryId].m_volume = volume_C;
28364 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
28365 for(
MInt dim = 0; dim < 3; dim++) {
28366 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
28367 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
28368 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
28373 for(
MInt face = 0; face < 6; face++) {
28374 nfs_cur[face] = nfs5[currentSubCase][face];
28377 p_0 = corner[cornersMCtoSOLVER[tiling5STL[currentSubCase][0]]];
28378 p_1 = corner[cornersMCtoSOLVER[tiling5STL[currentSubCase][1]]];
28379 p_2 = corner[cornersMCtoSOLVER[tiling5STL[currentSubCase][2]]];
28380 if(currentSubCase < 24) {
28382 for(
MInt i = 0; i < 6; i++) {
28383 faceVolume_0[i] = faceVolume[i];
28384 for(
MInt j = 0; j < 3; j++) {
28385 faceCentroid_0[i][j] = faceCentroid[i][j];
28390 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][3]];
28391 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28392 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][4]];
28393 p_0ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28394 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][5]];
28395 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28396 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][6]];
28397 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28398 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][7]];
28399 p_2ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28400 face1 = facesMCtoSOLVER[tiling5STL[currentSubCase][8]];
28401 face2 = facesMCtoSOLVER[tiling5STL[currentSubCase][9]];
28402 face3 = facesMCtoSOLVER[tiling5STL[currentSubCase][10]];
28403 face4 = facesMCtoSOLVER[tiling5STL[currentSubCase][11]];
28404 face5 = facesMCtoSOLVER[tiling5STL[currentSubCase][12]];
28406 computePoly5(p_0, p_0ss, p_2ss, p_2, p_1, &faceVolume[face1], faceCentroid[face1], normal[face1]);
28407 computeTri(p_0ss, p_0, p_0s, &faceVolume[face2], faceCentroid[face2], normal[face2]);
28408 computeTrapez(p_0, p_1, p_1s, p_0s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
28409 computeTrapez(p_1, p_1s, p_2s, p_2, &faceVolume[face4], faceCentroid[face4], normal[face4]);
28410 computeTri(p_2s, p_2, p_2ss, &faceVolume[face5], faceCentroid[face5], normal[face5]);
28412 computePoly5(p_0s, p_1s, p_2s, p_2ss, p_0ss, &area_c, coordinates_c, normalVec_c);
28414 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_0s, p_1s, p_2s, p_0ss, p_2ss);
28416 for(
MInt i = 0; i < 5; i++) {
28417 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
28418 &pyraVolume[i], pyraCentroid[i]);
28420 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[5], pyraCentroid[5]);
28421 for(
MInt i = 0; i < 6; i++) {
28422 volume_C += pyraVolume[i];
28423 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
28425 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
28427 if(currentSubCase >= 24) {
28428 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
28429 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
28430 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
28431 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
28432 correctFace(&faceVolume[face5], faceCentroid[face5], &faceVolume_0[face5], faceCentroid_0[face5]);
28434 correctCell(&volume_C, coordinates_Cell, &gridCellVolume, &m_solver->a_coordinate(cellId, 0));
28436 correctNormal(normalVec_c);
28439 m_bndryCells->a[bndryId].m_volume = volume_C;
28441 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
28442 for(
MInt dim = 0; dim < 3; dim++) {
28443 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
28444 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
28445 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
28450 for(
MInt face = 0; face < 6; face++) {
28451 nfs_cur[face] = nfs8[currentSubCase][face];
28454 p_0 = corner[cornersMCtoSOLVER[tiling8STL[currentSubCase][0]]];
28455 p_1 = corner[cornersMCtoSOLVER[tiling8STL[currentSubCase][1]]];
28456 p_2 = corner[cornersMCtoSOLVER[tiling8STL[currentSubCase][2]]];
28457 p_3 = corner[cornersMCtoSOLVER[tiling8STL[currentSubCase][3]]];
28459 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][4]];
28460 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28461 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][5]];
28462 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28463 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][6]];
28464 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28465 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][7]];
28466 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28467 face5 = facesMCtoSOLVER[tiling8STL[currentSubCase][8]];
28468 face1 = facesMCtoSOLVER[tiling8STL[currentSubCase][9]];
28469 face2 = facesMCtoSOLVER[tiling8STL[currentSubCase][10]];
28470 face3 = facesMCtoSOLVER[tiling8STL[currentSubCase][11]];
28471 face4 = facesMCtoSOLVER[tiling8STL[currentSubCase][12]];
28473 computeTrapez(p_0, p_1, p_1s, p_0s, &faceVolume[face1], faceCentroid[face1], normal[face1]);
28474 computeTrapez(p_1, p_2, p_2s, p_1s, &faceVolume[face2], faceCentroid[face2], normal[face2]);
28475 computeTrapez(p_2, p_3, p_3s, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
28476 computeTrapez(p_3, p_0, p_0s, p_3s, &faceVolume[face4], faceCentroid[face4], normal[face4]);
28478 computeTrapez(p_0, p_3, p_2, p_1, &faceVolume[face5], faceCentroid[face5], normal[face5]);
28480 computePoly4(p_0s, p_1s, p_2s, p_3s, &area_c, coordinates_c, normalVec_c);
28482 maia::math::vecAvg<3>(M, p_0, p_0s, p_1, p_1s, p_2, p_2s, p_3, p_3s);
28484 for(
MInt i = 0; i < 5; i++) {
28485 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
28486 &pyraVolume[i], pyraCentroid[i]);
28488 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[5], pyraCentroid[5]);
28489 for(
MInt i = 0; i < 6; i++) {
28490 volume_C += pyraVolume[i];
28491 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
28493 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
28495 m_bndryCells->a[bndryId].m_volume = volume_C;
28497 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
28498 for(
MInt dim = 0; dim < 3; dim++) {
28499 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
28500 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
28501 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
28506 for(
MInt face = 0; face < 6; face++) {
28507 nfs_cur[face] = nfs9[currentSubCase][face];
28510 p_0 = corner[cornersMCtoSOLVER[tiling9STL[currentSubCase][0]]];
28511 p_1 = corner[cornersMCtoSOLVER[tiling9STL[currentSubCase][1]]];
28512 p_2 = corner[cornersMCtoSOLVER[tiling9STL[currentSubCase][2]]];
28513 p_3 = corner[cornersMCtoSOLVER[tiling9STL[currentSubCase][3]]];
28515 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][4]];
28516 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28517 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][5]];
28518 p_1ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28519 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][6]];
28520 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28521 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][7]];
28522 p_2ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28523 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][8]];
28524 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28525 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][9]];
28526 p_3ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28527 face1 = facesMCtoSOLVER[tiling9STL[currentSubCase][10]];
28528 face2 = facesMCtoSOLVER[tiling9STL[currentSubCase][11]];
28529 face3 = facesMCtoSOLVER[tiling9STL[currentSubCase][12]];
28530 face4 = facesMCtoSOLVER[tiling9STL[currentSubCase][13]];
28531 face5 = facesMCtoSOLVER[tiling9STL[currentSubCase][14]];
28532 face6 = facesMCtoSOLVER[tiling9STL[currentSubCase][15]];
28534 computePoly5(p_0, p_3, p_3ss, p_2s, p_2, &faceVolume[face1], faceCentroid[face1], normal[face1]);
28535 computePoly5(p_0, p_1, p_1ss, p_3s, p_3, &faceVolume[face3], faceCentroid[face3], normal[face3]);
28536 computePoly5(p_0, p_2, p_2ss, p_1s, p_1, &faceVolume[face5], faceCentroid[face5], normal[face5]);
28537 computeTri(p_1, p_1s, p_1ss, &faceVolume[face2], faceCentroid[face2], normal[face2]);
28538 computeTri(p_2, p_2s, p_2ss, &faceVolume[face4], faceCentroid[face4], normal[face4]);
28539 computeTri(p_3, p_3s, p_3ss, &faceVolume[face6], faceCentroid[face6], normal[face6]);
28541 computePoly6(p_1ss, p_1s, p_2ss, p_2s, p_3ss, p_3s, &area_c, coordinates_c, normalVec_c);
28543 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_3, p_1s, p_2s, p_3s, p_1ss, p_2ss, p_3ss);
28545 for(
MInt i = 0; i < 6; i++) {
28546 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
28547 &pyraVolume[i], pyraCentroid[i]);
28549 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[6], pyraCentroid[6]);
28550 for(
MInt i = 0; i < 7; i++) {
28551 volume_C += pyraVolume[i];
28552 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
28554 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
28556 m_bndryCells->a[bndryId].m_volume = volume_C;
28558 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
28559 for(
MInt dim = 0; dim < 3; dim++) {
28560 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
28561 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
28562 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
28569 for(
MInt face = 0; face < 6; face++) {
28570 nfs_cur[face] = nfs11[currentSubCase][face];
28573 p_0 = corner[cornersMCtoSOLVER[tiling11STL[currentSubCase][0]]];
28574 p_1 = corner[cornersMCtoSOLVER[tiling11STL[currentSubCase][1]]];
28575 p_2 = corner[cornersMCtoSOLVER[tiling11STL[currentSubCase][2]]];
28576 p_3 = corner[cornersMCtoSOLVER[tiling11STL[currentSubCase][3]]];
28578 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][4]];
28579 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28580 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][5]];
28581 p_0ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28582 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][6]];
28583 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28584 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][7]];
28585 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28586 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][8]];
28587 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28588 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][9]];
28589 p_3ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28590 face1 = facesMCtoSOLVER[tiling11STL[currentSubCase][10]];
28591 face2 = facesMCtoSOLVER[tiling11STL[currentSubCase][11]];
28592 face3 = facesMCtoSOLVER[tiling11STL[currentSubCase][12]];
28593 face4 = facesMCtoSOLVER[tiling11STL[currentSubCase][13]];
28594 face5 = facesMCtoSOLVER[tiling11STL[currentSubCase][14]];
28595 face6 = facesMCtoSOLVER[tiling11STL[currentSubCase][15]];
28597 computeTri(p_0, p_0s, p_0ss, &faceVolume[face1], faceCentroid[face1], normal[face1]);
28598 computePoly5(p_3s, p_3, p_2, p_1, p_1s, &faceVolume[face2], faceCentroid[face2], normal[face2]);
28599 computeTrapez(p_2, p_3, p_3ss, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
28600 computeTrapez(p_1, p_0, p_0ss, p_1s, &faceVolume[face4], faceCentroid[face4], normal[face4]);
28601 computePoly5(p_1, p_2, p_2s, p_0s, p_0, &faceVolume[face5], faceCentroid[face5], normal[face5]);
28602 computeTri(p_3, p_3s, p_3ss, &faceVolume[face6], faceCentroid[face6], normal[face6]);
28604 computePoly6(p_0ss, p_0s, p_2s, p_3ss, p_3s, p_1s, &area_c, coordinates_c, normalVec_c);
28606 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_3, p_0s, p_1s, p_2s, p_3s, p_0ss, p_3ss);
28608 for(
MInt i = 0; i < 6; i++) {
28609 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
28610 &pyraVolume[i], pyraCentroid[i]);
28612 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[6], pyraCentroid[6]);
28613 for(
MInt i = 0; i < 7; i++) {
28614 volume_C += pyraVolume[i];
28615 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
28617 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
28619 m_bndryCells->a[bndryId].m_volume = volume_C;
28621 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
28622 for(
MInt dim = 0; dim < 3; dim++) {
28623 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
28624 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
28625 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
28631 for(
MInt face = 0; face < 6; face++) {
28632 nfs_cur[face] = nfs14[currentSubCase][face];
28635 p_0 = corner[cornersMCtoSOLVER[tiling14STL[currentSubCase][0]]];
28636 p_1 = corner[cornersMCtoSOLVER[tiling14STL[currentSubCase][1]]];
28637 p_2 = corner[cornersMCtoSOLVER[tiling14STL[currentSubCase][2]]];
28638 p_3 = corner[cornersMCtoSOLVER[tiling14STL[currentSubCase][3]]];
28640 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][4]];
28641 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28642 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][5]];
28643 p_0ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28644 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][6]];
28645 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28646 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][7]];
28647 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28648 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][8]];
28649 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28650 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][9]];
28651 p_3ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
28652 face1 = facesMCtoSOLVER[tiling14STL[currentSubCase][10]];
28653 face2 = facesMCtoSOLVER[tiling14STL[currentSubCase][11]];
28654 face3 = facesMCtoSOLVER[tiling14STL[currentSubCase][12]];
28655 face4 = facesMCtoSOLVER[tiling14STL[currentSubCase][13]];
28656 face5 = facesMCtoSOLVER[tiling14STL[currentSubCase][14]];
28657 face6 = facesMCtoSOLVER[tiling14STL[currentSubCase][15]];
28659 computeTri(p_0, p_0s, p_0ss, &faceVolume[face1], faceCentroid[face1], normal[face1]);
28660 computePoly5(p_2, p_3, p_3ss, p_1s, p_1, &faceVolume[face2], faceCentroid[face2], normal[face2]);
28661 computeTrapez(p_2s, p_3s, p_3, p_2, &faceVolume[face3], faceCentroid[face3], normal[face3]);
28662 computeTrapez(p_1s, p_0s, p_0, p_1, &faceVolume[face4], faceCentroid[face4], normal[face4]);
28663 computePoly5(p_2, p_1, p_0, p_0ss, p_2s, &faceVolume[face5], faceCentroid[face5], normal[face5]);
28664 computeTri(p_3, p_3s, p_3ss, &faceVolume[face6], faceCentroid[face6], normal[face6]);
28666 computePoly6(p_0ss, p_0s, p_1s, p_3ss, p_3s, p_2s, &area_c, coordinates_c, normalVec_c);
28668 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_3, p_0s, p_1s, p_2s, p_3s, p_0ss, p_3ss);
28670 for(
MInt i = 0; i < 6; i++) {
28671 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
28672 &pyraVolume[i], pyraCentroid[i]);
28674 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[6], pyraCentroid[6]);
28675 for(
MInt i = 0; i < 7; i++) {
28676 volume_C += pyraVolume[i];
28677 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
28679 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
28681 m_bndryCells->a[bndryId].m_volume = volume_C;
28683 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
28684 for(
MInt dim = 0; dim < 3; dim++) {
28685 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
28686 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
28687 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
28693 stringstream errorMessage;
28694 errorMessage <<
"FvBndryCnd3D::createCutFaceMGC - Error: Inconsistent type implementation." << endl;
28695 mTerm(1, AT_, errorMessage.str());
28700 for(
MInt i = 0; i < nDim; i++) {
28702 if(!nfs_cur[2 * i + 1]) faceVolume[2 * i + 1] = 0;
28703 if(!nfs_cur[2 * i]) faceVolume[2 * i] = 0;
28705 m_bndryCells->a[bndryId].m_coordinates[i] -= m_solver->a_coordinate(cellId, i);
28707 faceDiff[i] = faceVolume[2 * i + 1] - faceVolume[2 * i];
28708 absA +=
POW2(faceDiff[i]);
28711 for(
MInt i = 0; i < nDim; i++) {
28712 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[i] = faceDiff[i] / sqrt(absA);
28714 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = sqrt(absA);
28718 for(
MInt face = 0; face < 6; face++) {
28719 m_bndryCells->a[bndryId].m_associatedSrfc[face] = -1;
28720 for(
MInt i = 0; i < noFaces; i++) {
28721 if(!(*facepointers[i] == face))
continue;
28723 spaceId = face / 2;
28724 if(nfs_cur[face]) {
28725 if(m_solver->a_hasNeighbor(cellId, face) > 0) {
28726 nghbrId = m_solver->c_neighborId(cellId, face);
28728 if(m_solver->c_parentId(cellId) > -1) {
28729 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId), face) > 0)
28730 nghbrId = m_solver->c_neighborId(m_solver->c_parentId(cellId), face);
28736 if(m_solver->c_noChildren(nghbrId) > 0)
continue;
28737 otherSideId = (sideId + 1) % 2;
28738 srfcId = m_solver->a_noSurfaces();
28739 m_surfaces.append();
28740 m_solver->a_surfaceOrientation(srfcId) = spaceId;
28741 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
28742 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) = cellId;
28743 for(
MInt dim = 0; dim < nDim; dim++) {
28744 m_solver->a_surfaceCoordinate(srfcId, dim) = faceCentroid[face][dim];
28746 m_solver->a_surfaceArea(srfcId) = faceVolume[face];
28747 m_bndryCells->a[bndryId].m_associatedSrfc[face] = srfcId;
28750 stringstream errorMessage;
28751 errorMessage <<
" Error in FvBndryCnd3D::createCutFaceMGC - 6. Problem with face " << face << endl;
28752 errorMessage <<
"bndryId: " << bndryId << endl;
28753 errorMessage <<
"cellId: " << cellId << endl;
28754 errorMessage <<
"bndryCnd: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
28755 errorMessage <<
"case, subcase: " << currentCase <<
", " << currentSubCase << endl;
28756 errorMessage <<
"face Volumes: " << faceVolume[0] <<
", " << faceVolume[1] <<
", " << faceVolume[2] <<
", "
28757 << faceVolume[3] <<
", " << faceVolume[4] <<
", " << faceVolume[5] << endl;
28758 errorMessage <<
"faceCentroids: ";
28759 for(
MInt j = 0; j < 6; j++) {
28760 errorMessage << faceCentroid[j][0] <<
", " << faceCentroid[j][1] <<
", " << faceCentroid[j][2] <<
"; "
28763 errorMessage <<
"area_c = " << area_c << endl;
28764 errorMessage <<
"normalVec_c = " << normalVec_c[0] <<
", " << normalVec_c[1] <<
", " << normalVec_c[2]
28766 errorMessage <<
"coordinates_c = " << coordinates_c[0] <<
", " << coordinates_c[1] <<
", "
28767 << coordinates_c[2] << endl;
28768 errorMessage <<
"coordinates_Cell = " << coordinates_Cell[0] <<
", " << coordinates_Cell[1] <<
", "
28769 << coordinates_Cell[2] << endl;
28770 errorMessage <<
"volume_C = " << volume_C << endl;
28771 mTerm(1, AT_, errorMessage.str());
28776 for(
MInt face = 0; face < 6; face++) {
28777 if(!nfs_cur[face]) {
28778 m_bndryCells->a[bndryId].m_externalFaces[face] =
true;
28786 for(
MInt bndryId = 0; bndryId < m_bndryCells->size(); bndryId++) {
28787 cellId = m_bndryCells->a[bndryId].m_cellId;
28788 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitClone)) {
28789 cellId = m_solver->m_splitChildToSplitCell.find(cellId)->second;
28790 m_solver->assertValidGridCellId(cellId);
28792 for(
MInt dirId = 0; dirId < m_noDirs; dirId++) {
28793 m_bndryNghbrs[bndryId * m_noDirs * 2 + dirId * 2] = -1;
28794 if(m_solver->a_hasNeighbor(cellId, dirId) > 0)
28795 m_bndryNghbrs[bndryId * m_noDirs * 2 + dirId * 2] = m_solver->c_neighborId(cellId, dirId);
28796 m_bndryNghbrs[bndryId * m_noDirs * 2 + dirId * 2 + 1] = -1;
28804 for(
MInt ambId = 0; ambId < noAmbiguousCells; ambId++) {
28805 MInt bndryId = ambiguousCells[ambId];
28806 cellId = m_bndryCells->a[bndryId].m_cellId;
28809 if(splitCell[bndryId] && !splitFace[bndryId]) {
28811 for(
MInt child = 0; child < 3; child++) {
28812 bndryId2 = m_splitChildren[bndryId * 3 + child];
28813 if(bndryId2 == -1)
break;
28814 cellId2 = m_bndryCells->a[bndryId2].m_cellId;
28817 for(
MInt corn = 0; corn < 8; corn++) {
28818 if(cornerCellMapping[ambId * 8 + corn] == cellId2) {
28819 for(
MInt f = 0; f < 3; f++) {
28820 faceTMP = cornerFaceMapping[corn * 3 + f];
28821 nghbrCellId = m_solver->c_neighborId(cellId2, faceTMP);
28822 nghbrBndryId = m_solver->a_bndryId(nghbrCellId);
28823 if(nghbrBndryId < 0)
mTerm(1, AT_,
"strange split cell neighbor");
28824 if(!splitCell[nghbrBndryId] && !splitFace[nghbrBndryId]) {
28828 srfcId = m_bndryCells->a[nghbrBndryId].m_associatedSrfc[opposite[faceTMP]];
28829 if(m_solver->a_surfaceNghbrCellId(srfcId, 0) == nghbrCellId) {
28830 m_solver->a_surfaceNghbrCellId(srfcId, 1) = cellId2;
28832 m_solver->a_surfaceNghbrCellId(srfcId, 0) = cellId2;
28835 if(splitCell[nghbrBndryId]) {
28839 srfcId = m_bndryCells->a[bndryId2].m_associatedSrfc[faceTMP];
28840 if(m_solver->a_surfaceNghbrCellId(srfcId, 0) == cellId2) {
28841 m_solver->a_surfaceNghbrCellId(srfcId, 1) = m_solver->c_neighborId(cellId2, faceTMP);
28843 m_solver->a_surfaceNghbrCellId(srfcId, 0) = m_solver->c_neighborId(cellId2, faceTMP);
28845 }
else if(splitFace[nghbrBndryId]) {
28863 for(
MInt corn = 0; corn < 8; corn++) {
28864 if(cornerCellMapping[ambId * 8 + corn] == cellId) {
28865 for(
MInt f = 0; f < 3; f++) {
28866 faceTMP = cornerFaceMapping[corn * 3 + f];
28867 nghbrCellId = m_solver->c_neighborId(cellId, faceTMP);
28868 nghbrBndryId = m_solver->a_bndryId(nghbrCellId);
28869 if(!splitCell[nghbrBndryId] && !splitFace[nghbrBndryId]) {
28874 if(splitCell[nghbrBndryId]) {
28878 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[faceTMP];
28879 if(m_solver->a_surfaceNghbrCellId(srfcId, 0) == cellId) {
28880 m_solver->a_surfaceNghbrCellId(srfcId, 1) = m_solver->c_neighborId(cellId, faceTMP);
28882 m_solver->a_surfaceNghbrCellId(srfcId, 0) = m_solver->c_neighborId(cellId, faceTMP);
28884 }
else if(splitFace[nghbrBndryId]) {
28903 if(!splitCell[bndryId] && splitFace[bndryId]) {
28904 for(
MInt face = 0; face < 6; face++) {
28905 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[face];
28910 nghbrCellId = m_solver->c_neighborId(cellId, face);
28911 nghbrBndryId = m_solver->a_bndryId(nghbrCellId);
28913 splitCorner1 = m_splitSurfaces[-srfcId * 6 + 1];
28914 splitCorner2 = m_splitSurfaces[-srfcId * 6 + 2];
28915 if(splitCell[nghbrBndryId]) {
28916 if(m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6], 0) == cellId)
28917 m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6], 1) =
28918 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
28920 m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6], 0) =
28921 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
28922 }
else if(splitFace[nghbrBndryId]) {
28926 stringstream errorMessage;
28927 errorMessage <<
" Error in FvBndryCnd3D::createCutFaceMGC::this should not happen! ";
28928 mTerm(1, AT_, errorMessage.str());
28932 splitCorner1 = m_splitSurfaces[-srfcId * 6 + 3 + 1];
28933 splitCorner2 = m_splitSurfaces[-srfcId * 6 + 3 + 2];
28934 if(splitCell[nghbrBndryId]) {
28935 if(m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6 + 3], 0) == cellId)
28936 m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6 + 3], 1) =
28937 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
28939 m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6 + 3], 0) =
28940 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
28941 }
else if(splitFace[nghbrBndryId]) {
28946 }
else if(srfcId >= 0) {
28948 nghbrCellId = m_solver->c_neighborId(cellId, face);
28949 nghbrBndryId = m_solver->a_bndryId(nghbrCellId);
28950 if(splitCell[nghbrBndryId]) {
28951 for(
MInt i = 0; i < 4; i++) {
28952 if(cornerCellMapping[ambIds[nghbrBndryId] * 8 + faceCornerMapping[face * 6 + i]] == -1) {
28958 if(m_solver->a_surfaceNghbrCellId(srfcId, 0) == cellId)
28959 m_solver->a_surfaceNghbrCellId(srfcId, 1) = m_solver->c_neighborId(cellId, face);
28961 m_solver->a_surfaceNghbrCellId(srfcId, 0) = m_solver->c_neighborId(cellId, face);
28965 }
else if(splitFace[nghbrBndryId]) {
28977 for(
MInt ambId = 0; ambId < noAmbiguousCells; ambId++) {
28978 MInt bndryId = ambiguousCells[ambId];
28979 cellId = m_bndryCells->a[bndryId].m_cellId;
28982 if(splitCell[bndryId] && !splitFace[bndryId]) {
28984 for(
MInt child = 0; child < 3; child++) {
28985 bndryId2 = m_splitChildren[bndryId * 3 + child];
28986 if(bndryId2 == -1)
break;
28987 cellId2 = m_bndryCells->a[bndryId2].m_cellId;
28988 MInt splitCellId = cellId2;
28989 for(
MInt corn = 0; corn < 8; corn++) {
28990 if(cornerCellMapping[ambId * 8 + corn] == cellId2) {
28991 for(
MInt f = 0; f < 3; f++) {
28992 faceTMP = cornerFaceMapping[corn * 3 + f];
28993 if(m_solver->a_hasProperty(cellId2, SolverCell::IsSplitClone)) {
28994 cellId2 = m_solver->m_splitChildToSplitCell.find(cellId2)->second;
28996 nghbrCellId = m_solver->c_neighborId(cellId2, faceTMP);
28997 if(!m_solver->a_hasNeighbor(cellId2, faceTMP) || nghbrCellId < 0)
continue;
28998 nghbrBndryId = m_solver->a_bndryId(nghbrCellId);
28999 if(!splitCell[nghbrBndryId] && !splitFace[nghbrBndryId]) {
29003 m_bndryNghbrs[nghbrBndryId * m_noDirs * 2 + opposite[faceTMP] * 2] = splitCellId;
29004 m_bndryNghbrs[bndryId2 * m_noDirs * 2 + faceTMP * 2] = nghbrCellId;
29005 srfcId = m_bndryCells->a[nghbrBndryId].m_associatedSrfc[opposite[faceTMP]];
29007 if(m_solver->a_surfaceNghbrCellId(srfcId, 0) == nghbrCellId) {
29008 m_solver->a_surfaceNghbrCellId(srfcId, 1) = splitCellId;
29010 m_solver->a_surfaceNghbrCellId(srfcId, 0) = splitCellId;
29013 cerr <<
"no surf found " << m_solver->a_isHalo(splitCellId) <<
" "
29014 << m_solver->a_isHalo(nghbrCellId) << endl;
29016 if(splitCell[nghbrBndryId]) {
29018 m_bndryNghbrs[bndryId2 * m_noDirs * 2 + faceTMP * 2] =
29019 cornerCellMapping[ambIds[nghbrBndryId] * 8 + corn + neighborCorner[faceTMP]];
29020 srfcId = m_bndryCells->a[bndryId2].m_associatedSrfc[faceTMP];
29022 if(m_solver->a_surfaceNghbrCellId(srfcId, 0) == splitCellId) {
29023 m_solver->a_surfaceNghbrCellId(srfcId, 1) =
29024 m_bndryNghbrs[bndryId2 * m_noDirs * 2 + faceTMP * 2];
29026 m_solver->a_surfaceNghbrCellId(srfcId, 0) =
29027 m_bndryNghbrs[bndryId2 * m_noDirs * 2 + faceTMP * 2];
29030 }
else if(splitFace[nghbrBndryId]) {
29033 m_bndryNghbrs[bndryId2 * m_noDirs * 2 + faceTMP * 2] = nghbrCellId;
29042 for(
MInt f = 0; f < m_noDirs; f++) {
29043 if(m_bndryCells->a[bndryId2].m_externalFaces[f]) m_bndryNghbrs[bndryId2 * m_noDirs * 2 + f * 2] = -1;
29048 for(
MInt corn = 0; corn < 8; corn++) {
29049 if(cornerCellMapping[ambId * 8 + corn] == cellId) {
29050 for(
MInt f = 0; f < 3; f++) {
29051 faceTMP = cornerFaceMapping[corn * 3 + f];
29052 nghbrCellId = m_solver->c_neighborId(cellId, faceTMP);
29053 nghbrBndryId = m_solver->a_bndryId(nghbrCellId);
29054 if(!splitCell[nghbrBndryId] && !splitFace[nghbrBndryId]) {
29059 m_bndryNghbrs[bndryId * m_noDirs * 2 + faceTMP * 2] = nghbrCellId;
29060 m_bndryNghbrs[nghbrBndryId * m_noDirs * 2 + opposite[faceTMP] * 2] = cellId;
29062 if(splitCell[nghbrBndryId]) {
29064 m_bndryNghbrs[bndryId * m_noDirs * 2 + faceTMP * 2] =
29065 cornerCellMapping[ambIds[nghbrBndryId] * 8 + corn + neighborCorner[faceTMP]];
29066 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[faceTMP];
29067 if(m_solver->a_surfaceNghbrCellId(srfcId, 0) == cellId) {
29068 m_solver->a_surfaceNghbrCellId(srfcId, 1) = m_bndryNghbrs[bndryId * m_noDirs * 2 + faceTMP * 2];
29070 m_solver->a_surfaceNghbrCellId(srfcId, 0) = m_bndryNghbrs[bndryId * m_noDirs * 2 + faceTMP * 2];
29072 }
else if(splitFace[nghbrBndryId]) {
29073 m_bndryNghbrs[bndryId * m_noDirs * 2 + faceTMP * 2] = nghbrCellId;
29083 for(
MInt f = 0; f < m_noDirs; f++) {
29084 if(m_bndryCells->a[bndryId].m_externalFaces[f]) m_bndryNghbrs[bndryId * m_noDirs * 2 + f * 2] = -1;
29090 if(!splitCell[bndryId] && splitFace[bndryId]) {
29091 for(
MInt face = 0; face < 6; face++) {
29092 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[face];
29097 nghbrCellId = m_solver->c_neighborId(cellId, face);
29098 nghbrBndryId = m_solver->a_bndryId(nghbrCellId);
29100 splitCorner1 = m_splitSurfaces[-srfcId * 6 + 1];
29101 splitCorner2 = m_splitSurfaces[-srfcId * 6 + 2];
29102 if(splitCell[nghbrBndryId]) {
29103 m_bndryNghbrs[bndryId * m_noDirs * 2 + face * 2] =
29104 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
29105 if(m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6], 0) == cellId)
29106 m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6], 1) =
29107 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
29109 m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6], 0) =
29110 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
29111 }
else if(splitFace[nghbrBndryId]) {
29113 m_bndryNghbrs[bndryId * m_noDirs * 2 + face * 2] = nghbrCellId;
29116 stringstream errorMessage;
29117 errorMessage <<
" Error in FvBndryCnd3D::createCutFaceMGC::this should not happen! ";
29118 mTerm(1, AT_, errorMessage.str());
29122 splitCorner1 = m_splitSurfaces[-srfcId * 6 + 3 + 1];
29123 splitCorner2 = m_splitSurfaces[-srfcId * 6 + 3 + 2];
29124 if(splitCell[nghbrBndryId]) {
29126 m_bndryNghbrs[bndryId * m_noDirs * 2 + face * 2 + 1] =
29127 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
29128 if(m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6 + 3], 0) == cellId)
29129 m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6 + 3], 1) =
29130 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
29132 m_solver->a_surfaceNghbrCellId(m_splitSurfaces[-srfcId * 6 + 3], 0) =
29133 cornerCellMapping[ambIds[nghbrBndryId] * 8 + splitCorner2];
29134 }
else if(splitFace[nghbrBndryId]) {
29136 m_bndryNghbrs[bndryId * m_noDirs * 2 + face * 2 + 1] = nghbrCellId;
29139 stringstream errorMessage;
29140 errorMessage <<
" Error in FvBndryCnd3D::createCutFaceMGC::this should not happen! ";
29141 mTerm(1, AT_, errorMessage.str());
29143 }
else if(srfcId >= 0) {
29145 nghbrCellId = m_solver->c_neighborId(cellId, face);
29146 nghbrBndryId = m_solver->a_bndryId(nghbrCellId);
29147 if(splitCell[nghbrBndryId]) {
29148 for(
MInt i = 0; i < 4; i++) {
29149 if(cornerCellMapping[ambIds[nghbrBndryId] * 8 + faceCornerMapping[face * 6 + i]] == -1) {
29153 m_bndryNghbrs[bndryId * m_noDirs * 2 + face * 2] =
29154 cornerCellMapping[ambIds[nghbrBndryId] * 8 + faceCornerMapping[face * 6 + i]];
29155 if(m_solver->a_surfaceNghbrCellId(srfcId, 0) == cellId)
29156 m_solver->a_surfaceNghbrCellId(srfcId, 1) = m_bndryNghbrs[bndryId * m_noDirs * 2 + face * 2];
29158 m_solver->a_surfaceNghbrCellId(srfcId, 0) = m_bndryNghbrs[bndryId * m_noDirs * 2 + face * 2];
29164 m_bndryNghbrs[bndryId * m_noDirs * 2 + face * 2] = nghbrCellId;
29173 for(
MInt bndryId = 0; bndryId < m_bndryCells->size(); bndryId++) {
29174 cellId = m_bndryCells->a[bndryId].m_cellId;
29175 for(
MInt f = 0; f < m_noDirs; f++) {
29176 if(m_bndryCells->a[bndryId].m_externalFaces[f]) {
29177 m_bndryNghbrs[bndryId * m_noDirs * 2 + f * 2] = -1;
29178 m_bndryNghbrs[bndryId * m_noDirs * 2 + f * 2 + 1] = -1;
29186 for(
MInt i = 0; i < 15; i++) {
29187 cerr <<
"Occurences case " << i <<
" : " << presentCases[i] <<
" times" << endl;
29189 cerr <<
"---------------------------------------------------------------" << endl << endl << endl;
29190 cerr <<
"Number Surfaces: " << m_solver->a_noSurfaces() << endl;
29204template <MInt nDim,
class SysEqn>
29205template <
class _, std::enable_if_t<nDim == 3, _*>>
29209 MInt bndryId2, cellId2, bndryId;
29211 MInt splitId = m_solver->m_splitCells.size();
29212 if(noSplitChilds > 1) {
29213 splitId = splitId - 1;
29214 m_solver->m_splitChilds[splitId].resize(noSplitChilds);
29216 m_solver->m_splitCells.push_back(cellId);
29217 m_solver->m_splitChilds.resize(m_solver->m_splitCells.size());
29218 m_solver->m_splitChilds[splitId].resize(noSplitChilds);
29221 bndryId = m_solver->a_bndryId(cellId);
29222 bndryId2 = m_bndryCells->size();
29223 cellId2 = m_solver->a_noCells();
29225 m_bndryCells->append();
29227 m_solver->m_totalnosplitchilds++;
29228 ASSERT(cellId2 == m_solver->a_noCells() - 1,
"Error in the cell-count, for splitchilds!");
29230 m_solver->m_splitChilds[splitId][noSplitChilds - 1] = cellId2;
29231 m_solver->m_splitChildToSplitCell.insert(pair<MInt, MInt>(cellId2, cellId));
29233 m_bndryCells->a[bndryId2].m_cellId = cellId2;
29234 m_solver->a_bndryId(cellId2) = bndryId2;
29235 m_solver->a_bndryId(cellId2) = bndryId2;
29237 for(
MInt face = 0; face < 6; face++) {
29238 m_bndryCells->a[bndryId2].m_associatedSrfc[face] = -1;
29239 m_bndryCells->a[bndryId2].m_externalFaces[face] =
false;
29242 m_bndryCells->a[bndryId2].m_srfcs[0]->m_bndryCndId = m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
29243 m_bndryCells->a[bndryId2].m_srfcs[0]->m_noCutPoints = m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
29245 for(
MInt i = 0; i < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; i++) {
29246 m_bndryCells->a[bndryId2].m_srfcs[0]->m_cutEdge[i] = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[i];
29247 m_bndryCells->a[bndryId2].m_srfcs[0]->m_bodyId[i] = m_bndryCells->a[bndryId].m_srfcs[0]->m_bodyId[i];
29248 for(
MInt j = 0; j < nDim; j++)
29249 m_bndryCells->a[bndryId2].m_srfcs[0]->m_cutCoordinates[i][j] =
29250 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[i][j];
29253 for(
MInt i = 0; i < nDim; i++) {
29254 m_solver->a_coordinate(cellId2, i) = m_solver->a_coordinate(cellId, i);
29256 m_solver->a_isInterface(cellId2) = m_solver->a_isInterface(cellId);
29258 m_solver->a_level(cellId2) = m_solver->a_level(cellId);
29260 m_solver->a_copyPropertiesSolver(cellId, cellId2);
29262 m_solver->a_hasProperty(cellId2, SolverCell::IsSplitCell) =
false;
29263 m_solver->a_hasProperty(cellId2, SolverCell::IsSplitChild) =
false;
29264 m_solver->a_hasProperty(cellId2, SolverCell::IsSplitClone) =
true;
29266 m_solver->a_hasProperty(cellId, SolverCell::IsSplitCell) =
false;
29267 m_solver->a_hasProperty(cellId, SolverCell::IsSplitChild) =
false;
29268 m_solver->a_hasProperty(cellId, SolverCell::IsSplitClone) =
false;
29284template <MInt nDim,
class SysEqn>
29285template <
class _, std::enable_if_t<nDim == 3, _*>>
29289 MInt spaceId, spaceId1, spaceId2, sideId;
29290 MFloat cellLength = m_solver->grid().cellLengthAtCell(cellId);
29291 MFloat point1[3] = {0, 0, 0};
29292 MFloat point2[3] = {0, 0, 0};
29293 MFloat point3[3] = {0, 0, 0};
29294 MFloat point4[3] = {0, 0, 0};
29296 ofl.open(fileName);
29300 ofl.setf(ios::fixed);
29303 ofl <<
"solid amazonas cell " <<
cellId << endl;
29304 for(
MInt dirId = 0; dirId < m_noDirs; dirId++) {
29305 spaceId = dirId / 2;
29306 sideId = dirId % 2;
29307 spaceId1 = (spaceId + 1) % nDim;
29308 spaceId2 = (spaceId1 + 1) % nDim;
29309 point1[spaceId] = m_solver->a_coordinate(cellId, spaceId) + ((
MFloat)sideId - F1B2) * cellLength;
29310 point2[spaceId] = point1[spaceId];
29311 point3[spaceId] = point1[spaceId];
29312 point4[spaceId] = point1[spaceId];
29313 point1[spaceId1] = m_solver->a_coordinate(cellId, spaceId1) - F1B2 * cellLength;
29314 point2[spaceId1] = m_solver->a_coordinate(cellId, spaceId1) - F1B2 * cellLength;
29315 point3[spaceId1] = m_solver->a_coordinate(cellId, spaceId1) + F1B2 * cellLength;
29316 point4[spaceId1] = m_solver->a_coordinate(cellId, spaceId1) + F1B2 * cellLength;
29317 point1[spaceId2] = m_solver->a_coordinate(cellId, spaceId2) - F1B2 * cellLength;
29318 point2[spaceId2] = m_solver->a_coordinate(cellId, spaceId2) + F1B2 * cellLength;
29319 point3[spaceId2] = m_solver->a_coordinate(cellId, spaceId2) - F1B2 * cellLength;
29320 point4[spaceId2] = m_solver->a_coordinate(cellId, spaceId2) + F1B2 * cellLength;
29321 if(dirId == 0) ofl <<
" facet normal -1.0 0.0 0.0 " << endl;
29322 if(dirId == 1) ofl <<
" facet normal 1.0 0.0 0.0 " << endl;
29323 if(dirId == 2) ofl <<
" facet normal 0.0 -1.0 0.0 " << endl;
29324 if(dirId == 3) ofl <<
" facet normal 0.0 1.0 0.0 " << endl;
29325 if(dirId == 4) ofl <<
" facet normal 0.0 0.0 -1.0 " << endl;
29326 if(dirId == 5) ofl <<
" facet normal 0.0 0.0 1.0 " << endl;
29327 ofl <<
" outer loop" << endl;
29328 ofl <<
" vertex " << point1[0] <<
" " << point1[1] <<
" " << point1[2] << endl;
29329 ofl <<
" vertex " << point2[0] <<
" " << point2[1] <<
" " << point2[2] << endl;
29330 ofl <<
" vertex " << point3[0] <<
" " << point3[1] <<
" " << point3[2] << endl;
29331 ofl <<
" endloop" << endl;
29332 ofl <<
" endfacet" << endl;
29333 if(dirId == 0) ofl <<
" facet normal -1.0 0.0 0.0 " << endl;
29334 if(dirId == 1) ofl <<
" facet normal 1.0 0.0 0.0 " << endl;
29335 if(dirId == 2) ofl <<
" facet normal 0.0 -1.0 0.0 " << endl;
29336 if(dirId == 3) ofl <<
" facet normal 0.0 1.0 0.0 " << endl;
29337 if(dirId == 4) ofl <<
" facet normal 0.0 0.0 -1.0 " << endl;
29338 if(dirId == 5) ofl <<
" facet normal 0.0 0.0 1.0 " << endl;
29339 ofl <<
" outer loop" << endl;
29340 ofl <<
" vertex " << point4[0] <<
" " << point4[1] <<
" " << point4[2] << endl;
29341 ofl <<
" vertex " << point2[0] <<
" " << point2[1] <<
" " << point2[2] << endl;
29342 ofl <<
" vertex " << point3[0] <<
" " << point3[1] <<
" " << point3[2] << endl;
29343 ofl <<
" endloop" << endl;
29344 ofl <<
" endfacet" << endl;
29346 ofl <<
"endsolid amazonas cell " <<
cellId << endl;
29366template <MInt nDim,
class SysEqn>
29367template <
class _, std::enable_if_t<nDim == 3, _*>>
29371 static constexpr MInt cornerIndices[8][3] = {{-1, -1, -1}, {1, -1, -1}, {-1, 1, -1}, {1, 1, -1},
29372 {-1, -1, 1}, {1, -1, 1}, {-1, 1, 1}, {1, 1, 1}};
29373 static constexpr MInt cornersSOLVERtoMC[8] = {1, 2, 0, 3, 5, 6, 4, 7};
29374 static constexpr MInt edgesMCtoSOLVER[12] = {0, 2, 1, 3, 4, 6, 5, 7, 10, 8, 9, 11};
29376 unsigned char outcode_MC = 0;
29377 MInt noCells = m_bndryCells->size();
29379 MFloat corner[8][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
29381 MBool currentOutcode =
false;
29382 MInt currentSubCase;
29400 MInt cutPoints[12] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
29401 MInt noCutPoints = 0;
29402 MInt noPlotCells = 0;
29403 const MChar* fileName =
"cutSurface_";
29404 stringstream fileName2;
29405 fileName2 << fileName << domainId() <<
".vtk";
29407 MInt pointsCount = 0;
29410 MInt* mcCases = mcCases_scratch.getPointer();
29411 MInt* subCases = subCases_scratch.getPointer();
29412 for(
MInt i = 0; i < m_bndryCells->size(); i++) {
29416 MIntScratchSpace ambiguousCells_scratch(noCells, AT_,
"ambiguousCells_scratch");
29417 MIntScratchSpace disambiguation_scratch(noCells, AT_,
"disambiguation_scratch");
29418 MInt* ambiguousCells = ambiguousCells_scratch.getPointer();
29419 MInt* disambiguation = disambiguation_scratch.getPointer();
29420 MInt noAmbiguousCells = 0;
29422 MInt faceTMP = std::numeric_limits<MInt>::min();
29423 static constexpr MInt facesMCtoSOLVER[6] = {0, 2, 1, 3, 4, 5};
29425 stack<MInt> ambStack;
29426 MInt case6_2_counter = 0;
29427 MInt case7_3l_counter = 0;
29428 MInt case7_3h_counter = 0;
29429 MInt case3_2_counter = 0;
29435 cerr <<
" begin of plot routine! " << endl;
29438 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
29439 cellId = m_bndryCells->a[bndryId].m_cellId;
29440 m_bndryCells->a[bndryId].m_noSrfcs = 1;
29443 if(m_solver->c_noChildren(cellId) > 0) {
29446 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
29451 for(
MInt j = 0; j < 8; j++) {
29452 for(
MInt dim = 0; dim < nDim; dim++) {
29453 corner[j][dim] = m_solver->a_coordinate(cellId, dim)
29454 + cornerIndices[j][dim] * F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
29456 currentOutcode = !((
MBool)m_solver->m_geometry->pointIsInside2(corner[j]));
29457 if(currentOutcode) outcode_MC = outcode_MC | (1 << cornersSOLVERtoMC[j]);
29461 currentCase = (
MInt)cases[outcode_MC][0];
29462 cerr <<
" cell " <<
cellId <<
" bndryId " << bndryId <<
" currentCase " << currentCase << endl;
29463 mcCases[bndryId] = currentCase;
29464 currentSubCase = (
MInt)cases[outcode_MC][1];
29465 subCases[bndryId] = currentSubCase;
29466 if(!caseStatesSTL[currentCase][0]) {
29467 cerr <<
"Error in plotSurface: Case not implemented: " << currentCase << endl;
29473 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
29474 disambiguation[bndryId] = -1;
29475 cellId = m_bndryCells->a[bndryId].m_cellId;
29476 if(m_solver->c_noChildren(cellId) > 0) {
29479 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
29480 if(!caseStatesSTL[mcCases[bndryId]][0]) {
29483 if(!caseStatesSTL[mcCases[bndryId]][1]) {
29484 ambiguousCells[noAmbiguousCells++] = bndryId;
29485 cerr <<
" cell " << bndryId <<
" is ambiguous " << endl;
29490 for(
MInt ambId = 0; ambId < noAmbiguousCells; ambId++) {
29491 bdAmbId = ambiguousCells[ambId];
29492 disambiguation[bdAmbId] = 0;
29493 cellId = m_bndryCells->a[bdAmbId].m_cellId;
29494 currentCase = mcCases[bdAmbId];
29495 currentSubCase = subCases[bdAmbId];
29498 switch(currentCase) {
29503 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29518 stringstream errorMessage;
29519 errorMessage <<
" Error in FvBndryCndXD::plotSurface: cell in ambigous cells does not have an ambiguous "
29521 <<
cellId <<
" case: " << currentCase <<
" bndryId: " << bdAmbId << endl;
29522 writeStlFileOfCell(cellId,
"errorcell.stl");
29523 mTerm(1, AT_, errorMessage.str());
29527 for(
MInt i = 0; i < faceMax; i++) {
29530 switch(currentCase) {
29532 faceTMP = facesMCtoSOLVER[tiling3_1STL[currentSubCase][2 + i]];
29535 faceTMP = facesMCtoSOLVER[tiling6_1STL[currentSubCase][2 + i]];
29538 faceTMP = facesMCtoSOLVER[tiling7_1STL[currentSubCase][3 + i]];
29541 faceTMP = facesMCtoSOLVER[tiling10_1STL[currentSubCase][2 + i]];
29544 faceTMP = facesMCtoSOLVER[tiling12_1STL[currentSubCase][2 + i]];
29547 stringstream errorMessage;
29548 errorMessage <<
" Error in FvBndryCndXD::plotSurface: cell in ambigous cells does not have an ambiguous "
29550 <<
cellId <<
" case: " << currentCase <<
" bndryId: " << bdAmbId << endl;
29551 mTerm(1, AT_, errorMessage.str());
29554 nghbrCellId = m_solver->c_neighborId(cellId, faceTMP);
29555 if(nghbrCellId < 0) {
29556 stringstream errorMessage;
29557 errorMessage <<
" Error in FvBndryCndXD::plotSurface: no neighbor in ambiguous direction... exiting." << endl;
29558 errorMessage <<
" cellId: " <<
cellId <<
", ambiguous face: " << faceTMP << endl;
29559 writeStlFileOfCell(cellId,
"errorcell.stl");
29560 mTerm(1, AT_, errorMessage.str());
29565 for(
MInt dim = 0; dim < nDim; dim++) {
29566 corner[0][dim] = (m_solver->a_coordinate(cellId, dim) + m_solver->a_coordinate(nghbrCellId, dim)) * F1B2;
29568 currentOutcode = (
MBool)m_solver->m_geometry->pointIsInside2(corner[0]);
29570 if(currentOutcode) {
29571 disambiguation[bdAmbId] +=
IPOW2(faceMax - i - 1);
29576 switch(currentCase) {
29578 if(disambiguation[bdAmbId] == 0) {
29579 if(currentSubCase < 12) {
29580 m_bndryCells->a[bdAmbId].m_noSrfcs = 1;
29584 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29587 if(disambiguation[bdAmbId] == 1) {
29588 if(currentSubCase < 12) {
29589 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29591 m_bndryCells->a[bdAmbId].m_noSrfcs = 1;
29599 if(disambiguation[bdAmbId] == 0) {
29600 if(currentSubCase < 24) {
29601 m_bndryCells->a[bdAmbId].m_noSrfcs = 3;
29604 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29607 if(disambiguation[bdAmbId] == 1) {
29608 if(currentSubCase < 24) {
29609 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29611 m_bndryCells->a[bdAmbId].m_noSrfcs = 3;
29619 if(currentSubCase < 8) {
29620 switch(disambiguation[bdAmbId]) {
29622 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29627 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29628 case7_3l_counter++;
29633 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29636 m_bndryCells->a[bdAmbId].m_noSrfcs = 3;
29639 stringstream errorMessage;
29640 errorMessage <<
"ERROR: Switch variable 'disambiguation[bdAmbId]' with value " << disambiguation[bdAmbId]
29641 <<
" not matching any case." << endl;
29642 mTerm(1, AT_, errorMessage.str());
29646 switch(disambiguation[bdAmbId]) {
29648 m_bndryCells->a[bdAmbId].m_noSrfcs = 3;
29653 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29658 m_bndryCells->a[bdAmbId].m_noSrfcs = 3;
29659 case7_3h_counter++;
29662 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29665 stringstream errorMessage;
29666 errorMessage <<
"ERROR: Switch variable 'disambiguation[bdAmbId]' with value " << disambiguation[bdAmbId]
29667 <<
" not matching any case." << endl;
29668 mTerm(1, AT_, errorMessage.str());
29675 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29679 m_bndryCells->a[bdAmbId].m_noSrfcs = 2;
29683 stringstream errorMessage;
29684 errorMessage <<
" Error in FvBndryCndXD::plotSurface: cell in ambigous cells does not have an ambiguous "
29686 <<
cellId <<
" case: " << currentCase <<
" bndryId: " << bdAmbId << endl;
29687 writeStlFileOfCell(cellId,
"errorcell.stl");
29688 mTerm(1, AT_, errorMessage.str());
29695 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
29697 for(
MInt ambId = 0; ambId < noAmbiguousCells; ambId++) {
29698 MInt bndryId = ambiguousCells[ambId];
29700 cellId = m_bndryCells->a[bndryId].m_cellId;
29701 if(m_solver->c_noChildren(cellId) > 0)
continue;
29702 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
29703 noCutPoints += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
29704 noPlotCells += m_bndryCells->a[bndryId].m_noSrfcs;
29708 ofl.open((fileName2.str()).c_str(), ofstream::trunc);
29712 ofl.setf(ios::fixed);
29715 ofl <<
"# vtk DataFile Version 3.0" << endl
29716 <<
"MAIAD cutsurface file" << endl
29719 <<
"DATASET UNSTRUCTURED_GRID" << endl
29722 ofl <<
"POINTS " << noCutPoints <<
" float" << endl;
29726 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
29728 for(
MInt ambId = 0; ambId < noAmbiguousCells; ambId++) {
29729 MInt bndryId = ambiguousCells[ambId];
29732 cellId = m_bndryCells->a[bndryId].m_cellId;
29735 if(m_solver->c_noChildren(cellId) > 0) {
29738 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
29740 for(
MInt cutPoint = 0; cutPoint < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cutPoint++) {
29741 for(
MInt i = 0; i < 3; i++)
29742 ofl << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoint][i] <<
" ";
29745 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints != caseCutPoints[mcCases[bndryId]]) {
29746 stringstream errorMessage;
29747 errorMessage <<
"Problem in FvBndryCndXD::plotSurface: "
29748 <<
" cell " << bndryId <<
" case " << mcCases[bndryId] << endl;
29749 errorMessage <<
" cell with subcase " << subCases[bndryId] <<
" has "
29750 << m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints <<
" cutpoints instead of "
29751 << caseCutPoints[mcCases[bndryId]] << endl;
29752 writeStlFileOfCell(cellId,
"problemacell.stl");
29753 mTerm(1, AT_, errorMessage.str());
29760 ofl <<
"CELLS " << noPlotCells <<
" "
29761 << noPlotCells + noCutPoints + case6_2_counter * 4 + case7_3l_counter * 2 + case7_3h_counter * 4
29762 + case3_2_counter * 2
29768 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
29770 for(
MInt ambId = 0; ambId < noAmbiguousCells; ambId++) {
29771 MInt bndryId = ambiguousCells[ambId];
29773 cellId = m_bndryCells->a[bndryId].m_cellId;
29775 if(m_solver->c_noChildren(cellId) > 0) {
29778 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
29780 for(
MInt cutPoint = 0; cutPoint < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cutPoint++) {
29781 cutPoints[m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPoint]] = cutPoint;
29784 for(
MInt i = 0; i < 8; i++) {
29785 for(
MInt dim = 0; dim < nDim; dim++) {
29786 corner[i][dim] = m_solver->a_coordinate(cellId, dim)
29787 + cornerIndices[i][dim] * F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
29791 currentCase = mcCases[bndryId];
29792 currentSubCase = subCases[bndryId];
29794 if(!caseStatesSTL[currentCase][0]) {
29795 cerr <<
"Error in plotSurface: Case not implemented: " << currentCase << endl;
29799 if(!caseStatesSTL[currentCase][1]) {
29800 switch(currentCase) {
29802 if(disambiguation[bndryId] == -1) {
29803 stringstream errorMessage;
29804 errorMessage <<
"Error in plotSurface: case 3 cell not disambiguated! cell: " <<
cellId <<
", exiting!"
29806 mTerm(1, AT_, errorMessage.str());
29808 if((currentSubCase < 12 && disambiguation[bndryId] == 0)
29809 || (currentSubCase >= 12 && disambiguation[bndryId] == 1)) {
29810 cerr <<
" plotting case 3.2 - 1 surface " << endl;
29812 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][2]];
29813 p_1 = cutPoints[cutDummy];
29814 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][3]];
29815 p_2 = cutPoints[cutDummy];
29816 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][4]];
29817 p_3 = cutPoints[cutDummy];
29818 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][5]];
29819 p_1s = cutPoints[cutDummy];
29820 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][6]];
29821 p_2s = cutPoints[cutDummy];
29822 cutDummy = edgesMCtoSOLVER[tiling3_2STL[currentSubCase][7]];
29823 p_3s = cutPoints[cutDummy];
29835 for(
MInt i = 0; i < 6; i++) {
29836 ofl << pP[i] + pointsCount <<
" ";
29863 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
29865 }
else if((currentSubCase < 12 && disambiguation[bndryId] == 1)
29866 || (currentSubCase >= 12 && disambiguation[bndryId] == 0)) {
29867 cerr <<
" plotting case 3.1 - 2 surfaces " << endl;
29869 subCaseDummy = tiling3_1STL[currentSubCase][0];
29870 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
29871 pP[0] = cutPoints[cutDummy];
29872 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
29873 pP[1] = cutPoints[cutDummy];
29874 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
29875 pP[2] = cutPoints[cutDummy];
29879 for(
MInt i = 0; i < 3; i++) {
29880 ofl << pP[i] + pointsCount <<
" ";
29885 subCaseDummy = tiling3_1STL[currentSubCase][1];
29886 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
29887 pP[0] = cutPoints[cutDummy];
29888 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
29889 pP[1] = cutPoints[cutDummy];
29890 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
29891 pP[2] = cutPoints[cutDummy];
29895 for(
MInt i = 0; i < 3; i++) {
29896 ofl << pP[i] + pointsCount <<
" ";
29899 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
29904 cerr <<
" plotting case 4 - 2 surfaces " << endl;
29906 subCaseDummy = tiling4_1STL[currentSubCase][0];
29907 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
29908 pP[0] = cutPoints[cutDummy];
29909 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
29910 pP[1] = cutPoints[cutDummy];
29911 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
29912 pP[2] = cutPoints[cutDummy];
29916 for(
MInt i = 0; i < 3; i++) {
29917 ofl << pP[i] + pointsCount <<
" ";
29922 subCaseDummy = tiling4_1STL[currentSubCase][1];
29923 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
29924 pP[0] = cutPoints[cutDummy];
29925 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
29926 pP[1] = cutPoints[cutDummy];
29927 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
29928 pP[2] = cutPoints[cutDummy];
29932 for(
MInt i = 0; i < 3; i++) {
29933 ofl << pP[i] + pointsCount <<
" ";
29936 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
29941 if((currentSubCase < 24 && disambiguation[bndryId] == 0)
29942 || (currentSubCase >= 24 && disambiguation[bndryId] == 1)) {
29943 cerr <<
" plotting case 6.2 - 3 surfaces " << endl;
29945 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][5]];
29946 p_0s = cutPoints[cutDummy];
29947 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][6]];
29948 p_0ss = cutPoints[cutDummy];
29949 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][7]];
29950 p_1s = cutPoints[cutDummy];
29951 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][8]];
29952 p_1ss = cutPoints[cutDummy];
29953 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][9]];
29954 p_2s = cutPoints[cutDummy];
29955 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][10]];
29956 p_2ss = cutPoints[cutDummy];
29957 cutDummy = edgesMCtoSOLVER[tiling6_2STL[currentSubCase][11]];
29958 p_3 = cutPoints[cutDummy];
29967 for(
MInt i = 0; i < 4; i++) {
29968 ofl << pP[i] + pointsCount <<
" ";
29979 for(
MInt i = 0; i < 4; i++) {
29980 ofl << pP[i] + pointsCount <<
" ";
29990 for(
MInt i = 0; i < 3; i++) {
29991 ofl << pP[i] + pointsCount <<
" ";
29994 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
29996 }
else if((currentSubCase < 24 && disambiguation[bndryId] == 1)
29997 || (currentSubCase >= 24 && disambiguation[bndryId] == 0)) {
29998 cerr <<
" plotting case 6.1 - 2 surfaces " << endl;
30000 subCaseDummy = tiling6_1STL[currentSubCase][0];
30001 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
30002 p_3 = cutPoints[cutDummy];
30003 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
30004 p_2 = cutPoints[cutDummy];
30005 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
30006 p_3s = cutPoints[cutDummy];
30007 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
30008 p_2s = cutPoints[cutDummy];
30018 for(
MInt i = 0; i < 4; i++) {
30019 ofl << pP[i] + pointsCount <<
" ";
30025 subCaseDummy = tiling6_1STL[currentSubCase][1];
30026 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30027 pP[0] = cutPoints[cutDummy];
30028 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30029 pP[1] = cutPoints[cutDummy];
30030 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30031 pP[2] = cutPoints[cutDummy];
30035 for(
MInt i = 0; i < 3; i++) {
30036 ofl << pP[i] + pointsCount <<
" ";
30039 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30044 disamb_tmp = disambiguation[bndryId];
30045 if(currentSubCase >= 8) disamb_tmp = 7 - disamb_tmp;
30046 switch(disamb_tmp) {
30049 cerr <<
" plotting case 7.4.1 - 2 surfaces " << endl;
30051 subCaseDummy = tiling7_4_1STL[currentSubCase][0];
30052 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30053 pP[0] = cutPoints[cutDummy];
30054 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30055 pP[1] = cutPoints[cutDummy];
30056 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30057 pP[2] = cutPoints[cutDummy];
30061 for(
MInt i = 0; i < 3; i++) {
30062 ofl << pP[i] + pointsCount <<
" ";
30066 subCaseDummy = tiling7_4_1STL[currentSubCase][1];
30068 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][4]];
30069 p_1s = cutPoints[cutDummy];
30070 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][5]];
30071 p_1ss = cutPoints[cutDummy];
30072 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][6]];
30073 p_2s = cutPoints[cutDummy];
30074 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][7]];
30075 p_2ss = cutPoints[cutDummy];
30076 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][8]];
30077 p_3s = cutPoints[cutDummy];
30078 cutDummy = edgesMCtoSOLVER[tiling9STL[subCaseDummy][9]];
30079 p_3ss = cutPoints[cutDummy];
30091 for(
MInt i = 0; i < 6; i++) {
30092 ofl << pP[i] + pointsCount <<
" ";
30095 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30100 cutDummy = edgesMCtoSOLVER[tiling7_3_1STL[currentSubCase][6]];
30101 p_1s = cutPoints[cutDummy];
30102 cutDummy = edgesMCtoSOLVER[tiling7_3_1STL[currentSubCase][7]];
30103 p_1ss = cutPoints[cutDummy];
30104 cutDummy = edgesMCtoSOLVER[tiling7_3_1STL[currentSubCase][8]];
30105 p_1sss = cutPoints[cutDummy];
30106 cutDummy = edgesMCtoSOLVER[tiling7_3_1STL[currentSubCase][9]];
30107 p_2s = cutPoints[cutDummy];
30108 cutDummy = edgesMCtoSOLVER[tiling7_3_1STL[currentSubCase][10]];
30109 p_2ss = cutPoints[cutDummy];
30110 cutDummy = edgesMCtoSOLVER[tiling7_3_1STL[currentSubCase][11]];
30111 p_2sss = cutPoints[cutDummy];
30112 cutDummy = edgesMCtoSOLVER[tiling7_3_1STL[currentSubCase][12]];
30113 p_3s = cutPoints[cutDummy];
30114 cutDummy = edgesMCtoSOLVER[tiling7_3_1STL[currentSubCase][13]];
30115 p_3ss = cutPoints[cutDummy];
30116 cutDummy = edgesMCtoSOLVER[tiling7_3_1STL[currentSubCase][14]];
30117 p_3sss = cutPoints[cutDummy];
30119 if(currentSubCase < 8) {
30120 cerr <<
" plotting case 7.3 - 2 surfaces, disamb 1, low SC " << endl;
30130 for(
MInt i = 0; i < 5; i++) {
30131 ofl << pP[i] + pointsCount <<
" ";
30144 for(
MInt i = 0; i < 6; i++) {
30145 ofl << pP[i] + pointsCount <<
" ";
30149 cerr <<
" plotting case 7.3 - 3 surfaces, disamb 1, high SC " << endl;
30159 for(
MInt i = 0; i < 5; i++) {
30160 ofl << pP[i] + pointsCount <<
" ";
30172 for(
MInt i = 0; i < 5; i++) {
30173 ofl << pP[i] + pointsCount <<
" ";
30183 for(
MInt i = 0; i < 3; i++) {
30184 ofl << pP[i] + pointsCount <<
" ";
30188 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30193 cerr <<
" plotting case 7.3 - 3 surfaces, disamb 2 " << endl;
30195 cutDummy = edgesMCtoSOLVER[tiling7_3_2STL[currentSubCase][6]];
30196 p_1s = cutPoints[cutDummy];
30197 cutDummy = edgesMCtoSOLVER[tiling7_3_2STL[currentSubCase][7]];
30198 p_1ss = cutPoints[cutDummy];
30199 cutDummy = edgesMCtoSOLVER[tiling7_3_2STL[currentSubCase][8]];
30200 p_1sss = cutPoints[cutDummy];
30201 cutDummy = edgesMCtoSOLVER[tiling7_3_2STL[currentSubCase][9]];
30202 p_2s = cutPoints[cutDummy];
30203 cutDummy = edgesMCtoSOLVER[tiling7_3_2STL[currentSubCase][10]];
30204 p_2ss = cutPoints[cutDummy];
30205 cutDummy = edgesMCtoSOLVER[tiling7_3_2STL[currentSubCase][11]];
30206 p_2sss = cutPoints[cutDummy];
30207 cutDummy = edgesMCtoSOLVER[tiling7_3_2STL[currentSubCase][12]];
30208 p_3s = cutPoints[cutDummy];
30209 cutDummy = edgesMCtoSOLVER[tiling7_3_2STL[currentSubCase][13]];
30210 p_3ss = cutPoints[cutDummy];
30211 cutDummy = edgesMCtoSOLVER[tiling7_3_2STL[currentSubCase][14]];
30212 p_3sss = cutPoints[cutDummy];
30214 if(currentSubCase < 8) {
30215 cerr <<
" plotting case 7.3 - 2 surfaces, disamb 2, low SC " << endl;
30225 for(
MInt i = 0; i < 5; i++) {
30226 ofl << pP[i] + pointsCount <<
" ";
30239 for(
MInt i = 0; i < 6; i++) {
30240 ofl << pP[i] + pointsCount <<
" ";
30244 cerr <<
" plotting case 7.3 - 3 surfaces, disamb 2, high SC " << endl;
30254 for(
MInt i = 0; i < 5; i++) {
30255 ofl << pP[i] + pointsCount <<
" ";
30267 for(
MInt i = 0; i < 5; i++) {
30268 ofl << pP[i] + pointsCount <<
" ";
30278 for(
MInt i = 0; i < 3; i++) {
30279 ofl << pP[i] + pointsCount <<
" ";
30283 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30288 cerr <<
" plotting case 7.3 - 3 surfaces, disamb 4 " << endl;
30290 cutDummy = edgesMCtoSOLVER[tiling7_3_4STL[currentSubCase][6]];
30291 p_1s = cutPoints[cutDummy];
30292 cutDummy = edgesMCtoSOLVER[tiling7_3_4STL[currentSubCase][7]];
30293 p_1ss = cutPoints[cutDummy];
30294 cutDummy = edgesMCtoSOLVER[tiling7_3_4STL[currentSubCase][8]];
30295 p_1sss = cutPoints[cutDummy];
30296 cutDummy = edgesMCtoSOLVER[tiling7_3_4STL[currentSubCase][9]];
30297 p_2s = cutPoints[cutDummy];
30298 cutDummy = edgesMCtoSOLVER[tiling7_3_4STL[currentSubCase][10]];
30299 p_2ss = cutPoints[cutDummy];
30300 cutDummy = edgesMCtoSOLVER[tiling7_3_4STL[currentSubCase][11]];
30301 p_2sss = cutPoints[cutDummy];
30302 cutDummy = edgesMCtoSOLVER[tiling7_3_4STL[currentSubCase][12]];
30303 p_3s = cutPoints[cutDummy];
30304 cutDummy = edgesMCtoSOLVER[tiling7_3_4STL[currentSubCase][13]];
30305 p_3ss = cutPoints[cutDummy];
30306 cutDummy = edgesMCtoSOLVER[tiling7_3_4STL[currentSubCase][14]];
30307 p_3sss = cutPoints[cutDummy];
30309 if(currentSubCase < 8) {
30310 cerr <<
" plotting case 7.3 - 2 surfaces, disamb 4, low SC " << endl;
30320 for(
MInt i = 0; i < 5; i++) {
30321 ofl << pP[i] + pointsCount <<
" ";
30334 for(
MInt i = 0; i < 6; i++) {
30335 ofl << pP[i] + pointsCount <<
" ";
30339 cerr <<
" plotting case 7.3 - 3 surfaces, disamb 4, high SC " << endl;
30349 for(
MInt i = 0; i < 5; i++) {
30350 ofl << pP[i] + pointsCount <<
" ";
30362 for(
MInt i = 0; i < 5; i++) {
30363 ofl << pP[i] + pointsCount <<
" ";
30373 for(
MInt i = 0; i < 3; i++) {
30374 ofl << pP[i] + pointsCount <<
" ";
30378 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30384 cerr <<
" plotting case 7.2 - 2 surfaces, disamb 3 " << endl;
30386 subCaseDummy = tiling7_2_3STL[currentSubCase][0];
30387 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30388 pP[0] = cutPoints[cutDummy];
30389 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30390 pP[1] = cutPoints[cutDummy];
30391 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30392 pP[2] = cutPoints[cutDummy];
30396 for(
MInt i = 0; i < 3; i++) {
30397 ofl << pP[i] + pointsCount <<
" ";
30401 subCaseDummy = tiling7_2_3STL[currentSubCase][1];
30402 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][2]];
30403 p_1 = cutPoints[cutDummy];
30404 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][3]];
30405 p_2 = cutPoints[cutDummy];
30406 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][4]];
30407 p_3 = cutPoints[cutDummy];
30408 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][5]];
30409 p_1s = cutPoints[cutDummy];
30410 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][6]];
30411 p_2s = cutPoints[cutDummy];
30412 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][7]];
30413 p_3s = cutPoints[cutDummy];
30425 for(
MInt i = 0; i < 6; i++) {
30426 ofl << pP[i] + pointsCount <<
" ";
30429 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30434 cerr <<
" plotting case 7.2 - 2 surfaces, disamb 5 " << endl;
30436 subCaseDummy = tiling7_2_5STL[currentSubCase][0];
30437 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30438 pP[0] = cutPoints[cutDummy];
30439 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30440 pP[1] = cutPoints[cutDummy];
30441 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30442 pP[2] = cutPoints[cutDummy];
30446 for(
MInt i = 0; i < 3; i++) {
30447 ofl << pP[i] + pointsCount <<
" ";
30451 subCaseDummy = tiling7_2_5STL[currentSubCase][1];
30452 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][2]];
30453 p_1 = cutPoints[cutDummy];
30454 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][3]];
30455 p_2 = cutPoints[cutDummy];
30456 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][4]];
30457 p_3 = cutPoints[cutDummy];
30458 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][5]];
30459 p_1s = cutPoints[cutDummy];
30460 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][6]];
30461 p_2s = cutPoints[cutDummy];
30462 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][7]];
30463 p_3s = cutPoints[cutDummy];
30475 for(
MInt i = 0; i < 6; i++) {
30476 ofl << pP[i] + pointsCount <<
" ";
30479 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30484 cerr <<
" plotting case 7.2 - 2 surfaces, disamb 6 " << endl;
30486 subCaseDummy = tiling7_2_6STL[currentSubCase][0];
30487 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30488 pP[0] = cutPoints[cutDummy];
30489 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30490 pP[1] = cutPoints[cutDummy];
30491 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30492 pP[2] = cutPoints[cutDummy];
30496 for(
MInt i = 0; i < 3; i++) {
30497 ofl << pP[i] + pointsCount <<
" ";
30501 subCaseDummy = tiling7_2_6STL[currentSubCase][1];
30502 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][2]];
30503 p_1 = cutPoints[cutDummy];
30504 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][3]];
30505 p_2 = cutPoints[cutDummy];
30506 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][4]];
30507 p_3 = cutPoints[cutDummy];
30508 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][5]];
30509 p_1s = cutPoints[cutDummy];
30510 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][6]];
30511 p_2s = cutPoints[cutDummy];
30512 cutDummy = edgesMCtoSOLVER[tiling3_2STL[subCaseDummy][7]];
30513 p_3s = cutPoints[cutDummy];
30525 for(
MInt i = 0; i < 6; i++) {
30526 ofl << pP[i] + pointsCount <<
" ";
30529 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30534 cerr <<
" plotting case 7.1 - 3 surfaces " << endl;
30536 subCaseDummy = tiling7_1STL[currentSubCase][0];
30537 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30538 pP[0] = cutPoints[cutDummy];
30539 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30540 pP[1] = cutPoints[cutDummy];
30541 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30542 pP[2] = cutPoints[cutDummy];
30546 for(
MInt i = 0; i < 3; i++) {
30547 ofl << pP[i] + pointsCount <<
" ";
30553 subCaseDummy = tiling7_1STL[currentSubCase][1];
30554 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30555 pP[0] = cutPoints[cutDummy];
30556 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30557 pP[1] = cutPoints[cutDummy];
30558 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30559 pP[2] = cutPoints[cutDummy];
30563 for(
MInt i = 0; i < 3; i++) {
30564 ofl << pP[i] + pointsCount <<
" ";
30569 subCaseDummy = tiling7_1STL[currentSubCase][2];
30570 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30571 pP[0] = cutPoints[cutDummy];
30572 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30573 pP[1] = cutPoints[cutDummy];
30574 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30575 pP[2] = cutPoints[cutDummy];
30579 for(
MInt i = 0; i < 3; i++) {
30580 ofl << pP[i] + pointsCount <<
" ";
30584 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30588 stringstream errorMessage;
30589 errorMessage <<
"ERROR: Switch variable 'disamb_tmp' with value " << disamb_tmp
30590 <<
" not matching any case." << endl;
30591 mTerm(1, AT_, errorMessage.str());
30599 if(disambiguation[bndryId] == 3) {
30600 cerr <<
" plotting case 10.2 (really 10.1.1 split) - 2 surfaces " << endl;
30602 subCaseDummy = tiling10_2STL[currentSubCase][0];
30603 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
30604 p_3 = cutPoints[cutDummy];
30605 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
30606 p_2 = cutPoints[cutDummy];
30607 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
30608 p_3s = cutPoints[cutDummy];
30609 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
30610 p_2s = cutPoints[cutDummy];
30620 for(
MInt i = 0; i < 4; i++) {
30621 ofl << pP[i] + pointsCount <<
" ";
30626 subCaseDummy = tiling10_2STL[currentSubCase][1];
30627 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
30628 p_3 = cutPoints[cutDummy];
30629 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
30630 p_2 = cutPoints[cutDummy];
30631 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
30632 p_3s = cutPoints[cutDummy];
30633 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
30634 p_2s = cutPoints[cutDummy];
30644 for(
MInt i = 0; i < 4; i++) {
30645 ofl << pP[i] + pointsCount <<
" ";
30649 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30652 }
else if(disambiguation[bndryId] == 0) {
30653 cerr <<
" plotting case 10.1 - 2 surfaces " << endl;
30655 subCaseDummy = tiling10_1STL[currentSubCase][0];
30656 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
30657 p_3 = cutPoints[cutDummy];
30658 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
30659 p_2 = cutPoints[cutDummy];
30660 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
30661 p_3s = cutPoints[cutDummy];
30662 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
30663 p_2s = cutPoints[cutDummy];
30673 for(
MInt i = 0; i < 4; i++) {
30674 ofl << pP[i] + pointsCount <<
" ";
30679 subCaseDummy = tiling10_1STL[currentSubCase][1];
30680 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
30681 p_3 = cutPoints[cutDummy];
30682 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
30683 p_2 = cutPoints[cutDummy];
30684 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
30685 p_3s = cutPoints[cutDummy];
30686 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
30687 p_2s = cutPoints[cutDummy];
30697 for(
MInt i = 0; i < 4; i++) {
30698 ofl << pP[i] + pointsCount <<
" ";
30702 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30705 cerr <<
"Error in plotSurface: Type 10.2 (real 10.2) detected, but not implemented."
30706 <<
" cell " <<
cellId <<
" with bndryId " << bndryId <<
" and disambiguation "
30707 << disambiguation[bndryId] << endl;
30708 writeStlFileOfCell(cellId,
"10_2_cell.stl");
30709 cerr <<
" plotting cell as 10.1 cell... " << endl;
30712 subCaseDummy = tiling10_1STL[currentSubCase][0];
30713 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
30714 p_3 = cutPoints[cutDummy];
30715 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
30716 p_2 = cutPoints[cutDummy];
30717 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
30718 p_3s = cutPoints[cutDummy];
30719 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
30720 p_2s = cutPoints[cutDummy];
30730 for(
MInt i = 0; i < 4; i++) {
30731 ofl << pP[i] + pointsCount <<
" ";
30736 subCaseDummy = tiling10_1STL[currentSubCase][1];
30737 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][2]];
30738 p_3 = cutPoints[cutDummy];
30739 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][3]];
30740 p_2 = cutPoints[cutDummy];
30741 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][4]];
30742 p_3s = cutPoints[cutDummy];
30743 cutDummy = edgesMCtoSOLVER[tiling2STL[subCaseDummy][5]];
30744 p_2s = cutPoints[cutDummy];
30754 for(
MInt i = 0; i < 4; i++) {
30755 ofl << pP[i] + pointsCount <<
" ";
30759 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30765 if(disambiguation[bndryId] == 0) {
30766 cerr <<
" plotting case 12.1 - 2 surfaces - connected" << endl;
30768 subCaseDummy = tiling12_1STL[currentSubCase][0];
30770 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][3]];
30771 p_0s = cutPoints[cutDummy];
30772 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][4]];
30773 p_0ss = cutPoints[cutDummy];
30774 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][5]];
30775 p_1s = cutPoints[cutDummy];
30776 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][6]];
30777 p_2s = cutPoints[cutDummy];
30778 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][7]];
30779 p_2ss = cutPoints[cutDummy];
30790 for(
MInt i = 0; i < 5; i++) {
30791 ofl << pP[i] + pointsCount <<
" ";
30796 subCaseDummy = tiling12_1STL[currentSubCase][1];
30797 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30798 pP[0] = cutPoints[cutDummy];
30799 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30800 pP[1] = cutPoints[cutDummy];
30801 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30802 pP[2] = cutPoints[cutDummy];
30806 for(
MInt i = 0; i < 3; i++) {
30807 ofl << pP[i] + pointsCount <<
" ";
30810 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30811 }
else if(disambiguation[bndryId] == 3) {
30812 cerr <<
" plotting case 12.1 - 2 surfaces - separated" << endl;
30814 subCaseDummy = tiling12_1STL[23 - currentSubCase][0];
30816 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][3]];
30817 p_0s = cutPoints[cutDummy];
30818 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][4]];
30819 p_0ss = cutPoints[cutDummy];
30820 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][5]];
30821 p_1s = cutPoints[cutDummy];
30822 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][6]];
30823 p_2s = cutPoints[cutDummy];
30824 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][7]];
30825 p_2ss = cutPoints[cutDummy];
30836 for(
MInt i = 0; i < 5; i++) {
30837 ofl << pP[i] + pointsCount <<
" ";
30842 subCaseDummy = tiling12_1STL[23 - currentSubCase][1];
30843 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30844 pP[0] = cutPoints[cutDummy];
30845 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30846 pP[1] = cutPoints[cutDummy];
30847 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30848 pP[2] = cutPoints[cutDummy];
30852 for(
MInt i = 0; i < 3; i++) {
30853 ofl << pP[i] + pointsCount <<
" ";
30856 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30858 cerr <<
"Error in plotSurface: Type 12.2 or 12.3 detected, but not implemented."
30859 <<
" cell " <<
cellId <<
" with bndryId " << bndryId <<
" and disambiguation "
30860 << disambiguation[bndryId] << endl;
30861 cerr <<
" plotting as 12.1 cell... " << endl;
30862 writeStlFileOfCell(cellId,
"12.2_12.3_cell.stl");
30865 subCaseDummy = tiling12_1STL[23 - currentSubCase][0];
30867 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][3]];
30868 p_0s = cutPoints[cutDummy];
30869 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][4]];
30870 p_0ss = cutPoints[cutDummy];
30871 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][5]];
30872 p_1s = cutPoints[cutDummy];
30873 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][6]];
30874 p_2s = cutPoints[cutDummy];
30875 cutDummy = edgesMCtoSOLVER[tiling5STL[subCaseDummy][7]];
30876 p_2ss = cutPoints[cutDummy];
30887 for(
MInt i = 0; i < 5; i++) {
30888 ofl << pP[i] + pointsCount <<
" ";
30893 subCaseDummy = tiling12_1STL[23 - currentSubCase][1];
30894 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][1]];
30895 pP[0] = cutPoints[cutDummy];
30896 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][2]];
30897 pP[1] = cutPoints[cutDummy];
30898 cutDummy = edgesMCtoSOLVER[tiling1STL[subCaseDummy][3]];
30899 pP[2] = cutPoints[cutDummy];
30903 for(
MInt i = 0; i < 3; i++) {
30904 ofl << pP[i] + pointsCount <<
" ";
30907 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30913 stringstream errorMessage;
30914 errorMessage <<
"Error in plotSurface: Inconsistent type implementation." << endl;
30915 mTerm(1, AT_, errorMessage.str());
30919 switch(currentCase) {
30921 cerr <<
"Error in plotSurface: Cell is not a boundary cell!" << endl;
30922 cerr <<
"CellId: " <<
cellId <<
" BndryId: " << bndryId << endl;
30926 cutDummy = edgesMCtoSOLVER[tiling1STL[currentSubCase][1]];
30927 pP[0] = cutPoints[cutDummy];
30928 cutDummy = edgesMCtoSOLVER[tiling1STL[currentSubCase][2]];
30929 pP[1] = cutPoints[cutDummy];
30930 cutDummy = edgesMCtoSOLVER[tiling1STL[currentSubCase][3]];
30931 pP[2] = cutPoints[cutDummy];
30935 for(
MInt i = 0; i < 3; i++) {
30936 ofl << pP[i] + pointsCount <<
" ";
30939 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30943 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][2]];
30944 p_3 = cutPoints[cutDummy];
30945 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][3]];
30946 p_2 = cutPoints[cutDummy];
30947 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][4]];
30948 p_3s = cutPoints[cutDummy];
30949 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][5]];
30950 p_2s = cutPoints[cutDummy];
30959 for(
MInt i = 0; i < 4; i++) {
30960 ofl << pP[i] + pointsCount <<
" ";
30963 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30969 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][3]];
30970 p_0s = cutPoints[cutDummy];
30971 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][4]];
30972 p_0ss = cutPoints[cutDummy];
30973 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][5]];
30974 p_1s = cutPoints[cutDummy];
30975 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][6]];
30976 p_2s = cutPoints[cutDummy];
30977 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][7]];
30978 p_2ss = cutPoints[cutDummy];
30989 for(
MInt i = 0; i < 5; i++) {
30990 ofl << pP[i] + pointsCount <<
" ";
30993 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
30998 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][4]];
30999 p_0s = cutPoints[cutDummy];
31000 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][5]];
31001 p_1s = cutPoints[cutDummy];
31002 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][6]];
31003 p_2s = cutPoints[cutDummy];
31004 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][7]];
31005 p_3s = cutPoints[cutDummy];
31015 for(
MInt i = 0; i < 4; i++) {
31016 ofl << pP[i] + pointsCount <<
" ";
31019 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
31025 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][4]];
31026 p_1s = cutPoints[cutDummy];
31027 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][5]];
31028 p_1ss = cutPoints[cutDummy];
31029 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][6]];
31030 p_2s = cutPoints[cutDummy];
31031 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][7]];
31032 p_2ss = cutPoints[cutDummy];
31033 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][8]];
31034 p_3s = cutPoints[cutDummy];
31035 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][9]];
31036 p_3ss = cutPoints[cutDummy];
31048 for(
MInt i = 0; i < 6; i++) {
31049 ofl << pP[i] + pointsCount <<
" ";
31052 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
31057 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][4]];
31058 p_0s = cutPoints[cutDummy];
31059 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][5]];
31060 p_0ss = cutPoints[cutDummy];
31061 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][6]];
31062 p_1s = cutPoints[cutDummy];
31063 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][7]];
31064 p_2s = cutPoints[cutDummy];
31065 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][8]];
31066 p_3s = cutPoints[cutDummy];
31067 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][9]];
31068 p_3ss = cutPoints[cutDummy];
31080 for(
MInt i = 0; i < 6; i++) {
31081 ofl << pP[i] + pointsCount <<
" ";
31084 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
31090 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][4]];
31091 p_0s = cutPoints[cutDummy];
31092 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][5]];
31093 p_0ss = cutPoints[cutDummy];
31094 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][6]];
31095 p_1s = cutPoints[cutDummy];
31096 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][7]];
31097 p_2s = cutPoints[cutDummy];
31098 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][8]];
31099 p_3s = cutPoints[cutDummy];
31100 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][9]];
31101 p_3ss = cutPoints[cutDummy];
31113 for(
MInt i = 0; i < 6; i++) {
31114 ofl << pP[i] + pointsCount <<
" ";
31118 pointsCount += m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
31130 ofl <<
"CELL_TYPES " << noPlotCells << endl;
31131 for(
MInt i = 0; i < noPlotCells; i++) {
31147template <MInt nDim,
class SysEqn>
31148template <
class _, std::enable_if_t<nDim == 3, _*>>
31152 MInt& iter = m_static_plotEdges_iter;
31153 stringstream fileName;
31154 fileName <<
"FeatureEdges" << domainId() <<
"_" << iter++ <<
".vtk";
31157 ofl.open((fileName.str()).c_str(), ofstream::trunc);
31160 ofl.setf(ios::fixed);
31163 ofl <<
"# vtk DataFile Version 3.0" << endl
31164 <<
"MAIAD featureEdge file" << endl
31166 <<
"DATASET POLYDATA" << endl
31167 <<
"POINTS " << noFeatureEdges * 2 <<
" float" << endl;
31169 for(
MInt i = 0; i < noFeatureEdges; i++) {
31170 for(
MInt j = 0; j < 2; j++) {
31171 for(
MInt k = 0; k < 3; k++) {
31172 ofl << featureEdges[2 * i + j][k] <<
" ";
31178 ofl <<
"LINES " << noFeatureEdges <<
" " << noFeatureEdges * 3 << endl;
31179 for(
MInt i = 0; i < noFeatureEdges; i++) {
31180 ofl <<
"2 " << 2 * i <<
" " << 2 * i + 1 << endl;
31198template <MInt nDim,
class SysEqn>
31199template <
class _, std::enable_if_t<nDim == 3, _*>>
31203 MInt& iter = m_static_plotIntersectionPoints_iter;
31204 stringstream fileName;
31205 fileName <<
"IntersectionPoints" << domainId() <<
"_" << iter++ <<
".vtk";
31208 ofl.open((fileName.str()).c_str(), ofstream::trunc);
31209 MInt totalPoints = 0;
31211 for(
MInt i = 0; i < 6; i++) {
31212 totalPoints += noIntersectionPoints[i];
31216 ofl.setf(ios::fixed);
31219 ofl <<
"# vtk DataFile Version 3.0" << endl
31220 <<
"MAIAD intersectionPoints file" << endl
31222 <<
"DATASET POLYDATA" << endl
31223 <<
"POINTS " << totalPoints <<
" float" << endl;
31225 for(
MInt face = 0; face < 6; face++) {
31226 for(
MInt i = 0; i < noIntersectionPoints[face]; i++) {
31227 for(
MInt k = 0; k < 3; k++) {
31228 ofl << intersectionPoints[face][i][k] <<
" ";
31234 ofl <<
"VERTICES " << totalPoints <<
" " << totalPoints * 2 << endl;
31235 for(
MInt i = 0; i < totalPoints; i++) {
31236 ofl <<
"1 " << i << endl;
31249template <MInt nDim,
class SysEqn>
31250template <
class _, std::enable_if_t<nDim == 3, _*>>
31257 MFloat normal[3] = {0.0, 0.0, 0.0};
31258 MFloat dummy_1[3] = {0, 0, 0};
31259 MFloat dummy_2[3] = {0, 0, 0};
31260 MFloat dummy_3[3] = {0, 0, 0};
31262 MInt& iter = m_static_writeStlOfNodes_iter;
31263 stringstream fileName2;
31264 fileName2 << filename << domainId() <<
"_" << iter++ <<
".stl";
31267 ofl.open((fileName2.str()).c_str(), ofstream::trunc);
31271 ofl.setf(ios::fixed);
31274 ofl <<
" solid feature triangles " << endl;
31276 for(
MInt i = 0; i < noNodes; i++) {
31277 point1 = m_solver->m_geometry->elements[nodeList[i]].m_vertices[0];
31278 point2 = m_solver->m_geometry->elements[nodeList[i]].m_vertices[1];
31279 point3 = m_solver->m_geometry->elements[nodeList[i]].m_vertices[2];
31281 vecSub(point2, point1, dummy_1);
31282 vecSub(point3, point1, dummy_2);
31285 vecScalarMul(-1.0 / area, dummy_3, normal);
31287 ofl <<
" facet normal " << normal[0] <<
" " << normal[1] <<
" " << normal[2] << endl;
31288 ofl <<
" outer loop" << endl;
31289 ofl <<
" vertex " << point1[0] <<
" " << point1[1] <<
" " << point1[2] << endl;
31290 ofl <<
" vertex " << point2[0] <<
" " << point2[1] <<
" " << point2[2] << endl;
31291 ofl <<
" vertex " << point3[0] <<
" " << point3[1] <<
" " << point3[2] << endl;
31292 ofl <<
" endloop" << endl;
31293 ofl <<
" endfacet" << endl;
31296 ofl <<
" endsolid feature triangles " << endl;
31308template <MInt nDim,
class SysEqn>
31309template <
class _, std::enable_if_t<nDim == 3, _*>>
31313 ofl <<
" facet normal " << normal[0] <<
" " << normal[1] <<
" " << normal[2] << endl;
31314 ofl <<
" outer loop" << endl;
31315 ofl <<
" vertex " << A[0] <<
" " << A[1] <<
" " << A[2] << endl;
31316 ofl <<
" vertex " << B[0] <<
" " << B[1] <<
" " << B[2] << endl;
31317 ofl <<
" vertex " << C[0] <<
" " << C[1] <<
" " << C[2] << endl;
31318 ofl <<
" endloop" << endl;
31319 ofl <<
" endfacet" << endl;
31332template <MInt nDim,
class SysEqn>
31333template <
class _, std::enable_if_t<nDim == 3, _*>>
31337 for(
MInt dim = 0; dim < nDim; dim++) {
31338 res[dim] =
a[dim] -
b[dim];
31349template <MInt nDim,
class SysEqn>
31350template <
class _, std::enable_if_t<nDim == 3, _*>>
31354 for(
MInt dim = 0; dim < nDim; dim++) {
31355 res[dim] = s *
a[dim];
31366template <MInt nDim,
class SysEqn>
31367template <
class _, std::enable_if_t<nDim == 3, _*>>
31371 MFloat dummy_1[3] = {0, 0, 0};
31372 MFloat dummy_2[3] = {0, 0, 0};
31373 MFloat dummy_3[3] = {0, 0, 0};
31375 vecSub(
b,
a, dummy_1);
31376 vecSub(c,
a, dummy_2);
31379 std::fill(dummy_1, dummy_1 + 3, 0.0);
31380 centroid = vecScalarMul(F1B3, maia::math::vecAdd<3>(dummy_1,
a,
b, c), centroid);
31392template <MInt nDim,
class SysEqn>
31393template <
class _, std::enable_if_t<nDim == 3, _*>>
31398 computePoly3(
a,
b, c, area, centroid, normal);
31413template <MInt nDim,
class SysEqn>
31414template <
class _, std::enable_if_t<nDim == 3, _*>>
31419 MFloat dummy_1[3] = {0, 0, 0};
31420 MFloat dummy_2[3] = {0, 0, 0};
31423 computeTri(
a,
b, c, &A1, dummy_1, normal);
31424 computeTri(c, d,
a, &A2, dummy_2);
31426 std::fill_n(centroid, 3, 0.0);
31427 maia::math::vecAdd<3>(centroid, vecScalarMul(A1, dummy_1, dummy_1), vecScalarMul(A2, dummy_2, dummy_2));
31428 centroid = vecScalarMul(F1 / *area, centroid, centroid);
31443template <MInt nDim,
class SysEqn>
31444template <
class _, std::enable_if_t<nDim == 3, _*>>
31449 MFloat dummy_1[3] = {0, 0, 0};
31450 MFloat dummy_2[3] = {0, 0, 0};
31451 MFloat dummy_3[3] = {0, 0, 0};
31453 vecSub(
b,
a, dummy_1);
31454 vecSub(c,
a, dummy_2);
31457 normal = vecScalarMul(-F1B2 / *area, dummy_3, normal);
31458 std::fill_n(dummy_1, 3, 0.0);
31459 centroid = vecScalarMul(F1B3, maia::math::vecAdd<3>(dummy_1,
a,
b, c), centroid);
31474template <MInt nDim,
class SysEqn>
31475template <
class _, std::enable_if_t<nDim == 3, _*>>
31480 MFloat c_1[3] = {0, 0, 0};
31481 MFloat c_2[3] = {0, 0, 0};
31482 MFloat c_3[3] = {0, 0, 0};
31483 MFloat c_4[3] = {0, 0, 0};
31484 MFloat n_1[3] = {0, 0, 0};
31485 MFloat n_2[3] = {0, 0, 0};
31486 MFloat n_3[3] = {0, 0, 0};
31487 MFloat n_4[3] = {0, 0, 0};
31488 MFloat M[3] = {0, 0, 0};
31491 maia::math::vecAvg<3>(M,
a,
b, c, d);
31492 computePoly3(
a,
b, M, &A1, c_1, n_1);
31493 computePoly3(
b, c, M, &A2, c_2, n_2);
31494 computePoly3(c, d, M, &A3, c_3, n_3);
31495 computePoly3(d,
a, M, &A4, c_4, n_4);
31497 *area = A1 + A2 + A3 + A4;
31498 vecScalarMul(A1, c_1, c_1);
31499 vecScalarMul(A2, c_2, c_2);
31500 vecScalarMul(A3, c_3, c_3);
31501 vecScalarMul(A4, c_4, c_4);
31502 std::fill_n(centroid, 3, 0.0);
31503 centroid = vecScalarMul(F1 / *area, maia::math::vecAdd<3>(centroid, c_1, c_2, c_3, c_4), centroid);
31505 vecScalarMul(A1, n_1, n_1);
31506 vecScalarMul(A2, n_2, n_2);
31507 vecScalarMul(A3, n_3, n_3);
31508 vecScalarMul(A4, n_4, n_4);
31509 std::fill_n(normal, 3, 0.0);
31510 normal = vecScalarMul(F1 / *area, maia::math::vecAdd<3>(normal, n_1, n_2, n_3, n_4), normal);
31525template <MInt nDim,
class SysEqn>
31526template <
class _, std::enable_if_t<nDim == 3, _*>>
31531 MFloat c_1[3] = {0, 0, 0};
31532 MFloat c_2[3] = {0, 0, 0};
31533 MFloat c_3[3] = {0, 0, 0};
31534 MFloat c_4[3] = {0, 0, 0};
31535 MFloat c_5[3] = {0, 0, 0};
31536 MFloat n_1[3] = {0, 0, 0};
31537 MFloat n_2[3] = {0, 0, 0};
31538 MFloat n_3[3] = {0, 0, 0};
31539 MFloat n_4[3] = {0, 0, 0};
31540 MFloat n_5[3] = {0, 0, 0};
31541 MFloat M[3] = {0, 0, 0};
31542 MFloat A1, A2, A3, A4, A5;
31544 maia::math::vecAvg<3>(M,
a,
b, c, d, e);
31545 computePoly3(
a,
b, M, &A1, c_1, n_1);
31546 computePoly3(
b, c, M, &A2, c_2, n_2);
31547 computePoly3(c, d, M, &A3, c_3, n_3);
31548 computePoly3(d, e, M, &A4, c_4, n_4);
31549 computePoly3(e,
a, M, &A5, c_5, n_5);
31551 *area = A1 + A2 + A3 + A4 + A5;
31552 vecScalarMul(A1, c_1, c_1);
31553 vecScalarMul(A2, c_2, c_2);
31554 vecScalarMul(A3, c_3, c_3);
31555 vecScalarMul(A4, c_4, c_4);
31556 vecScalarMul(A5, c_5, c_5);
31557 std::fill_n(centroid, 3, 0.0);
31558 centroid = vecScalarMul(F1 / *area, maia::math::vecAdd<3>(centroid, c_1, c_2, c_3, c_4, c_5), centroid);
31560 vecScalarMul(A1, n_1, n_1);
31561 vecScalarMul(A2, n_2, n_2);
31562 vecScalarMul(A3, n_3, n_3);
31563 vecScalarMul(A4, n_4, n_4);
31564 vecScalarMul(A5, n_5, n_5);
31565 std::fill_n(normal, 3, 0.0);
31566 normal = vecScalarMul(F1 / *area, maia::math::vecAdd<3>(normal, n_1, n_2, n_3, n_4, n_5), normal);
31582template <MInt nDim,
class SysEqn>
31583template <
class _, std::enable_if_t<nDim == 3, _*>>
31588 MFloat c_1[3] = {0, 0, 0};
31589 MFloat c_2[3] = {0, 0, 0};
31590 MFloat c_3[3] = {0, 0, 0};
31591 MFloat c_4[3] = {0, 0, 0};
31592 MFloat c_5[3] = {0, 0, 0};
31593 MFloat c_6[3] = {0, 0, 0};
31594 MFloat n_1[3] = {0, 0, 0};
31595 MFloat n_2[3] = {0, 0, 0};
31596 MFloat n_3[3] = {0, 0, 0};
31597 MFloat n_4[3] = {0, 0, 0};
31598 MFloat n_5[3] = {0, 0, 0};
31599 MFloat n_6[3] = {0, 0, 0};
31600 MFloat M[3] = {0, 0, 0};
31601 MFloat A1, A2, A3, A4, A5, A6;
31603 maia::math::vecAvg<3>(M,
a,
b, c, d, e, f);
31604 computePoly3(
a,
b, M, &A1, c_1, n_1);
31605 computePoly3(
b, c, M, &A2, c_2, n_2);
31606 computePoly3(c, d, M, &A3, c_3, n_3);
31607 computePoly3(d, e, M, &A4, c_4, n_4);
31608 computePoly3(e, f, M, &A5, c_5, n_5);
31609 computePoly3(f,
a, M, &A6, c_6, n_6);
31611 *area = A1 + A2 + A3 + A4 + A5 + A6;
31612 vecScalarMul(A1, c_1, c_1);
31613 vecScalarMul(A2, c_2, c_2);
31614 vecScalarMul(A3, c_3, c_3);
31615 vecScalarMul(A4, c_4, c_4);
31616 vecScalarMul(A5, c_5, c_5);
31617 vecScalarMul(A6, c_6, c_6);
31618 std::fill_n(centroid, 3, 0.0);
31619 centroid = vecScalarMul(F1 / *area, maia::math::vecAdd<3>(centroid, c_1, c_2, c_3, c_4, c_5, c_6), centroid);
31621 vecScalarMul(A1, n_1, n_1);
31622 vecScalarMul(A2, n_2, n_2);
31623 vecScalarMul(A3, n_3, n_3);
31624 vecScalarMul(A4, n_4, n_4);
31625 vecScalarMul(A5, n_5, n_5);
31626 vecScalarMul(A6, n_6, n_6);
31627 std::fill_n(normal, 3, 0.0);
31628 normal = vecScalarMul(F1 / *area, maia::math::vecAdd<3>(normal, n_1, n_2, n_3, n_4, n_5, n_6), normal);
31638template <MInt nDim,
class SysEqn>
31639template <
class _, std::enable_if_t<nDim == 3, _*>>
31644 MFloat dummy_1[3] = {0, 0, 0};
31645 MFloat dummy_2[3] = {0, 0, 0};
31646 MFloat dummy_3[3] = {0, 0, 0};
31647 MFloat dummy_4[3] = {0, 0, 0};
31649 vecSub(
b,
a, dummy_1);
31650 vecSub(c,
a, dummy_2);
31651 vecSub(d,
a, dummy_3);
31654 *volume = F1B6 * abs(inner_product(dummy_4, dummy_4 + 3, dummy_3, 0.0));
31655 std::fill_n(dummy_4, 3, 0.0);
31656 centroid = vecScalarMul(F1B4, maia::math::vecAdd<3>(dummy_4,
a,
b, c, d), centroid);
31666template <MInt nDim,
class SysEqn>
31667template <
class _, std::enable_if_t<nDim == 3, _*>>
31672 MFloat h_vec[3] = {0, 0, 0};
31673 MFloat dummy_2[3] = {0, 0, 0};
31675 vecSub(M, base_centroid, h_vec);
31676 std::fill_n(centroid, 3, 0.0);
31677 centroid = maia::math::vecAdd<3>(centroid, vecScalarMul(F1B4, h_vec, dummy_2), base_centroid);
31678 *volume = F1B3 * (*area) * abs(inner_product(h_vec, h_vec + 3, normal, 0.0));
31693template <MInt nDim,
class SysEqn>
31694template <
class _, std::enable_if_t<nDim == 3, _*>>
31698 MFloat dummy_1[3] = {0, 0, 0};
31699 MFloat dummy_2[3] = {0, 0, 0};
31700 vecSub(vecScalarMul(*area_0, centroid_0, dummy_1), vecScalarMul(*area, centroid, dummy_2), centroid);
31701 *area = *area_0 - *area;
31702 vecScalarMul(F1 / *area, centroid, centroid);
31717template <MInt nDim,
class SysEqn>
31718template <
class _, std::enable_if_t<nDim == 3, _*>>
31722 MFloat dummy_1[3] = {0, 0, 0};
31723 MFloat dummy_2[3] = {0, 0, 0};
31724 vecSub(vecScalarMul(*volume_0, centroid_0, dummy_1), vecScalarMul(*volume, centroid, dummy_2), centroid);
31725 *volume = *volume_0 - *volume;
31726 vecScalarMul(F1 / *volume, centroid, centroid);
31736template <MInt nDim,
class SysEqn>
31737template <
class _, std::enable_if_t<nDim == 3, _*>>
31741 vecScalarMul(-F1, normal, normal);
31761template <MInt nDim,
class SysEqn>
31762template <
class _, std::enable_if_t<nDim == 3, _*>>
31766 static constexpr MInt edgeCode[24] = {8, 10, 0, 4, 9, 11, 1, 5, 2, 6, 8, 9, 3, 7, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7};
31767 static constexpr MInt faceCode[24] = {0, 4, 1, 4, 2, 4, 3, 4, 0, 5, 1, 5, 2, 5, 3, 5, 0, 2, 1, 2, 0, 3, 1, 3};
31768 static constexpr MInt cornerIndices[8][3] = {{-1, -1, -1}, {1, -1, -1}, {-1, 1, -1}, {1, 1, -1},
31769 {-1, -1, 1}, {1, -1, 1}, {-1, 1, 1}, {1, 1, 1}};
31770 static constexpr MInt cornersMCtoSOLVER[8] = {2, 0, 1, 3, 6, 4, 5, 7};
31771 static constexpr MInt cornersSOLVERtoMC[8] = {1, 2, 0, 3, 5, 6, 4, 7};
31772 static constexpr MInt edgesMCtoSOLVER[12] = {0, 2, 1, 3, 4, 6, 5, 7, 10, 8, 9, 11};
31773 static constexpr MInt facesMCtoSOLVER[6] = {0, 2, 1, 3, 4, 5};
31774 MFloat target[6] = {0, 0, 0, 0, 0, 0};
31775 unsigned char outcode_MC = 0;
31776 MInt noCells = m_bndryCells->size();
31779 MFloat corner[8][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
31781 MBool currentOutcode =
false;
31787 MFloat* faceCentroid[6];
31789 for(
MInt i = 0; i < 6; i++)
31790 faceCentroid[i] = &faceCentroid_scratch.p[i * nDim];
31791 MFloat* faceCentroid_0[6];
31793 for(
MInt i = 0; i < 6; i++)
31794 faceCentroid_0[i] = &faceCentroid_0_scratch.
p[i * nDim];
31797 for(
MInt i = 0; i < 6; i++)
31798 normal[i] = &normal_scratch.
p[i * nDim];
31799 const MInt maxNoPyramids = 8;
31800 MFloat* pyraCentroid[maxNoPyramids];
31801 MFloatScratchSpace pyraCentroid_scratch(nDim * maxNoPyramids, AT_,
"pyraCentroid_scratch");
31802 for(
MInt i = 0; i < maxNoPyramids; i++)
31803 pyraCentroid[i] = &pyraCentroid_scratch.
p[i * nDim];
31806 MFloatScratchSpace faceVolume_0_scratch(F2 * m_noDirs, AT_,
"faceVolume_0_scratch");
31807 MFloat* faceVolume = faceVolume_scratch.getPointer();
31808 MFloat* pyraVolume = pyraVolume_scratch.getPointer();
31809 MFloat* faceVolume_0 = faceVolume_0_scratch.getPointer();
31810 MInt currentSubCase;
31830 MInt* facepointers[6] = {&face1, &face2, &face3, &face4, &face5, &face6};
31831 MInt cutPoints[12] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
31833 MFloat* normalVec_c = normalVec_c_scratch.getPointer();
31836 MFloat* coordinates_c = coordinates_c_scratch.getPointer();
31839 MFloat* coordinates_Cell = coordinates_Cell_scratch.getPointer();
31840 MFloat M[3] = {0, 0, 0};
31841 MFloat dummy_1[3] = {0, 0, 0};
31842 MFloat dummy_2[3] = {0, 0, 0};
31843 MFloat dummy_3[3] = {0, 0, 0};
31844 MBool nfs_cur[6] = {
false,
false,
false,
false,
false,
false};
31846 MBool cornerCell =
false;
31848 MFloat normalEps = 1e-4;
31849 const MInt maxNoEdges = 800;
31851 MFloat** featureEdges = featureEdges_scratch.getPointer();
31852 const MInt maxNoIntersectPointsPerFace = 10;
31855 "intersectionPoints_scratchP");
31856 MFloatScratchSpace intersectionPoints_scratch(2 * nDim * maxNoIntersectPointsPerFace * nDim, AT_,
31857 "intersectionPoints_scratch");
31858 MFloat*** intersectionPoints = intersectionPoints_scratchPP.getPointer();
31859 for(
MInt i = 0; i < 2 * nDim; i++) {
31860 intersectionPoints[i] = &intersectionPoints_scratchP.p[i * maxNoIntersectPointsPerFace];
31861 for(
MInt j = 0; j < maxNoIntersectPointsPerFace; j++) {
31862 intersectionPoints[i][j] = &intersectionPoints_scratch.p[i * maxNoIntersectPointsPerFace * nDim + j * nDim];
31865 MInt noWallNodes, noInflowNodes, noFeatureEdges;
31866 MInt noIntersectionPoints[6] = {0, 0, 0, 0, 0, 0};
31867 const MInt maxNoNodes =
31870 MIntScratchSpace inflowNodes_scratch(maxNoNodes, AT_,
"inflowNodes_scratch");
31871 MInt* wallNodes = wallNodes_scratch.getPointer();
31872 MInt* inflowNodes = inflowNodes_scratch.getPointer();
31874 MFloat** target2 = target2_scratchP.getPointer();
31876 for(
MInt i = 0; i < nDim; i++)
31877 target2[i] = &target2_scratch.p[i * nDim];
31878 MInt index1, index2, index3;
31880 MInt pointIndices[2] = {0, 0};
31890 MInt* facePoints = facePoints_scratch.getPointer();
31893 for(
MInt i = 0; i < 6; i++) {
31894 points[i] = &points_scratch.p[i * nDim];
31897 MInt* nextFaces = nextFaces_scratch.getPointer();
31903 MFloat* normal1 = normal1_scratch.getPointer();
31904 MFloat* normal2 = normal2_scratch.getPointer();
31905 MFloat* centroid1 = centroid1_scratch.getPointer();
31906 MFloat* centroid2 = centroid2_scratch.getPointer();
31911 MInt noUnusedCutPoints;
31912 MIntScratchSpace unusedCutPoints_scratch(2, AT_,
"unusedCutPoints_scratch");
31913 MInt* unusedCutPoints = unusedCutPoints_scratch.getPointer();
31914 MInt& iter = m_static_correctInflowBoundary_iter;
31915 stringstream fileName2;
31916 fileName2 <<
"cutSurface_newParts" << domainId() <<
"_" << iter++ <<
".stl";
31918 ofl.open((fileName2.str()).c_str(), ofstream::trunc);
31919 MBool secondHalf =
false;
31920 MInt cutEdge, cutEdgeNghbr;
31921 MInt cutFace1, cutFace2, cutFaceNghbr1, cutFaceNghbr2;
31924 MBool inside =
true;
31930 ofl.setf(ios::fixed);
31933 ofl <<
"solid cutsurface " << endl;
31938 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
31939 noUnusedCutPoints = 0;
31940 cornerCell =
false;
31941 cellId = m_bndryCells->a[bndryId].m_cellId;
31942 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
31943 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
31944 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == bcId) {
31945 normalDiff =
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[0] - meanNormal[0])
31946 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[1] - meanNormal[1])
31947 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[2] - meanNormal[2]);
31948 if(normalDiff > normalEps) {
31957 gridCellVolume = m_solver->grid().gridCellVolume(m_solver->a_level(cellId));
31960 coordinates_Cell[0] = 0;
31961 coordinates_Cell[1] = 0;
31962 coordinates_Cell[2] = 0;
31965 for(
MInt cutPoint = 0; cutPoint < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cutPoint++) {
31966 cutPoints[m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cutPoint]] = cutPoint;
31969 for(
MInt i = 0; i < nDim; i++) {
31970 target[i] = m_solver->a_coordinate(cellId, i)
31971 - F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId)) * 1.05;
31972 target[i + nDim] = m_solver->a_coordinate(cellId, i)
31973 + F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId)) * 1.05;
31974 faceVolume[2 * i] =
POW2(m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId)));
31975 faceVolume[2 * i + 1] = faceVolume[2 * i];
31976 for(
MInt j = 0; j < 3; j++) {
31977 faceCentroid[2 * i][j] = m_solver->a_coordinate(cellId, j);
31978 faceCentroid[2 * i + 1][j] = m_solver->a_coordinate(cellId, j);
31980 faceCentroid[2 * i][i] -= F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
31981 faceCentroid[2 * i + 1][i] += F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
31985 std::vector<MInt> nodeList;
31986 m_solver->m_geometry->getIntersectionElements(target, nodeList);
31987 const MInt noNodes = nodeList.size();
31988 if(noNodes > maxNoNodes) {
31989 stringstream errorMessage;
31990 errorMessage <<
"Error in FvBndryCndXD::correctInflowBoundary - noNodes = " << noNodes
31991 <<
" > maxNoNodes = " << maxNoNodes <<
". Please increase maxNoNodes! ";
31992 mTerm(1, AT_, errorMessage.str());
31998 for(
MInt j = 0; j < 8; j++) {
31999 for(
MInt dim = 0; dim < nDim; dim++) {
32000 corner[j][dim] = m_solver->a_coordinate(cellId, dim)
32001 + cornerIndices[j][dim] * F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
32003 currentOutcode = !((
MBool)m_solver->m_geometry->pointIsInside2(corner[j]));
32004 if(currentOutcode) outcode_MC = outcode_MC | (1 << cornersSOLVERtoMC[j]);
32008 currentCase = (
MInt)cases[outcode_MC][0];
32009 currentSubCase = (
MInt)cases[outcode_MC][1];
32010 if(!(m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints == caseCutPoints[currentCase])) {
32011 cerr <<
"FvBndryCndXD::correctInflowBoundary: Detected special inlet correction cell! cellId " <<
cellId
32012 <<
", bndryId: " << bndryId <<
" cutPointsTheory: " << caseCutPoints[currentCase]
32013 <<
" actual Cut Points: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints
32014 <<
" case: " << currentCase << endl;
32016 if(!caseStatesSTL[currentCase][0]) {
32017 cerr <<
"FvBndryCndXD::correctInflowBoundary - Error: Case not implemented: " << currentCase << endl;
32023 getSortedElements(nodeList, noWallNodes, wallNodes, noInflowNodes, inflowNodes, bcId);
32024 if(noWallNodes > 0)
32025 bcWall = m_solver->m_geometry->elements[wallNodes[0]].m_bndCndId;
32027 stringstream fileName;
32028 fileName <<
cellId <<
".stl";
32029 writeStlFileOfCell(cellId, (fileName.str()).c_str());
32030 plotEdges(noFeatureEdges, featureEdges);
32031 plotIntersectionPoints(noIntersectionPoints, intersectionPoints);
32032 stringstream errorMessage;
32033 errorMessage <<
"cell " <<
cellId <<
" has no wall nodes!";
32034 mTerm(1, AT_, errorMessage.str());
32037 if(noInflowNodes > 0)
32038 bcInlet = m_solver->m_geometry->elements[inflowNodes[0]].m_bndCndId;
32040 stringstream errorMessage;
32041 errorMessage <<
" cell " <<
cellId <<
" has no inflow nodes!";
32042 mTerm(1, AT_, errorMessage.str());
32046 getFeatureEdges(noFeatureEdges, featureEdges, noWallNodes, wallNodes, meanNormal, basePoint);
32049 for(
MInt face = 0; face < 6; face++) {
32051 index2 = (index1 + 1) % 3;
32052 index3 = (index2 + 1) % 3;
32053 for(
MInt i = 0; i < 3; i++)
32054 for(
MInt j = 0; j < 3; j++)
32055 target2[i][j] = faceCentroid[face][j];
32057 target2[0][index2] -= F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
32058 target2[0][index3] -= F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
32059 target2[1][index2] += F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
32060 target2[1][index3] -= F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
32061 target2[2][index2] -= F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
32062 target2[2][index3] += F1B2 * m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId));
32065 getIntersectionPoints(target2, featureEdges, noFeatureEdges, (
MInt)(face / 2), intersectionPoints[face],
32066 noIntersectionPoints[face]);
32070 if(!caseStatesSTL[currentCase][1]) {
32071 stringstream errorMessage;
32072 errorMessage <<
" Case " << currentCase <<
" not allowed for Inflow/Outflow boundary correction!";
32073 mTerm(1, AT_, errorMessage.str());
32075 m_bndryCells->a[bndryId].m_noSrfcs = 1;
32076 secondHalf =
false;
32077 switch(currentCase) {
32079 cerr <<
"FvBndryCndXD::correctInflowBoundary - Error: Cell is not a boundary cell!" << endl;
32080 cerr <<
"CellId: " <<
cellId <<
" BndryId: " << bndryId << endl;
32084 for(
MInt face = 0; face < 6; face++) {
32085 nfs_cur[face] = nfs1[currentSubCase][face];
32087 p_0 = corner[cornersMCtoSOLVER[tiling1STL[currentSubCase][0]]];
32089 if(currentSubCase < 8) {
32091 for(
MInt i = 0; i < 6; i++) {
32092 faceVolume_0[i] = faceVolume[i];
32093 for(
MInt j = 0; j < 3; j++) {
32094 faceCentroid_0[i][j] = faceCentroid[i][j];
32098 cutDummy = edgesMCtoSOLVER[tiling1STL[currentSubCase][1]];
32099 p_1 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32100 cutDummy = edgesMCtoSOLVER[tiling1STL[currentSubCase][2]];
32101 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32102 cutDummy = edgesMCtoSOLVER[tiling1STL[currentSubCase][3]];
32103 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32104 face1 = facesMCtoSOLVER[tiling1STL[currentSubCase][4]];
32105 face2 = facesMCtoSOLVER[tiling1STL[currentSubCase][5]];
32106 face3 = facesMCtoSOLVER[tiling1STL[currentSubCase][6]];
32109 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
32110 if(p_1 == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32111 || p_2 == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32112 || p_3 == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]) {
32115 unusedCutPoints[noUnusedCutPoints++] = cp;
32119 for(
MInt face = 0; face < noFaces; face++) {
32120 facePoints[face] = -1;
32121 facePoints[2 * face] = -1;
32122 nextFaces[face] = -1;
32124 nextFaces[face1] = face3;
32125 nextFaces[face2] = face1;
32126 nextFaces[face3] = face2;
32127 facePoints[2 * face1] = 2;
32128 facePoints[2 * face1 + 1] = 0;
32129 facePoints[2 * face2] = 1;
32130 facePoints[2 * face2 + 1] = 2;
32131 facePoints[2 * face3] = 0;
32132 facePoints[2 * face3 + 1] = 1;
32133 for(
MInt i = 0; i < 3; i++) {
32134 points[0][i] = p_1[i];
32135 points[1][i] = p_2[i];
32136 points[2][i] = p_3[i];
32139 computeTri(p_0, p_1, p_3, &faceVolume[face1], faceCentroid[face1], normal[face1]);
32140 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2], normal[face2]);
32141 computeTri(p_0, p_2, p_1, &faceVolume[face3], faceCentroid[face3], normal[face3]);
32143 computePoly3(p_1, p_2, p_3, &area_c, coordinates_c, normalVec_c);
32145 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_3);
32147 computeTetra(p_0, p_1, p_2, p_3, &volume_C, coordinates_Cell);
32149 if(currentSubCase >= 8) {
32153 m_bndryCells->a[bndryId].m_volume = volume_C;
32155 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
32156 for(
MInt dim = 0; dim < 3; dim++) {
32157 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
32158 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
32159 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
32164 for(
MInt face = 0; face < 6; face++) {
32165 nfs_cur[face] = nfs2[currentSubCase][face];
32168 p_0 = corner[cornersMCtoSOLVER[tiling2STL[currentSubCase][0]]];
32169 p_0s = corner[cornersMCtoSOLVER[tiling2STL[currentSubCase][1]]];
32170 if(currentSubCase < 12) {
32172 for(
MInt i = 0; i < 6; i++) {
32173 faceVolume_0[i] = faceVolume[i];
32174 for(
MInt j = 0; j < 3; j++) {
32175 faceCentroid_0[i][j] = faceCentroid[i][j];
32180 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][2]];
32181 p_3 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32182 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][3]];
32183 p_2 = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32184 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][4]];
32185 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32186 cutDummy = edgesMCtoSOLVER[tiling2STL[currentSubCase][5]];
32187 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32188 face1 = facesMCtoSOLVER[tiling2STL[currentSubCase][6]];
32189 face2 = facesMCtoSOLVER[tiling2STL[currentSubCase][7]];
32190 face3 = facesMCtoSOLVER[tiling2STL[currentSubCase][8]];
32191 face4 = facesMCtoSOLVER[tiling2STL[currentSubCase][9]];
32194 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
32195 if(p_3 == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32196 || p_2 == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32197 || p_3s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32198 || p_2s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]) {
32201 unusedCutPoints[noUnusedCutPoints++] = cp;
32205 for(
MInt face = 0; face < noFaces; face++) {
32206 facePoints[face] = -1;
32207 facePoints[2 * face] = -1;
32208 nextFaces[face] = -1;
32210 nextFaces[face1] = face3;
32211 nextFaces[face2] = face1;
32212 nextFaces[face3] = face4;
32213 nextFaces[face4] = face2;
32214 facePoints[2 * face1] = 0;
32215 facePoints[2 * face1 + 1] = 1;
32216 facePoints[2 * face2] = 3;
32217 facePoints[2 * face2 + 1] = 0;
32218 facePoints[2 * face3] = 1;
32219 facePoints[2 * face3 + 1] = 2;
32220 facePoints[2 * face4] = 2;
32221 facePoints[2 * face4 + 1] = 3;
32222 for(
MInt i = 0; i < 3; i++) {
32223 points[0][i] = p_3[i];
32224 points[1][i] = p_3s[i];
32225 points[2][i] = p_2s[i];
32226 points[3][i] = p_2[i];
32229 computeTri(p_0, p_3, p_2, &faceVolume[face2], faceCentroid[face2], normal[face2]);
32230 computeTri(p_0s, p_3s, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
32231 computeTrapez(p_0, p_0s, p_3s, p_3, &faceVolume[face1], faceCentroid[face1], normal[face1]);
32232 computeTrapez(p_2, p_2s, p_0s, p_0, &faceVolume[face4], faceCentroid[face4], normal[face4]);
32234 computePoly4(p_3, p_3s, p_2s, p_2, &area_c, coordinates_c, normalVec_c);
32236 maia::math::vecAvg<3>(M, p_0, p_0s, p_2, p_2s, p_3, p_3s);
32238 for(
MInt i = 0; i < 4; i++) {
32239 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
32240 &pyraVolume[i], pyraCentroid[i]);
32242 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[4], pyraCentroid[4]);
32243 for(
MInt i = 0; i < 5; i++) {
32244 volume_C += pyraVolume[i];
32245 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
32247 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
32249 if(currentSubCase >= 12) {
32253 m_bndryCells->a[bndryId].m_volume = volume_C;
32255 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
32256 for(
MInt dim = 0; dim < 3; dim++) {
32257 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
32258 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
32259 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
32264 for(
MInt face = 0; face < 6; face++) {
32265 nfs_cur[face] = nfs5[currentSubCase][face];
32268 p_0 = corner[cornersMCtoSOLVER[tiling5STL[currentSubCase][0]]];
32269 p_1 = corner[cornersMCtoSOLVER[tiling5STL[currentSubCase][1]]];
32270 p_2 = corner[cornersMCtoSOLVER[tiling5STL[currentSubCase][2]]];
32271 if(currentSubCase < 24) {
32273 for(
MInt i = 0; i < 6; i++) {
32274 faceVolume_0[i] = faceVolume[i];
32275 for(
MInt j = 0; j < 3; j++) {
32276 faceCentroid_0[i][j] = faceCentroid[i][j];
32281 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][3]];
32282 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32283 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][4]];
32284 p_0ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32285 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][5]];
32286 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32287 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][6]];
32288 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32289 cutDummy = edgesMCtoSOLVER[tiling5STL[currentSubCase][7]];
32290 p_2ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32291 face1 = facesMCtoSOLVER[tiling5STL[currentSubCase][8]];
32292 face2 = facesMCtoSOLVER[tiling5STL[currentSubCase][9]];
32293 face3 = facesMCtoSOLVER[tiling5STL[currentSubCase][10]];
32294 face4 = facesMCtoSOLVER[tiling5STL[currentSubCase][11]];
32295 face5 = facesMCtoSOLVER[tiling5STL[currentSubCase][12]];
32298 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
32299 if(p_0s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32300 || p_0ss == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32301 || p_1s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32302 || p_2s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32303 || p_2ss == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]) {
32306 unusedCutPoints[noUnusedCutPoints++] = cp;
32310 for(
MInt face = 0; face < noFaces; face++) {
32311 facePoints[face] = -1;
32312 facePoints[2 * face] = -1;
32313 nextFaces[face] = -1;
32315 nextFaces[face1] = face2;
32316 nextFaces[face2] = face3;
32317 nextFaces[face3] = face4;
32318 nextFaces[face4] = face5;
32319 nextFaces[face5] = face1;
32320 facePoints[2 * face1] = 3;
32321 facePoints[2 * face1 + 1] = 4;
32322 facePoints[2 * face2] = 4;
32323 facePoints[2 * face2 + 1] = 0;
32324 facePoints[2 * face3] = 0;
32325 facePoints[2 * face3 + 1] = 1;
32326 facePoints[2 * face4] = 1;
32327 facePoints[2 * face4 + 1] = 2;
32328 facePoints[2 * face5] = 2;
32329 facePoints[2 * face5 + 1] = 3;
32330 for(
MInt i = 0; i < 3; i++) {
32331 points[0][i] = p_0s[i];
32332 points[1][i] = p_1s[i];
32333 points[2][i] = p_2s[i];
32334 points[3][i] = p_2ss[i];
32335 points[4][i] = p_0ss[i];
32338 computePoly5(p_0, p_0ss, p_2ss, p_2, p_1, &faceVolume[face1], faceCentroid[face1], normal[face1]);
32339 computeTri(p_0ss, p_0, p_0s, &faceVolume[face2], faceCentroid[face2], normal[face2]);
32340 computeTrapez(p_0, p_1, p_1s, p_0s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
32341 computeTrapez(p_1, p_1s, p_2s, p_2, &faceVolume[face4], faceCentroid[face4], normal[face4]);
32342 computeTri(p_2s, p_2, p_2ss, &faceVolume[face5], faceCentroid[face5], normal[face5]);
32344 computePoly5(p_0s, p_1s, p_2s, p_2ss, p_0ss, &area_c, coordinates_c, normalVec_c);
32346 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_0s, p_1s, p_2s, p_0ss, p_2ss);
32348 for(
MInt i = 0; i < 5; i++) {
32349 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
32350 &pyraVolume[i], pyraCentroid[i]);
32352 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[5], pyraCentroid[5]);
32353 for(
MInt i = 0; i < 6; i++) {
32354 volume_C += pyraVolume[i];
32355 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
32357 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
32359 if(currentSubCase >= 24) {
32363 m_bndryCells->a[bndryId].m_volume = volume_C;
32365 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
32366 for(
MInt dim = 0; dim < 3; dim++) {
32367 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
32368 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
32369 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
32374 for(
MInt face = 0; face < 6; face++) {
32375 nfs_cur[face] = nfs8[currentSubCase][face];
32378 p_0 = corner[cornersMCtoSOLVER[tiling8STL[currentSubCase][0]]];
32379 p_1 = corner[cornersMCtoSOLVER[tiling8STL[currentSubCase][1]]];
32380 p_2 = corner[cornersMCtoSOLVER[tiling8STL[currentSubCase][2]]];
32381 p_3 = corner[cornersMCtoSOLVER[tiling8STL[currentSubCase][3]]];
32383 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][4]];
32384 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32385 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][5]];
32386 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32387 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][6]];
32388 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32389 cutDummy = edgesMCtoSOLVER[tiling8STL[currentSubCase][7]];
32390 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32391 face5 = facesMCtoSOLVER[tiling8STL[currentSubCase][8]];
32392 face1 = facesMCtoSOLVER[tiling8STL[currentSubCase][9]];
32393 face2 = facesMCtoSOLVER[tiling8STL[currentSubCase][10]];
32394 face3 = facesMCtoSOLVER[tiling8STL[currentSubCase][11]];
32395 face4 = facesMCtoSOLVER[tiling8STL[currentSubCase][12]];
32398 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
32399 if(p_0s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32400 || p_1s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32401 || p_2s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32402 || p_3s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]) {
32405 unusedCutPoints[noUnusedCutPoints++] = cp;
32409 for(
MInt face = 0; face < noFaces; face++) {
32410 facePoints[face] = -1;
32411 facePoints[2 * face] = -1;
32412 nextFaces[face] = -1;
32414 nextFaces[face1] = face2;
32415 nextFaces[face2] = face3;
32416 nextFaces[face3] = face4;
32417 nextFaces[face4] = face1;
32418 facePoints[2 * face1] = 0;
32419 facePoints[2 * face1 + 1] = 1;
32420 facePoints[2 * face2] = 1;
32421 facePoints[2 * face2 + 1] = 2;
32422 facePoints[2 * face3] = 2;
32423 facePoints[2 * face3 + 1] = 3;
32424 facePoints[2 * face4] = 3;
32425 facePoints[2 * face4 + 1] = 0;
32426 for(
MInt i = 0; i < 3; i++) {
32427 points[0][i] = p_0s[i];
32428 points[1][i] = p_1s[i];
32429 points[2][i] = p_2s[i];
32430 points[3][i] = p_3s[i];
32433 computeTrapez(p_0, p_1, p_1s, p_0s, &faceVolume[face1], faceCentroid[face1], normal[face1]);
32434 computeTrapez(p_1, p_2, p_2s, p_1s, &faceVolume[face2], faceCentroid[face2], normal[face2]);
32435 computeTrapez(p_2, p_3, p_3s, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
32436 computeTrapez(p_3, p_0, p_0s, p_3s, &faceVolume[face4], faceCentroid[face4], normal[face4]);
32438 computeTrapez(p_0, p_3, p_2, p_1, &faceVolume[face5], faceCentroid[face5], normal[face5]);
32440 computePoly4(p_0s, p_1s, p_2s, p_3s, &area_c, coordinates_c, normalVec_c);
32442 maia::math::vecAvg<3>(M, p_0, p_0s, p_1, p_1s, p_2, p_2s, p_3, p_3s);
32444 for(
MInt i = 0; i < 5; i++) {
32445 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
32446 &pyraVolume[i], pyraCentroid[i]);
32448 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[5], pyraCentroid[5]);
32449 for(
MInt i = 0; i < 6; i++) {
32450 volume_C += pyraVolume[i];
32451 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
32453 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
32455 m_bndryCells->a[bndryId].m_volume = volume_C;
32458 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
32459 for(
MInt dim = 0; dim < 3; dim++) {
32460 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
32461 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
32462 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
32467 for(
MInt face = 0; face < 6; face++) {
32468 nfs_cur[face] = nfs9[currentSubCase][face];
32471 p_0 = corner[cornersMCtoSOLVER[tiling9STL[currentSubCase][0]]];
32472 p_1 = corner[cornersMCtoSOLVER[tiling9STL[currentSubCase][1]]];
32473 p_2 = corner[cornersMCtoSOLVER[tiling9STL[currentSubCase][2]]];
32474 p_3 = corner[cornersMCtoSOLVER[tiling9STL[currentSubCase][3]]];
32476 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][4]];
32477 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32478 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][5]];
32479 p_1ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32480 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][6]];
32481 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32482 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][7]];
32483 p_2ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32484 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][8]];
32485 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32486 cutDummy = edgesMCtoSOLVER[tiling9STL[currentSubCase][9]];
32487 p_3ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32490 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
32491 if(p_1ss == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32492 || p_1s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32493 || p_2s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32494 || p_2ss == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32495 || p_3s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32496 || p_3ss == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]) {
32499 unusedCutPoints[noUnusedCutPoints++] = cp;
32502 face1 = facesMCtoSOLVER[tiling9STL[currentSubCase][10]];
32503 face2 = facesMCtoSOLVER[tiling9STL[currentSubCase][11]];
32504 face3 = facesMCtoSOLVER[tiling9STL[currentSubCase][12]];
32505 face4 = facesMCtoSOLVER[tiling9STL[currentSubCase][13]];
32506 face5 = facesMCtoSOLVER[tiling9STL[currentSubCase][14]];
32507 face6 = facesMCtoSOLVER[tiling9STL[currentSubCase][15]];
32509 for(
MInt face = 0; face < noFaces; face++) {
32510 facePoints[face] = -1;
32511 facePoints[2 * face] = -1;
32512 nextFaces[face] = -1;
32514 nextFaces[face1] = face6;
32515 nextFaces[face2] = face5;
32516 nextFaces[face3] = face2;
32517 nextFaces[face4] = face1;
32518 nextFaces[face5] = face4;
32519 nextFaces[face6] = face3;
32520 facePoints[2 * face1] = 3;
32521 facePoints[2 * face1 + 1] = 4;
32522 facePoints[2 * face2] = 0;
32523 facePoints[2 * face2 + 1] = 1;
32524 facePoints[2 * face3] = 5;
32525 facePoints[2 * face3 + 1] = 0;
32526 facePoints[2 * face4] = 2;
32527 facePoints[2 * face4 + 1] = 3;
32528 facePoints[2 * face5] = 1;
32529 facePoints[2 * face5 + 1] = 2;
32530 facePoints[2 * face6] = 4;
32531 facePoints[2 * face6 + 1] = 5;
32532 for(
MInt i = 0; i < 3; i++) {
32533 points[0][i] = p_1ss[i];
32534 points[1][i] = p_1s[i];
32535 points[2][i] = p_2ss[i];
32536 points[3][i] = p_2s[i];
32537 points[4][i] = p_3ss[i];
32538 points[5][i] = p_3s[i];
32541 computePoly5(p_0, p_3, p_3ss, p_2s, p_2, &faceVolume[face1], faceCentroid[face1], normal[face1]);
32542 computePoly5(p_0, p_1, p_1ss, p_3s, p_3, &faceVolume[face3], faceCentroid[face3], normal[face3]);
32543 computePoly5(p_0, p_2, p_2ss, p_1s, p_1, &faceVolume[face5], faceCentroid[face5], normal[face5]);
32544 computeTri(p_1, p_1s, p_1ss, &faceVolume[face2], faceCentroid[face2], normal[face2]);
32545 computeTri(p_2, p_2s, p_2ss, &faceVolume[face4], faceCentroid[face4], normal[face4]);
32546 computeTri(p_3, p_3s, p_3ss, &faceVolume[face6], faceCentroid[face6], normal[face6]);
32548 computePoly6(p_1ss, p_1s, p_2ss, p_2s, p_3ss, p_3s, &area_c, coordinates_c, normalVec_c);
32550 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_3, p_1s, p_2s, p_3s, p_1ss, p_2ss, p_3ss);
32552 for(
MInt i = 0; i < 6; i++) {
32553 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
32554 &pyraVolume[i], pyraCentroid[i]);
32556 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[6], pyraCentroid[6]);
32557 for(
MInt i = 0; i < 7; i++) {
32558 volume_C += pyraVolume[i];
32559 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
32561 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
32563 m_bndryCells->a[bndryId].m_volume = volume_C;
32565 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
32566 for(
MInt dim = 0; dim < 3; dim++) {
32567 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
32568 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
32569 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
32576 for(
MInt face = 0; face < 6; face++) {
32577 nfs_cur[face] = nfs11[currentSubCase][face];
32580 p_0 = corner[cornersMCtoSOLVER[tiling11STL[currentSubCase][0]]];
32581 p_1 = corner[cornersMCtoSOLVER[tiling11STL[currentSubCase][1]]];
32582 p_2 = corner[cornersMCtoSOLVER[tiling11STL[currentSubCase][2]]];
32583 p_3 = corner[cornersMCtoSOLVER[tiling11STL[currentSubCase][3]]];
32585 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][4]];
32586 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32587 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][5]];
32588 p_0ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32589 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][6]];
32590 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32591 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][7]];
32592 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32593 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][8]];
32594 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32595 cutDummy = edgesMCtoSOLVER[tiling11STL[currentSubCase][9]];
32596 p_3ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32597 face1 = facesMCtoSOLVER[tiling11STL[currentSubCase][10]];
32598 face2 = facesMCtoSOLVER[tiling11STL[currentSubCase][11]];
32599 face3 = facesMCtoSOLVER[tiling11STL[currentSubCase][12]];
32600 face4 = facesMCtoSOLVER[tiling11STL[currentSubCase][13]];
32601 face5 = facesMCtoSOLVER[tiling11STL[currentSubCase][14]];
32602 face6 = facesMCtoSOLVER[tiling11STL[currentSubCase][15]];
32605 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
32606 if(p_0ss == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32607 || p_0s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32608 || p_1s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32609 || p_2s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32610 || p_3s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32611 || p_3ss == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]) {
32614 unusedCutPoints[noUnusedCutPoints++] = cp;
32618 for(
MInt face = 0; face < noFaces; face++) {
32619 facePoints[face] = -1;
32620 facePoints[2 * face] = -1;
32621 nextFaces[face] = -1;
32623 nextFaces[face1] = face5;
32624 nextFaces[face2] = face4;
32625 nextFaces[face3] = face6;
32626 nextFaces[face4] = face1;
32627 nextFaces[face5] = face3;
32628 nextFaces[face6] = face2;
32629 facePoints[2 * face1] = 0;
32630 facePoints[2 * face1 + 1] = 1;
32631 facePoints[2 * face2] = 4;
32632 facePoints[2 * face2 + 1] = 5;
32633 facePoints[2 * face3] = 2;
32634 facePoints[2 * face3 + 1] = 3;
32635 facePoints[2 * face4] = 5;
32636 facePoints[2 * face4 + 1] = 0;
32637 facePoints[2 * face5] = 1;
32638 facePoints[2 * face5 + 1] = 2;
32639 facePoints[2 * face6] = 3;
32640 facePoints[2 * face6 + 1] = 4;
32641 for(
MInt i = 0; i < 3; i++) {
32642 points[0][i] = p_0ss[i];
32643 points[1][i] = p_0s[i];
32644 points[2][i] = p_2s[i];
32645 points[3][i] = p_3ss[i];
32646 points[4][i] = p_3s[i];
32647 points[5][i] = p_1s[i];
32650 computeTri(p_0, p_0s, p_0ss, &faceVolume[face1], faceCentroid[face1], normal[face1]);
32651 computePoly5(p_3s, p_3, p_2, p_1, p_1s, &faceVolume[face2], faceCentroid[face2], normal[face2]);
32652 computeTrapez(p_2, p_3, p_3ss, p_2s, &faceVolume[face3], faceCentroid[face3], normal[face3]);
32653 computeTrapez(p_1, p_0, p_0ss, p_1s, &faceVolume[face4], faceCentroid[face4], normal[face4]);
32654 computePoly5(p_1, p_2, p_2s, p_0s, p_0, &faceVolume[face5], faceCentroid[face5], normal[face5]);
32655 computeTri(p_3, p_3s, p_3ss, &faceVolume[face6], faceCentroid[face6], normal[face6]);
32657 computePoly6(p_0ss, p_0s, p_2s, p_3ss, p_3s, p_1s, &area_c, coordinates_c, normalVec_c);
32659 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_3, p_0s, p_1s, p_2s, p_3s, p_0ss, p_3ss);
32661 for(
MInt i = 0; i < 6; i++) {
32662 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
32663 &pyraVolume[i], pyraCentroid[i]);
32665 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[6], pyraCentroid[6]);
32666 for(
MInt i = 0; i < 7; i++) {
32667 volume_C += pyraVolume[i];
32668 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
32670 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
32672 m_bndryCells->a[bndryId].m_volume = volume_C;
32674 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
32675 for(
MInt dim = 0; dim < 3; dim++) {
32676 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
32677 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
32678 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
32684 for(
MInt face = 0; face < 6; face++) {
32685 nfs_cur[face] = nfs14[currentSubCase][face];
32688 p_0 = corner[cornersMCtoSOLVER[tiling14STL[currentSubCase][0]]];
32689 p_1 = corner[cornersMCtoSOLVER[tiling14STL[currentSubCase][1]]];
32690 p_2 = corner[cornersMCtoSOLVER[tiling14STL[currentSubCase][2]]];
32691 p_3 = corner[cornersMCtoSOLVER[tiling14STL[currentSubCase][3]]];
32693 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][4]];
32694 p_0s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32695 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][5]];
32696 p_0ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32697 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][6]];
32698 p_1s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32699 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][7]];
32700 p_2s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32701 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][8]];
32702 p_3s = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32703 cutDummy = edgesMCtoSOLVER[tiling14STL[currentSubCase][9]];
32704 p_3ss = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cutPoints[cutDummy]];
32705 face1 = facesMCtoSOLVER[tiling14STL[currentSubCase][10]];
32706 face2 = facesMCtoSOLVER[tiling14STL[currentSubCase][11]];
32707 face3 = facesMCtoSOLVER[tiling14STL[currentSubCase][12]];
32708 face4 = facesMCtoSOLVER[tiling14STL[currentSubCase][13]];
32709 face5 = facesMCtoSOLVER[tiling14STL[currentSubCase][14]];
32710 face6 = facesMCtoSOLVER[tiling14STL[currentSubCase][15]];
32713 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++) {
32714 if(p_0ss == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32715 || p_0s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32716 || p_1s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32717 || p_2s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32718 || p_3s == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]
32719 || p_3ss == m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp]) {
32722 unusedCutPoints[noUnusedCutPoints++] = cp;
32726 for(
MInt face = 0; face < noFaces; face++) {
32727 facePoints[face] = -1;
32728 facePoints[2 * face] = -1;
32729 nextFaces[face] = -1;
32731 nextFaces[face1] = face4;
32732 nextFaces[face2] = face6;
32733 nextFaces[face3] = face5;
32734 nextFaces[face4] = face2;
32735 nextFaces[face5] = face1;
32736 nextFaces[face6] = face3;
32737 facePoints[2 * face1] = 0;
32738 facePoints[2 * face1 + 1] = 1;
32739 facePoints[2 * face2] = 2;
32740 facePoints[2 * face2 + 1] = 3;
32741 facePoints[2 * face3] = 4;
32742 facePoints[2 * face3 + 1] = 5;
32743 facePoints[2 * face4] = 1;
32744 facePoints[2 * face4 + 1] = 2;
32745 facePoints[2 * face5] = 5;
32746 facePoints[2 * face5 + 1] = 0;
32747 facePoints[2 * face6] = 3;
32748 facePoints[2 * face6 + 1] = 4;
32749 for(
MInt i = 0; i < 3; i++) {
32750 points[0][i] = p_0ss[i];
32751 points[1][i] = p_0s[i];
32752 points[2][i] = p_1s[i];
32753 points[3][i] = p_3ss[i];
32754 points[4][i] = p_3s[i];
32755 points[5][i] = p_2s[i];
32758 computeTri(p_0, p_0s, p_0ss, &faceVolume[face1], faceCentroid[face1], normal[face1]);
32759 computePoly5(p_2, p_3, p_3ss, p_1s, p_1, &faceVolume[face2], faceCentroid[face2], normal[face2]);
32760 computeTrapez(p_2s, p_3s, p_3, p_2, &faceVolume[face3], faceCentroid[face3], normal[face3]);
32761 computeTrapez(p_1s, p_0s, p_0, p_1, &faceVolume[face4], faceCentroid[face4], normal[face4]);
32762 computePoly5(p_2, p_1, p_0, p_0ss, p_2s, &faceVolume[face5], faceCentroid[face5], normal[face5]);
32763 computeTri(p_3, p_3s, p_3ss, &faceVolume[face6], faceCentroid[face6], normal[face6]);
32765 computePoly6(p_0ss, p_0s, p_1s, p_3ss, p_3s, p_2s, &area_c, coordinates_c, normalVec_c);
32767 maia::math::vecAvg<3>(M, p_0, p_1, p_2, p_3, p_0s, p_1s, p_2s, p_3s, p_0ss, p_3ss);
32769 for(
MInt i = 0; i < 6; i++) {
32770 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
32771 &pyraVolume[i], pyraCentroid[i]);
32773 computePyra(&area_c, coordinates_c, normalVec_c, M, &pyraVolume[6], pyraCentroid[6]);
32774 for(
MInt i = 0; i < 7; i++) {
32775 volume_C += pyraVolume[i];
32776 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
32778 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
32780 m_bndryCells->a[bndryId].m_volume = volume_C;
32782 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area_c;
32783 for(
MInt dim = 0; dim < 3; dim++) {
32784 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = coordinates_c[dim];
32785 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normalVec_c[dim];
32786 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
32792 mTerm(1, AT_,
"Inconsistent type implementation.");
32798 if(noUnusedCutPoints > 2) {
32799 mTerm(1, AT_,
"FvBndryCndXD::correctInflowBoundary - Error: Too many unused CutPoints!");
32803 if(noUnusedCutPoints < 2) {
32804 for(
MInt cp = 0; cp < noUnusedCutPoints; cp++) {
32805 cutEdge = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[unusedCutPoints[cp]];
32806 cutFace1 = faceCode[2 * cutEdge];
32807 cutFace2 = faceCode[2 * cutEdge + 1];
32809 if(noIntersectionPoints[cutFace1] == 1 && noIntersectionPoints[cutFace2] == 0) {
32810 for(
MInt dir = 0; dir < 3; dir++) {
32811 intersectionPoints[cutFace2][0][dir] =
32812 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[cp]][dir];
32813 intersectionPoints[cutFace1][0][dir] = F0;
32815 noIntersectionPoints[cutFace1] = 0;
32816 noIntersectionPoints[cutFace2] = 1;
32818 else if(noIntersectionPoints[cutFace2] == 1 && noIntersectionPoints[cutFace1] == 0) {
32819 for(
MInt dir = 0; dir < 3; dir++) {
32820 intersectionPoints[cutFace1][0][dir] =
32821 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[cp]][dir];
32822 intersectionPoints[cutFace2][0][dir] = F0;
32824 noIntersectionPoints[cutFace2] = 0;
32825 noIntersectionPoints[cutFace1] = 1;
32827 else if(noIntersectionPoints[cutFace2] == 0 && noIntersectionPoints[cutFace1] == 0) {
32828 for(
MInt dir = 0; dir < 3; dir++) {
32829 intersectionPoints[cutFace1][0][dir] =
32830 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[cp]][dir];
32831 intersectionPoints[cutFace2][0][dir] =
32832 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[cp]][dir];
32834 noIntersectionPoints[cutFace2] = 1;
32835 noIntersectionPoints[cutFace1] = 1;
32841 if(noUnusedCutPoints == 2) {
32842 cutEdge = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[unusedCutPoints[0]];
32843 cutFace1 = faceCode[2 * cutEdge];
32844 cutFace2 = faceCode[2 * cutEdge + 1];
32845 cutEdgeNghbr = m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[unusedCutPoints[1]];
32846 cutFaceNghbr1 = faceCode[2 * cutEdgeNghbr];
32847 cutFaceNghbr2 = faceCode[2 * cutEdgeNghbr + 1];
32849 if(noIntersectionPoints[cutFace2] == 0 && noIntersectionPoints[cutFace1] == 0
32850 && noIntersectionPoints[cutFaceNghbr2] == 0 && noIntersectionPoints[cutFaceNghbr1] == 0) {
32852 if(cutFaceNghbr1 == cutFace1) {
32853 for(
MInt dir = 0; dir < 3; dir++) {
32854 intersectionPoints[cutFace2][0][dir] =
32855 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[0]][dir];
32856 intersectionPoints[cutFaceNghbr2][0][dir] =
32857 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[1]][dir];
32859 noIntersectionPoints[cutFace2]++;
32860 noIntersectionPoints[cutFaceNghbr2]++;
32863 if(cutFaceNghbr2 == cutFace1) {
32864 for(
MInt dir = 0; dir < 3; dir++) {
32865 intersectionPoints[cutFace2][0][dir] =
32866 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[0]][dir];
32867 intersectionPoints[cutFaceNghbr1][0][dir] =
32868 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[1]][dir];
32870 noIntersectionPoints[cutFace2]++;
32871 noIntersectionPoints[cutFaceNghbr1]++;
32874 if(cutFaceNghbr1 == cutFace2) {
32875 for(
MInt dir = 0; dir < 3; dir++) {
32876 intersectionPoints[cutFace1][0][dir] =
32877 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[0]][dir];
32878 intersectionPoints[cutFaceNghbr2][0][dir] =
32879 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[1]][dir];
32881 noIntersectionPoints[cutFace1]++;
32882 noIntersectionPoints[cutFaceNghbr2]++;
32885 if(cutFaceNghbr2 == cutFace2) {
32886 for(
MInt dir = 0; dir < 3; dir++) {
32887 intersectionPoints[cutFace1][0][dir] =
32888 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[0]][dir];
32889 intersectionPoints[cutFaceNghbr1][0][dir] =
32890 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[unusedCutPoints[1]][dir];
32892 noIntersectionPoints[cutFace1]++;
32893 noIntersectionPoints[cutFaceNghbr1]++;
32896 stringstream fileName;
32897 fileName <<
cellId <<
".stl";
32898 writeStlFileOfCell(cellId, (fileName.str()).c_str());
32899 plotEdges(noFeatureEdges, featureEdges);
32900 plotIntersectionPoints(noIntersectionPoints, intersectionPoints);
32901 writeStlOfNodes(noWallNodes, wallNodes,
"WallNodes.stl");
32902 cerr <<
"Wrote stl-file of cell and wall nodes. Cell-file: " << fileName.str()
32903 <<
", Node-file: WallNodes.stl" << endl;
32904 mTerm(1, AT_,
"Unhandled exception in special cell handling!");
32910 for(
MInt cpCount = noUnusedCutPoints - 1; cpCount >= 0; cpCount--) {
32911 m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints--;
32912 for(
MInt count = unusedCutPoints[cpCount]; count < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints;
32914 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[count] =
32915 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[count + 1];
32916 for(
MInt dir = 0; dir < 3; dir++)
32917 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[count][dir] =
32918 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[count + 1][dir];
32923 for(
MInt face = 0; face < 6; face++) {
32924 if(noIntersectionPoints[face] == 2) {
32925 noIntersectionPoints[face] = 0;
32926 }
else if(noIntersectionPoints[face] > 1) {
32927 cerr <<
"FvBndryCndXD::correctInflowBoundary - Error: More than 1 intersection Point!"
32928 <<
" cellId: " <<
cellId << endl;
32929 stringstream fileName;
32930 fileName <<
cellId <<
".stl";
32931 writeStlFileOfCell(cellId, (fileName.str()).c_str());
32932 plotEdges(noFeatureEdges, featureEdges);
32933 plotIntersectionPoints(noIntersectionPoints, intersectionPoints);
32934 writeStlOfNodes(noWallNodes, wallNodes,
"WallNodes.stl");
32935 stringstream errorMessage;
32936 errorMessage <<
"Wrote stl-file of cell and wall nodes. Cell-file: " << fileName.str()
32937 <<
", Node-file: WallNodes.stl";
32938 mTerm(1, AT_, errorMessage.str());
32951 if(!caseStatesSTL[currentCase][1]) {
32952 mTerm(1, AT_,
"Case not resolved for Inlet Correction!");
32956 for(
MInt face = 0; face < 6; face++) {
32958 if(!(noIntersectionPoints[face] == 1)) {
32961 for(
MInt cP = 0; cP < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cP++) {
32962 for(
MInt edge = 0; edge < 4; edge++) {
32963 if(m_bndryCells->a[bndryId].m_srfcs[0]->m_cutEdge[cP] == edgeCode[face * 4 + edge]) {
32964 if(pointCount < 2) {
32965 pointIndices[pointCount++] = cP;
32967 mTerm(1, AT_,
"Too many cut Points!");
32972 if(!(pointCount == 2)) {
32973 cerr <<
"FvBndryCndXD::correctInflowBoundary - Error: Not two Cut points..."
32974 <<
" face: " << face <<
"faceNormal: " << normal[face][0] <<
" " << normal[face][1] <<
" "
32975 << normal[face][2] << endl;
32976 plotIntersectionPoints(noIntersectionPoints, intersectionPoints);
32977 plotEdges(noFeatureEdges, featureEdges);
32978 writeStlOfNodes(noWallNodes, wallNodes,
"WallNodes.stl");
32979 stringstream fileName;
32980 fileName <<
cellId <<
".stl";
32981 writeStlFileOfCell(cellId, (fileName.str()).c_str());
32982 stringstream errorMessage;
32983 errorMessage <<
"Wrote stl-file of cell, wall nodes, feature edges and intersection points. Cell-file: "
32985 mTerm(1, AT_, errorMessage.str());
32991 computeTri(m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[pointIndices[0]],
32992 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[pointIndices[1]],
32993 intersectionPoints[face][0], &newArea, dummy_1);
32994 plotTriangle(ofl, m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[pointIndices[0]],
32995 m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[pointIndices[1]],
32996 intersectionPoints[face][0], normal[face]);
33002 secondHalf =
false;
33008 newArea = -newArea;
33010 vecScalarMul(faceVolume[face], faceCentroid[face], dummy_2);
33011 vecScalarMul(newArea, dummy_1, dummy_3);
33012 std::fill_n(faceCentroid[face], 3, 0.0);
33013 maia::math::vecAdd<3>(faceCentroid[face], dummy_2, dummy_3);
33014 faceVolume[face] = faceVolume[face] + newArea;
33015 vecScalarMul(1. / (faceVolume[face]), faceCentroid[face], faceCentroid[face]);
33019 secondHalf =
false;
33026 if(faceStart == -1) {
33027 plotIntersectionPoints(noIntersectionPoints, intersectionPoints);
33028 plotEdges(noFeatureEdges, featureEdges);
33029 writeStlOfNodes(noWallNodes, wallNodes,
"WallNodes.stl");
33030 stringstream fileName;
33031 fileName <<
cellId <<
".stl";
33032 writeStlFileOfCell(cellId, (fileName.str()).c_str());
33033 cerr <<
"Wrote stl-file of cell, wall nodes, feature edges and intersection points. Cell-file: "
33034 << fileName.str() << endl;
33036 stringstream errorMessage;
33037 errorMessage <<
"No suitable start face found on cell " <<
cellId <<
"!";
33038 mTerm(1, AT_, errorMessage.str());
33042 points1[noPoints1++] = intersectionPoints[faceStart][0];
33045 points1[noPoints1++] = points[facePoints[2 * faceStart + 1]];
33046 faceStart = nextFaces[faceStart];
33047 }
while(noIntersectionPoints[faceStart] == 0);
33048 delta_IP = sqrt(
POW2(intersectionPoints[faceStart][0][0] - points1[0][0])
33049 +
POW2(intersectionPoints[faceStart][0][1] - points1[0][1])
33050 +
POW2(intersectionPoints[faceStart][0][2] - points1[0][2]));
33051 if(delta_IP > 1e-5) {
33052 points1[noPoints1++] = intersectionPoints[faceStart][0];
33056 points2[noPoints2++] = intersectionPoints[faceStart][0];
33059 points2[noPoints2++] = points[facePoints[2 * faceStart + 1]];
33060 faceStart = nextFaces[faceStart];
33061 }
while(noIntersectionPoints[faceStart] == 0);
33062 delta_IP = sqrt(
POW2(intersectionPoints[faceStart][0][0] - points2[0][0])
33063 +
POW2(intersectionPoints[faceStart][0][1] - points2[0][1])
33064 +
POW2(intersectionPoints[faceStart][0][2] - points2[0][2]));
33065 if(delta_IP > 1e-5) {
33066 points2[noPoints2++] = intersectionPoints[faceStart][0];
33069 switch(noPoints1) {
33072 cerr <<
"FvBndryCndXD::correctInflowBoundaryCondition - Error 1: Not enough Points to create a cut face"
33074 plotIntersectionPoints(noIntersectionPoints, intersectionPoints);
33075 plotEdges(noFeatureEdges, featureEdges);
33076 writeStlOfNodes(noWallNodes, wallNodes,
"WallNodes.stl");
33077 stringstream fileName;
33078 fileName <<
cellId <<
".stl";
33079 writeStlFileOfCell(cellId, (fileName.str()).c_str());
33080 cerr <<
" cut Points: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints <<
" : ";
33081 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++)
33082 cerr << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp][0] <<
" "
33083 << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp][1] <<
" "
33084 << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp][2] <<
"; ";
33086 stringstream errorMessage;
33087 errorMessage <<
"Wrote stl-file of cell, wall nodes, feature edges and intersection points. Cell-file: "
33089 mTerm(1, AT_, errorMessage.str());
33092 computePoly3(points1[0], points1[1], points1[2], &area1, centroid1, normal1);
33093 plotTriangle(ofl, points1[0], points1[1], points1[2], normal1);
33096 computePoly4(points1[0], points1[1], points1[2], points1[3], &area1, centroid1, normal1);
33097 plotTriangle(ofl, points1[0], points1[1], points1[2], normal1);
33098 plotTriangle(ofl, points1[2], points1[3], points1[0], normal1);
33101 computePoly5(points1[0], points1[1], points1[2], points1[3], points1[4], &area1, centroid1, normal1);
33102 plotTriangle(ofl, points1[0], points1[1], points1[2], normal1);
33103 plotTriangle(ofl, points1[2], points1[3], points1[4], normal1);
33104 plotTriangle(ofl, points1[2], points1[4], points1[0], normal1);
33107 computePoly6(points1[0], points1[1], points1[2], points1[3], points1[4], points1[5], &area1, centroid1,
33109 plotTriangle(ofl, points1[0], points1[1], points1[2], normal1);
33110 plotTriangle(ofl, points1[2], points1[3], points1[4], normal1);
33111 plotTriangle(ofl, points1[2], points1[4], points1[5], normal1);
33112 plotTriangle(ofl, points1[2], points1[5], points1[0], normal1);
33115 stringstream errorMessage;
33116 errorMessage <<
"ERROR: Switch variable 'noPoints1' with value " << noPoints1 <<
" not matching any case."
33118 mTerm(1, AT_, errorMessage.str());
33121 switch(noPoints2) {
33124 cerr <<
"FvBndryCndXD::correctInflowBoundaryCondition - Error 2: Not enough Points to create a cut face"
33126 plotIntersectionPoints(noIntersectionPoints, intersectionPoints);
33127 plotEdges(noFeatureEdges, featureEdges);
33128 writeStlOfNodes(noWallNodes, wallNodes,
"WallNodes.stl");
33129 stringstream fileName;
33130 fileName <<
cellId <<
".stl";
33131 writeStlFileOfCell(cellId, (fileName.str()).c_str());
33132 stringstream errorMessage;
33133 errorMessage <<
"Wrote stl-file of cell, wall nodes, feature edges and intersection points. Cell-file: "
33135 cerr <<
" cut Points: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints <<
" : ";
33136 for(
MInt cp = 0; cp < m_bndryCells->a[bndryId].m_srfcs[0]->m_noCutPoints; cp++)
33137 cerr << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp][0] <<
" "
33138 << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp][1] <<
" "
33139 << m_bndryCells->a[bndryId].m_srfcs[0]->m_cutCoordinates[cp][2] <<
"; ";
33141 mTerm(1, AT_, errorMessage.str());
33144 computePoly3(points2[0], points2[1], points2[2], &area2, centroid2, normal2);
33145 plotTriangle(ofl, points2[0], points2[1], points2[2], normal2);
33148 computePoly4(points2[0], points2[1], points2[2], points2[3], &area2, centroid2, normal2);
33149 plotTriangle(ofl, points2[0], points2[1], points2[2], normal2);
33150 plotTriangle(ofl, points2[2], points2[3], points2[0], normal2);
33153 computePoly5(points2[0], points2[1], points2[2], points2[3], points2[4], &area2, centroid2, normal2);
33154 plotTriangle(ofl, points2[0], points2[1], points2[2], normal2);
33155 plotTriangle(ofl, points2[2], points2[3], points2[4], normal2);
33156 plotTriangle(ofl, points2[2], points2[4], points2[0], normal2);
33159 computePoly6(points2[0], points2[1], points2[2], points2[3], points2[4], points2[5], &area2, centroid2,
33161 plotTriangle(ofl, points2[0], points2[1], points2[2], normal2);
33162 plotTriangle(ofl, points2[2], points2[3], points2[4], normal2);
33163 plotTriangle(ofl, points2[2], points2[4], points2[5], normal2);
33164 plotTriangle(ofl, points2[2], points2[5], points2[0], normal2);
33167 stringstream errorMessage;
33168 errorMessage <<
"ERROR: Switch variable 'noPoints2' with value " << noPoints2 <<
" not matching any case."
33170 mTerm(1, AT_, errorMessage.str());
33176 coordinates_Cell[0] = F0;
33177 coordinates_Cell[1] = F0;
33178 coordinates_Cell[2] = F0;
33179 for(
MInt i = 0; i < noFaces; i++) {
33180 computePyra(&faceVolume[*facepointers[i]], faceCentroid[*facepointers[i]], normal[*facepointers[i]], M,
33181 &pyraVolume[i], pyraCentroid[i]);
33183 computePyra(&area1, centroid1, normal1, M, &pyraVolume[noFaces], pyraCentroid[noFaces]);
33184 computePyra(&area2, centroid2, normal2, M, &pyraVolume[noFaces + 1], pyraCentroid[noFaces + 1]);
33185 for(
MInt i = 0; i < noFaces + 2; i++) {
33186 volume_C += pyraVolume[i];
33187 maia::math::vecAdd<3>(coordinates_Cell, vecScalarMul(pyraVolume[i], pyraCentroid[i], dummy_1));
33189 vecScalarMul(F1 / volume_C, coordinates_Cell, coordinates_Cell);
33192 POW2(normal1[0] - meanNormal[0]) +
POW2(normal1[1] - meanNormal[1]) +
POW2(normal1[2] - meanNormal[2]);
33193 if(normalDiff < normalEps) {
33202 switch(currentCase) {
33204 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
33205 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
33206 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
33208 correctCell(&volume_C, coordinates_Cell, &gridCellVolume, &m_solver->a_coordinate(cellId, 0));
33210 correctNormal(normalVec_c);
33212 correctNormal(normal1);
33213 correctNormal(normal2);
33218 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
33219 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
33220 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
33221 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
33223 correctCell(&volume_C, coordinates_Cell, &gridCellVolume, &m_solver->a_coordinate(cellId, 0));
33225 correctNormal(normalVec_c);
33227 correctNormal(normal1);
33228 correctNormal(normal2);
33233 correctFace(&faceVolume[face1], faceCentroid[face1], &faceVolume_0[face1], faceCentroid_0[face1]);
33234 correctFace(&faceVolume[face2], faceCentroid[face2], &faceVolume_0[face2], faceCentroid_0[face2]);
33235 correctFace(&faceVolume[face3], faceCentroid[face3], &faceVolume_0[face3], faceCentroid_0[face3]);
33236 correctFace(&faceVolume[face4], faceCentroid[face4], &faceVolume_0[face4], faceCentroid_0[face4]);
33237 correctFace(&faceVolume[face5], faceCentroid[face5], &faceVolume_0[face5], faceCentroid_0[face5]);
33239 correctCell(&volume_C, coordinates_Cell, &gridCellVolume, &m_solver->a_coordinate(cellId, 0));
33241 correctNormal(normal1);
33242 correctNormal(normal2);
33247 mTerm(1, AT_,
"Inconsistent type implementation.");
33255 for(
MInt i = 0; i < nDim; i++) {
33256 if(!nfs_cur[2 * i + 1]) faceVolume[2 * i + 1] = 0;
33257 if(!nfs_cur[2 * i]) faceVolume[2 * i] = 0;
33258 faceDiff[i] = faceVolume[2 * i + 1] - faceVolume[2 * i];
33259 absA +=
POW2(faceDiff[i]);
33264 if(bcInlet == bcId1) {
33265 for(
MInt dim = 0; dim < 3; dim++)
33266 normal1[dim] = meanNormal[dim];
33269 for(
MInt dim = 0; dim < 3; dim++)
33270 absA += normal1[dim] * normal1[dim];
33272 for(
MInt dim = 0; dim < 3; dim++)
33273 normal1[dim] /= absA;
33277 for(
MInt dim = 0; dim < 3; dim++)
33278 area1 += faceDiff[dim] * normal1[dim];
33282 for(
MInt i = 0; i < nDim; i++) {
33283 faceDiff[i] -= area1 * normal1[i];
33284 absA +=
POW2(faceDiff[i]);
33288 for(
MInt i = 0; i < nDim; i++)
33289 normal2[i] = faceDiff[i] / sqrt(absA);
33290 area2 = sqrt(absA);
33292 for(
MInt dim = 0; dim < 3; dim++)
33293 normal2[dim] = meanNormal[dim];
33296 for(
MInt dim = 0; dim < 3; dim++)
33297 absA += normal2[dim] * normal2[dim];
33299 for(
MInt dim = 0; dim < 3; dim++)
33300 normal2[dim] /= absA;
33304 for(
MInt dim = 0; dim < 3; dim++)
33305 area2 += faceDiff[dim] * normal2[dim];
33309 for(
MInt i = 0; i < nDim; i++) {
33310 faceDiff[i] -= area2 * normal2[i];
33311 absA +=
POW2(faceDiff[i]);
33315 for(
MInt i = 0; i < nDim; i++)
33316 normal1[i] = faceDiff[i] / sqrt(absA);
33317 area1 = sqrt(absA);
33393 m_bndryCells->a[bndryId].m_noSrfcs = 2;
33394 m_bndryCells->a[bndryId].m_volume = volume_C;
33396 if(bcInlet == bcId1) {
33397 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area1;
33398 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area2;
33399 m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId = bcId1;
33400 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = bcId2;
33401 for(
MInt dim = 0; dim < 3; dim++) {
33402 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = centroid1[dim];
33403 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = centroid2[dim];
33404 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normal1[dim];
33405 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normal2[dim];
33406 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
33409 m_bndryCells->a[bndryId].m_srfcs[0]->m_area = area2;
33410 m_bndryCells->a[bndryId].m_srfcs[1]->m_area = area1;
33411 m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId = bcId2;
33412 m_bndryCells->a[bndryId].m_srfcs[1]->m_bndryCndId = bcId1;
33413 for(
MInt dim = 0; dim < 3; dim++) {
33414 m_bndryCells->a[bndryId].m_srfcs[0]->m_coordinates[dim] = centroid2[dim];
33415 m_bndryCells->a[bndryId].m_srfcs[1]->m_coordinates[dim] = centroid1[dim];
33416 m_bndryCells->a[bndryId].m_srfcs[0]->m_normalVector[dim] = normal2[dim];
33417 m_bndryCells->a[bndryId].m_srfcs[1]->m_normalVector[dim] = normal1[dim];
33418 m_bndryCells->a[bndryId].m_coordinates[dim] = coordinates_Cell[dim];
33422 for(
MInt i = 0; i < nDim; i++) {
33423 m_bndryCells->a[bndryId].m_coordinates[i] -= m_solver->a_coordinate(cellId, i);
33426 for(
MInt face = 0; face < 6; face++) {
33427 for(
MInt i = 0; i < noFaces; i++) {
33428 if(!(*facepointers[i] == face))
continue;
33430 spaceId = face / 2;
33431 if(nfs_cur[face]) {
33432 if(m_solver->a_hasNeighbor(cellId, face) > 0)
33433 nghbrId = m_solver->c_neighborId(cellId, face);
33435 if(m_solver->c_parentId(cellId) > -1) {
33436 if(m_solver->a_hasNeighbor(m_solver->c_parentId(cellId), face) > 0)
33437 nghbrId = m_solver->c_neighborId(m_solver->c_parentId(cellId), face);
33443 if(m_solver->c_noChildren(nghbrId) > 0)
continue;
33444 otherSideId = (sideId + 1) % 2;
33445 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[face];
33446 m_solver->a_surfaceOrientation(srfcId) = spaceId;
33447 m_solver->a_surfaceNghbrCellId(srfcId, sideId) = nghbrId;
33448 m_solver->a_surfaceNghbrCellId(srfcId, otherSideId) =
cellId;
33449 for(
MInt dim = 0; dim < nDim; dim++) {
33450 m_solver->a_surfaceCoordinate(srfcId, dim) = faceCentroid[face][dim];
33452 m_solver->a_surfaceArea(srfcId) = faceVolume[face];
33453 m_bndryCells->a[bndryId].m_associatedSrfc[face] = srfcId;
33455 cerr <<
"FvBndryCndXD::correctInflowBoundary - Error for face: " << face << endl;
33456 cerr <<
"bndryId: " << bndryId << endl;
33457 cerr <<
"cellId: " <<
cellId << endl;
33458 cerr <<
"bndryCnd: " << m_bndryCells->a[bndryId].m_srfcs[0]->m_bndryCndId;
33459 cerr <<
"case, subcase: " << currentCase <<
", " << currentSubCase << endl;
33460 cerr <<
"face Volumes: " << faceVolume[0] <<
", " << faceVolume[1] <<
", " << faceVolume[2] <<
", "
33461 << faceVolume[3] <<
", " << faceVolume[4] <<
", " << faceVolume[5] << endl;
33462 cerr <<
"faceCentroids: ";
33463 for(
MInt j = 0; j < 6; j++) {
33464 cerr << faceCentroid[j][0] <<
", " << faceCentroid[j][1] <<
", " << faceCentroid[j][2] <<
"; " << endl;
33466 cerr <<
"area_c = " << area_c << endl;
33467 cerr <<
"normalVec_c = " << normalVec_c[0] <<
", " << normalVec_c[1] <<
", " << normalVec_c[2] << endl;
33468 cerr <<
"coordinates_c = " << coordinates_c[0] <<
", " << coordinates_c[1] <<
", " << coordinates_c[2]
33470 cerr <<
"coordinates_Cell = " << coordinates_Cell[0] <<
", " << coordinates_Cell[1] <<
", "
33471 << coordinates_Cell[2] << endl;
33472 cerr <<
"volume_C = " << volume_C << endl;
33473 mTerm(1, AT_,
"error in face");
33480 ofl <<
"endsolid cutsurface " << endl;
33496template <MInt nDim,
class SysEqn>
33497template <
class _, std::enable_if_t<nDim == 3, _*>>
33502 MFloat* meanNormal = meanNormal_scratch.getPointer();
33504 MFloat* basePoint = basePoint_scratch.getPointer();
33505 for(
MInt i = 0; i < 3; i++) {
33506 meanNormal[i] = F0;
33509 MInt noBcCells = 0;
33512 MFloat referencePoint2[3] = {0.0, 0.0, 0.0};
33513 MFloat referencePoint[3] = {0.0, 0.0, 0.0};
33514 MInt noCells = m_bndryCells->size();
33519 MFloat* comm_buff = comm_buff_scratch.getPointer();
33520 MFloat* comm_buff_result = comm_buff_result_scratch.getPointer();
33526 referencePoint2[0] = F0;
33527 referencePoint2[1] = F0;
33528 referencePoint2[2] = F0;
33529 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
33530 cellId = m_bndryCells->a[bndryId].m_cellId;
33531 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
33532 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
33533 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == bcId) {
33535 newArea += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area;
33536 for(
MInt i = 0; i < 3; i++) {
33537 referencePoint2[i] += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i];
33544 comm_buff[0] = newArea;
33545 comm_buff[1] = referencePoint2[0];
33546 comm_buff[2] = referencePoint2[1];
33547 comm_buff[3] = referencePoint2[2];
33548 comm_buff[4] = noBcCells;
33550 MPI_Allreduce(comm_buff, comm_buff_result, 5, MPI_DOUBLE, MPI_SUM, mpiComm(), AT_,
"comm_buff",
"comm_buff_result");
33552 newArea = comm_buff_result[0];
33553 referencePoint2[0] = comm_buff_result[1];
33554 referencePoint2[1] = comm_buff_result[2];
33555 referencePoint2[2] = comm_buff_result[3];
33556 noBcCells = (
MInt)comm_buff_result[4];
33558 for(
MInt i = 0; i < 3; i++) {
33559 referencePoint2[i] /= noBcCells;
33562 R = 0.7 * sqrt(newArea / PI);
33567 referencePoint[0] = F0;
33568 referencePoint[1] = F0;
33569 referencePoint[2] = F0;
33570 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
33571 cellId = m_bndryCells->a[bndryId].m_cellId;
33572 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
33573 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
33574 radius = sqrt(
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[0] - referencePoint2[0])
33575 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[1] - referencePoint2[1])
33576 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[2] - referencePoint2[2]));
33577 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == bcId && radius < R) {
33579 newArea += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_area;
33580 for(
MInt i = 0; i < 3; i++) {
33581 referencePoint[i] += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[i];
33587 comm_buff[0] = newArea;
33588 comm_buff[1] = referencePoint[0];
33589 comm_buff[2] = referencePoint[1];
33590 comm_buff[3] = referencePoint[2];
33591 comm_buff[4] = noBcCells;
33593 MPI_Allreduce(comm_buff, comm_buff_result, 5, MPI_DOUBLE, MPI_SUM, mpiComm(), AT_,
"comm_buff",
"comm_buff_result");
33595 newArea = comm_buff_result[0];
33596 referencePoint[0] = comm_buff_result[1];
33597 referencePoint[1] = comm_buff_result[2];
33598 referencePoint[2] = comm_buff_result[3];
33599 noBcCells = (
MInt)comm_buff_result[4];
33600 for(
MInt i = 0; i < 3; i++) {
33601 referencePoint[i] /= noBcCells;
33608 meanNormal[0] = F0;
33609 meanNormal[1] = F0;
33610 meanNormal[2] = F0;
33611 for(
MInt bndryId = 0; bndryId < noCells; bndryId++) {
33612 cellId = m_bndryCells->a[bndryId].m_cellId;
33613 if(m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
33614 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
33615 radius = sqrt(
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[0] - referencePoint[0])
33616 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[1] - referencePoint[1])
33617 +
POW2(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_coordinates[2] - referencePoint[2]));
33618 if(m_bndryCells->a[bndryId].m_srfcs[srfc]->m_bndryCndId == bcId && radius < R) {
33620 for(
MInt i = 0; i < 3; i++) {
33621 meanNormal[i] += m_bndryCells->a[bndryId].m_srfcs[srfc]->m_normalVector[i];
33627 comm_buff[0] = meanNormal[0];
33628 comm_buff[1] = meanNormal[1];
33629 comm_buff[2] = meanNormal[2];
33631 MPI_Allreduce(comm_buff, comm_buff_result, 3, MPI_DOUBLE, MPI_SUM, mpiComm(), AT_,
"comm_buff",
"comm_buff_result");
33633 meanNormal[0] = comm_buff_result[0];
33634 meanNormal[1] = comm_buff_result[1];
33635 meanNormal[2] = comm_buff_result[2];
33636 for(
MInt i = 0; i < 3; i++) {
33637 meanNormal[i] /= noBcCells;
33638 basePoint[i] = referencePoint[i];
33642 cerr <<
" computed base point and normal of bcId " << bcId <<
" as: normal: " << meanNormal[0] <<
" " << meanNormal[1]
33643 <<
" " << meanNormal[2] <<
". base point: " << basePoint[0] <<
" " << basePoint[1] <<
" " << basePoint[2]
33645 correctInflowBoundary(bcId, meanNormal, basePoint);
33661template <MInt nDim,
class SysEqn>
33662template <
class _, std::enable_if_t<nDim == 3, _*>>
33665 MInt& noIntersectionPoints) {
33672 MFloat pP[3] = {0.0, 0.0, 0.0};
33674 MBool rejected =
false;
33675 MBool accepted =
false;
33677 MInt spaceId1, spaceId2;
33680 noIntersectionPoints = 0;
33686 spaceId1 = (dir + 1) % 3;
33687 spaceId2 = (dir + 2) % 3;
33689 eps = abs(
a[spaceId1] -
b[spaceId1]) / 100;
33691 for(
MInt i = 0; i < noFeatureEdges; i++) {
33692 d = featureEdges[2 * i];
33693 e = featureEdges[2 * i + 1];
33698 if(d[dir] <
a[dir] && e[dir] <
a[dir])
33700 else if(d[dir] >
a[dir] && e[dir] >
a[dir])
33702 else if(d[dir] <=
a[dir] && e[dir] >=
a[dir])
33704 else if(d[dir] >=
a[dir] && e[dir] <=
a[dir])
33707 if(rejected ==
false && accepted ==
false) {
33708 cerr <<
"no trivial rejection, no trivial acception, continue..." << endl;
33710 }
else if(rejected) {
33714 gamma = ((e[0] - d[0]) * ((
a[2] - c[2]) * (c[1] -
b[1]) - (
a[1] - c[1]) * (c[2] -
b[2]))
33715 - (e[1] - d[1]) * ((
a[2] - c[2]) * (c[0] -
b[0]) - (
a[0] - c[0]) * (c[2] -
b[2]))
33716 + (e[2] - d[2]) * ((
a[1] - c[1]) * (c[0] -
b[0]) - (
a[0] - c[0]) * (c[1] -
b[1])));
33718 s = ((c[0] - d[0]) * ((
a[2] - c[2]) * (c[1] -
b[1]) - (
a[1] - c[1]) * (c[2] -
b[2]))
33719 - (c[1] - d[1]) * ((
a[2] - c[2]) * (c[0] -
b[0]) - (
a[0] - c[0]) * (c[2] -
b[2]))
33720 + (c[2] - d[2]) * ((
a[1] - c[1]) * (c[0] -
b[0]) - (
a[0] - c[0]) * (c[1] -
b[1])))
33724 for(
MInt k = 0; k < 3; k++) {
33725 pP[k] = d[k] + s * (e[k] - d[k]);
33729 if(
mMin(
a[spaceId1],
b[spaceId1]) <= pP[spaceId1] && pP[spaceId1] <=
mMax(
a[spaceId1],
b[spaceId1])) {
33730 if(
mMin(
a[spaceId2], c[spaceId2]) <= pP[spaceId2] && pP[spaceId2] <=
mMax(
a[spaceId2], c[spaceId2])) {
33732 for(
MInt j = 0; j < noIntersectionPoints; j++) {
33733 diff = sqrt(
POW2(pP[0] - intersectionPoints[j][0]) +
POW2(pP[1] - intersectionPoints[j][1])
33734 +
POW2(pP[2] - intersectionPoints[j][2]));
33740 if(!identical && noIntersectionPoints < 10) {
33741 for(
MInt j = 0; j < 3; j++) {
33742 intersectionPoints[noIntersectionPoints][j] = pP[j];
33744 noIntersectionPoints++;
33745 }
else if(noIntersectionPoints == 10)
33746 cerr <<
"FvBndryCndXD::getIntersectionPoints - Error: Too many intersection points, array too small.."
33771template <MInt nDim,
class SysEqn>
33772template <
class _, std::enable_if_t<nDim == 3, _*>>
33780 MFloat* edgeVec = edgeVec_scratch.getPointer();
33783 MFloat normalEps = 1e-3;
33790 noFeatureEdges = 0;
33793 for(
MInt i = 0; i < noWallNodes; i++) {
33794 for(
MInt j = 0; j < nDim; j++) {
33796 index2 = (j + 1) % nDim;
33798 edgeStart = m_solver->m_geometry->elements[wallNodes[i]].m_vertices[index1];
33799 edgeEnd = m_solver->m_geometry->elements[wallNodes[i]].m_vertices[index2];
33801 diff = sqrt(
POW2(edgeStart[0] - edgeEnd[0]) +
POW2(edgeStart[1] - edgeEnd[1]) +
POW2(edgeStart[2] - edgeEnd[2]));
33807 vecSub(edgeEnd, edgeStart, edgeVec);
33808 normalTest = (abs(inner_product(edgeVec, edgeVec + 3, meanNormal, 0.0)) < normalEps);
33810 vecSub(edgeStart, basePoint, edgeVec);
33811 planeTest1 = (abs(inner_product(edgeVec, edgeVec + 3, meanNormal, 0.0)) < planeEps);
33813 vecSub(edgeEnd, basePoint, edgeVec);
33814 planeTest2 = (abs(inner_product(edgeVec, edgeVec + 3, meanNormal, 0.0)) < planeEps);
33816 if(normalTest && (planeTest1 || planeTest2)) {
33817 featureEdges[2 * noFeatureEdges] = edgeStart;
33818 featureEdges[2 * noFeatureEdges + 1] = edgeEnd;
33843template <MInt nDim,
class SysEqn>
33844template <
class _, std::enable_if_t<nDim == 3, _*>>
33846 MInt*& wallNodes,
MInt& noInflowNodes,
MInt*& inflowNodes,
33852 for(
MInt i = 0; i < (signed)nodeList.size(); i++) {
33853 if(m_solver->m_geometry->elements[nodeList[i]].m_bndCndId == bcId) {
33854 inflowNodes[(noInflowNodes)++] = nodeList[i];
33856 wallNodes[(noWallNodes)++] = nodeList[i];
33876template <MInt nDim,
class SysEqn>
33881 const MInt noSmallCells = m_smallBndryCells->size();
33882 const MInt noBndryCells = m_bndryCells->size();
33884 MInt noUnknowns = nDim;
33886 MFloat* x = x_scratch.getPointer();
33892 for(bndryId = 0; bndryId < noBndryCells; bndryId++) {
33893 for(
MInt n = 0; n < nDim * m_solver->m_cells.noRecNghbrs(); n++)
33894 m_reconstructionConstants[bndryId][n] = -9999;
33898 for(bndryId = 0; bndryId < noBndryCells; bndryId++) {
33899 cellId = m_bndryCells->a[bndryId].m_cellId;
33900 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
33901 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient))
continue;
33902 if(m_bndryCells->a[bndryId].m_linkedCellId > -1)
continue;
33904 noNghbrIds = m_solver->a_noReconstructionNeighbors(cellId);
33907 for(
MInt cell = 0; cell < noNghbrIds; cell++) {
33908 id = m_solver->a_reconstructionNeighborId(cellId, cell);
33909 if(!m_solver->a_isBndryGhostCell(
id)) {
33910 for(
MInt i = 0; i < nDim; i++) {
33911 x[i] = m_solver->a_coordinate(
id, i);
33915 for(
MInt i = 0; i < nDim; i++)
33916 x[i] = m_solver->a_coordinate(cellId, i);
33919 for(
MInt i = 0; i < nDim; i++)
33920 m_solver->m_A[cell][i] = x[i] - m_solver->a_coordinate(cellId, i);
33924 for(
MInt i = 0; i < noUnknowns; i++) {
33925 for(
MInt j = 0; j < noUnknowns; j++) {
33926 m_solver->m_ATA[i][j] = F0;
33927 for(
MInt k = 0; k < noNghbrIds; k++) {
33928 m_solver->m_ATA[i][j] += m_solver->m_A[k][i] * m_solver->m_A[k][j];
33934 const MFloat epsilon =
POW3(m_solver->c_cellLengthAtLevel(m_solver->maxRefinementLevel()) / (1000.0));
33938 for(
MInt i = 0; i < noUnknowns; i++) {
33939 for(
MInt j = 0; j < noNghbrIds; j++) {
33940 m_solver->m_ATA[i][j] = F0;
33941 for(
MInt k = 0; k < noUnknowns; k++) {
33942 m_solver->m_ATA[i][j] += m_solver->m_ATAi[i][k] * m_solver->m_A[j][k];
33948 for(
MInt nghbr = 0; nghbr < noNghbrIds; nghbr++) {
33949 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
33952 if(!m_solver->a_isBndryGhostCell(nghbrId))
33953 for(
MInt i = 0; i < nDim; i++)
33954 m_reconstructionConstants[bndryId][nDim * nghbr + i] = m_solver->m_ATA[i][nghbr];
33956 for(
MInt i = 0; i < nDim; i++)
33957 m_reconstructionConstants[bndryId][nDim * nghbr + i] = F0;
33962 for(
MInt sid = 0; sid < noSmallCells; sid++) {
33963 bndryId = m_smallBndryCells->a[sid];
33964 cellId = m_bndryCells->a[bndryId].m_linkedCellId;
33965 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
33966 if(!m_solver->a_hasProperty(m_bndryCells->a[bndryId].m_cellId, SolverCell::IsOnCurrentMGLevel))
continue;
33967 if(!m_solver->a_hasProperty(cellId, SolverCell::IsFlux))
continue;
33968 if(m_solver->a_isBndryGhostCell(cellId))
continue;
33969 if(m_solver->a_isBndryGhostCell(m_bndryCells->a[bndryId].m_cellId))
continue;
33974 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient))
continue;
33975 if(m_solver->a_hasProperty(m_bndryCells->a[bndryId].m_cellId, SolverCell::IsNotGradient))
continue;
33978 noNghbrIds = m_solver->a_noReconstructionNeighbors(cellId);
33981 for(
MInt cell = 0; cell < noNghbrIds; cell++) {
33982 id = m_solver->a_reconstructionNeighborId(cellId, cell);
33983 if(!m_solver->a_isBndryGhostCell(
id)) {
33984 for(
MInt i = 0; i < nDim; i++) {
33985 x[i] = m_solver->a_coordinate(
id, i);
33989 for(
MInt i = 0; i < nDim; i++)
33990 x[i] = m_solver->a_coordinate(cellId, i);
33993 for(
MInt i = 0; i < nDim; i++)
33994 m_solver->m_A[cell][i] = x[i] - m_solver->a_coordinate(cellId, i);
33998 for(
MInt i = 0; i < noUnknowns; i++) {
33999 for(
MInt j = 0; j < noUnknowns; j++) {
34000 m_solver->m_ATA[i][j] = F0;
34001 for(
MInt k = 0; k < noNghbrIds; k++) {
34002 m_solver->m_ATA[i][j] += m_solver->m_A[k][i] * m_solver->m_A[k][j];
34008 const MFloat epsilon =
POW3(m_solver->c_cellLengthAtLevel(m_solver->maxRefinementLevel()) / (1000.0));
34012 for(
MInt i = 0; i < noUnknowns; i++) {
34013 for(
MInt j = 0; j < noNghbrIds; j++) {
34014 m_solver->m_ATA[i][j] = F0;
34015 for(
MInt k = 0; k < noUnknowns; k++) {
34016 m_solver->m_ATA[i][j] += m_solver->m_ATAi[i][k] * m_solver->m_A[j][k];
34022 for(
MInt nghbr = 0; nghbr < noNghbrIds; nghbr++) {
34023 nghbrId = m_solver->a_reconstructionNeighborId(cellId, nghbr);
34026 if(!m_solver->a_isBndryGhostCell(nghbrId))
34027 for(
MInt i = 0; i < nDim; i++)
34028 m_reconstructionConstants[bndryId][nDim * nghbr + i] = m_solver->m_ATA[i][nghbr];
34030 for(
MInt i = 0; i < nDim; i++)
34031 m_reconstructionConstants[bndryId][nDim * nghbr + i] = F0;
34046template <MInt nDim,
class SysEqn>
34047template <
class _, std::enable_if_t<nDim == 2, _*>>
34052 cerr <<
"Warning: Insufficient amount of points provided in FvBndryCndXD::computePolygon(...)." << endl;
34053 }
else if(N == 3) {
34054 centroid[0] = F1B3 * (x[0] + x[2] + x[4]);
34055 centroid[1] = F1B3 * (x[1] + x[3] + x[5]);
34056 *area = F1B2 * fabs(((x[0] - x[4]) * (x[3] - x[1])) - ((x[0] - x[2]) * (x[5] - x[1])));
34061 for(
MInt i = 0; i < N; i++) {
34062 tmp = x[i * 2] * x[((i + 1) % N) * 2 + 1] - x[i * 2 + 1] * x[((i + 1) % N) * 2];
34064 centroid[0] += tmp * (x[i * 2] + x[((i + 1) % N) * 2]);
34065 centroid[1] += tmp * (x[i * 2 + 1] + x[((i + 1) % N) * 2 + 1]);
34067 centroid[0] /= (F3 * (*area));
34068 centroid[1] /= (F3 * (*area));
34069 *area = F1B2 * fabs((*area));
34077template <MInt nDim,
class SysEqn>
34080 TERMM_IF_COND(m_solver->m_reConstSVDWeightMode == 3 || m_solver->m_reConstSVDWeightMode == 4,
34081 "Possibly not yet implemented!");
34083 MInt cbcId = m_cbcBndryCndIds[bcId];
34085 MInt otherDir[2 * nDim];
34086 for(
MInt dim = 0; dim < nDim; dim++) {
34087 otherDir[2 * dim] = 2 * dim + 1;
34088 otherDir[2 * dim + 1] = 2 * dim;
34090 MInt direction = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, cbcId);
34091 std::vector<MInt> dirs;
34092 dirs.resize(nDim + 1);
34093 dirs[0] = otherDir[direction];
34094 dirs[1] = (
MInt)dirs[0] / 2;
34095 dirs[2] = (dirs[1] + 1) % nDim;
34096 IF_CONSTEXPR(nDim == 3) { dirs[nDim] = (dirs[2] + 1) % nDim; }
34097 m_cbcDir[cbcId] = dirs;
34100 std::vector<MFloat> relaxCoef;
34101 relaxCoef.resize(CV->noVariables);
34102 for(
MInt var = 0; var < CV->noVariables; var++) {
34103 MInt ind = var + CV->noVariables * cbcId;
34104 relaxCoef[var] = Context::getSolverProperty<MFloat>(
"cbcRelaxation", m_solverId, AT_, ind);
34106 m_cbcRelax[cbcId] = relaxCoef;
34108 MInt dimN = dirs[1];
34110 if(m_solver->m_geometry->GetNoElements() < 1) {
34111 m_solver->m_geometry->getBoundingBoxMB(tmp);
34113 m_solver->m_geometry->getBoundingBox(tmp);
34115 m_cbcLref[cbcId] = (tmp[dimN + nDim] - tmp[dimN]);
34118 && Context::getSolverProperty<MString>(
"cutOffMethod", m_solverId, AT_) ==
"B") {
34119 std::vector<MFloat> cutOffCoordinates;
34120 cutOffCoordinates.resize(2 * nDim);
34121 for(
MInt i = 0; i < (2 * nDim); i++) {
34122 cutOffCoordinates[i] = Context::getSolverProperty<MFloat>(
"cutOffCoordinates", m_solverId, AT_, i);
34124 if(cutOffCoordinates[dimN + nDim] - cutOffCoordinates[dimN] < m_cbcLref[cbcId]) {
34125 m_cbcLref[cbcId] = cutOffCoordinates[dimN + nDim] - cutOffCoordinates[dimN];
34130 m_cbcTurbulence =
false;
34131 m_cbcTurbulence = Context::getSolverProperty<MBool>(
"cbcTurbulenceGeneration", m_solverId, AT_, &m_cbcTurbulence);
34132 if(m_cbcTurbulence) {
34134 if(m_sortedCutOffCells[bcId]->size() > 0) {
34136 mAlloc(m_oldFluctChol, m_sortedCutOffCells[bcId]->size(), nDim,
"m_oldFluctChol", F0, AT_);
34139 if(m_sortedCutOffCells[bcId]->size() < 1)
return;
34141 MInt dirN = dirs[0];
34142 std::vector<MFloat> refPoint;
34143 refPoint.resize(nDim);
34144 m_cbcInflowArea[cbcId] = computeCutoffBoundaryGeometry(bcId, dirN, &refPoint[0]);
34147 m_cbcReferencePoint[cbcId] = refPoint;
34150 m_dirNormal[cbcId].resize(nDim);
34151 m_dirTangent[cbcId].resize(nDim);
34153 m_dirNormal[cbcId][m_cbcDir[cbcId][1]] = 1.0;
34154 m_dirNormal[cbcId][m_cbcDir[cbcId][2]] = 0.0;
34155 IF_CONSTEXPR(nDim == 3) { m_dirNormal[cbcId][m_cbcDir[cbcId][3]] = 0.0; }
34157 m_dirTangent[cbcId][m_cbcDir[cbcId][1]] = 0.0;
34158 m_dirTangent[cbcId][m_cbcDir[cbcId][2]] = 1.0;
34159 IF_CONSTEXPR(nDim == 3) { m_dirTangent[cbcId][m_cbcDir[cbcId][3]] = 0.0; }
34163 for(
MInt n = 0; n < nDim; n++) {
34164 m_dirNormal[cbcId][n] = Context::getSolverProperty<MFloat>(
"cbcNormalDir", m_solverId, AT_, nDim * cbcId + n);
34166 m_dirTangent[cbcId][m_cbcDir[cbcId][1]] =
34167 sqrt(
POW2(m_dirNormal[cbcId][m_cbcDir[cbcId][2]] / m_dirNormal[cbcId][m_cbcDir[cbcId][1]])
34168 / (1 +
POW2(m_dirNormal[cbcId][m_cbcDir[cbcId][2]] / m_dirNormal[cbcId][m_cbcDir[cbcId][1]])));
34169 m_dirTangent[cbcId][m_cbcDir[cbcId][2]] = sqrt(1 -
POW2(m_dirTangent[cbcId][m_cbcDir[cbcId][1]]));
34170 IF_CONSTEXPR(nDim == 3) { m_dirTangent[cbcId][m_cbcDir[cbcId][3]] = 0; }
34173 m_cbcViscous =
false;
34174 m_cbcViscous = Context::getSolverProperty<MBool>(
"cbcViscous", m_solverId, AT_, &m_cbcViscous);
34176 MInt domainMin = domainId();
34177 if(noDomains() > 1) {
34178 MPI_Allreduce(MPI_IN_PLACE, &domainMin, 1, MPI_INT, MPI_MIN, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
34179 "MPI_IN_PLACE",
"domainMin");
34181 m_cbcDomainMin[cbcId] = domainMin;
34183 if(domainId() == m_cbcDomainMin[cbcId]) {
34184 cerr <<
" Characteristic length is " << m_cbcLref[cbcId] << endl;
34185 cerr << bcId <<
" Normal vector is : " << m_dirNormal[cbcId][0] <<
" " << m_dirNormal[cbcId][1] << endl;
34186 IF_CONSTEXPR(nDim == 3) { cerr <<
" " << m_dirNormal[cbcId][2] << endl; }
34187 cerr << bcId <<
" Tangential vector is : " << m_dirTangent[cbcId][0] <<
" " << m_dirTangent[cbcId][1] << endl;
34188 IF_CONSTEXPR(nDim == 3) { cerr <<
" " << m_dirTangent[cbcId][2] << endl; }
34189 cerr << bcId <<
" Inflow normal Area is: " << m_cbcInflowArea[cbcId] << endl;
34192 if(m_cutOffBndryCndIds[bcId] == 109910 || m_cutOffBndryCndIds[bcId] == 109911) {
34196 fn <<
"bc109910.txt";
34198 if(domainId() == m_cbcDomainMin[cbcId]) cerr <<
"loading BC data from " << fname <<
"...";
34201 unData.open(fname);
34202 vector<MFloat> data;
34206 while(unData >> num) {
34207 data.push_back(num);
34211 MInt unDataVarCount = Context::getSolverProperty<MInt>(
"bc109910DataCount", m_solverId, AT_, &unDataVarCount);
34212 m_unTargetDataCount = data.size() / unDataVarCount;
34213 mAlloc(m_unTargetData, m_unTargetDataCount,
"m_unTargetData", AT_);
34215 for(
MInt d = 0; d < m_unTargetDataCount; d++) {
34219 m_unTargetData[d] = make_pair(
y, un);
34225 if(m_cutOffBndryCndIds[bcId] == 109921) {
34229 fn <<
"bc109921.txt";
34231 if(m_solver->domainId() == 0) cerr <<
"loading BC data from " << fname <<
"...";
34234 vnData.open(fname);
34235 vector<MFloat> data;
34239 while(vnData >> num) {
34240 data.push_back(num);
34244 MInt vnDataVarCount = 13;
34245 m_vnTargetDataCount = data.size() / vnDataVarCount;
34246 mAlloc(m_vnTargetData, m_vnTargetDataCount,
"m_vnTargetData", AT_);
34248 for(
MInt d = 0; d < m_vnTargetDataCount; d++) {
34252 m_vnTargetData[d] = make_pair(
y, vn);
34270template <MInt nDim,
class SysEqn>
34274 const MInt minRecDim = nDim + 1;
34275 const MInt medRecDim = 2 * nDim + 1;
34276 const MInt maxRecDim = m_secondOrderRec ? (
IPOW2(nDim) + 2) : minRecDim;
34277 const MInt noBndryCells = m_bndryCells->size();
34278 const MInt maxNoSrfcs = 14;
34279 const MInt volFactor = nDim == 3 ? 4 : 2;
34283 const MInt maxNoNghbrs = 200;
34284 const MFloat condNumThreshold = 1e7;
34285 if(updateOnlyBndryCndId < 0) {
34286 m_log <<
"Initializing small cell RHS treatment." << endl;
34298 MFloat maxCondNum0 = F0;
34299 MFloat maxCondNum1 = F0;
34300 MFloat avgCondNum0 = F0;
34301 MFloat avgCondNum1 = F0;
34305 m_smallCutCells.clear();
34306 for(
MInt bndryId = 0; bndryId < noBndryCells; bndryId++) {
34307 const MInt cellId = m_bndryCells->a[bndryId].m_cellId;
34308 const MInt noSrfcs = m_bndryCells->a[bndryId].m_noSrfcs;
34310 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitClone)) {
34311 gridcellId = m_solver->m_splitChildToSplitCell.find(cellId)->second;
34314 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)) {
34317 if(m_solver->a_hasProperty(cellId, SolverCell::IsNotGradient)) {
34320 if(!m_solver->a_hasProperty(cellId, SolverCell::IsSplitChild) && m_solver->c_noChildren(gridcellId) > 0) {
34323 if(m_solver->a_hasProperty(cellId, SolverCell::IsSplitCell)) {
34326 if(m_solver->a_isPeriodic(cellId)) {
34329 if(m_solver->a_isHalo(cellId)) {
34336 MFloat vfrac = m_solver->a_cellVolume(cellId) / m_solver->grid().gridCellVolume(m_solver->maxLevel());
34337 if(m_solver->m_localTS) {
34338 vfrac = m_solver->a_cellVolume(cellId) / m_solver->grid().gridCellVolume(m_solver->a_level(cellId));
34341 MBool atWall =
false;
34342 for(
MInt srfc = 0; srfc < m_bndryCells->a[bndryId].m_noSrfcs; srfc++) {
34343 if(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId / 1000 == 3) {
34347 MFloat volumeLimit = atWall ? m_volumeLimitWall : m_volumeLimitOther;
34349 if(m_solver->a_level(cellId) < m_solver->maxLevel() && m_solver->m_bndryLevelJumps) {
34350 volumeLimit = volumeLimit * volFactor * (m_solver->maxLevel() - m_solver->a_level(cellId));
34353 if(vfrac < volumeLimit) {
34354 m_smallCutCells.push_back(bndryId);
34357 MBool skip =
false;
34358 if(updateOnlyBndryCndId > -1) {
34360 for(
MInt srfc = 0; srfc < noSrfcs; srfc++) {
34361 if(m_bndryCell[bndryId].m_srfcs[srfc]->m_bndryCndId == updateOnlyBndryCndId) {
34367 if(skip && vfrac < volumeLimit
34368 && m_bndryCell[bndryId].m_cellVarsRecConst.size()
34369 !=
IPOW2(noSrfcs) * m_bndryCell[bndryId].m_recNghbrIds.size()) {
34370 cerr << domainId() <<
": strange skip " <<
cellId <<
" " << m_solver->c_globalId(cellId) << endl;
34378 const MFloat normalizationFactor =
FPOW2(m_solver->a_level(cellId)) / m_solver->c_cellLengthAtLevel(0);
34380 const MInt recSize = m_bndryCell[bndryId].m_recNghbrIds.size();
34381 ASSERT(recSize > 0,
"");
34386 const MInt recDim = maxRecDim;
34387 ASSERT(minRecDim,
"");
34388 ASSERT(medRecDim,
"");
34390 for(
MInt k = noSrfcs + 1; k < recSize; k++) {
34391 MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[k];
34392 MFloat* nghbrCoord = &(m_solver->a_coordinate(nghbrId, 0));
34393 MInt nghbrLevel = m_solver->a_level(nghbrId);
34394 MFloat volume = m_solver->a_cellVolume(nghbrId);
34395 array<MFloat, nDim> deltaX;
34397 for(
MInt i = 0; i < nDim; i++) {
34398 deltaX[i] = (nghbrCoord[i] - m_solver->a_coordinate(cellId, i)) * normalizationFactor;
34399 dx +=
POW2(nghbrCoord[i] - m_solver->a_coordinate(cellId, i));
34402 MFloat vfracNghbr = volume / m_solver->grid().gridCellVolume(nghbrLevel);
34403 weights(k) =
maia::math::RBF(dx,
POW2(m_solver->c_cellLengthAtLevel(m_solver->a_level(cellId))))
34409 for(
MInt i = 0; i < nDim; i++) {
34410 mat(k, cnt) = deltaX[i];
34413 for(
MInt i = 0; i < nDim; i++) {
34414 if(cnt >= recDim) {
34417 mat(k, cnt) = F1B2 *
POW2(deltaX[i]);
34420 for(
MInt i = 0; i < nDim; i++) {
34421 for(
MInt j = i + 1; j < nDim; j++) {
34422 if(cnt >= recDim) {
34425 mat(k, cnt) = deltaX[i] * deltaX[j];
34434 maxCondNum0 =
mMax(maxCondNum0, condNum);
34435 avgCondNum0 += condNum;
34437 if(condNum < F0 || condNum > condNumThreshold) {
34438 cerr <<
"(1) Warning: SVD failed (" << condNum <<
") cell " <<
cellId <<
" (" << m_solver->c_globalId(cellId)
34440 <<
", " << recSize <<
"x" << recDim <<
" vfrac " << setprecision(14)
34441 << m_bndryCells->a[bndryId].m_volume / m_solver->grid().gridCellVolume(m_solver->a_level(cellId))
34442 << setprecision(6) <<
", p13: " << m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel)
34443 <<
", p15: " << m_solver->a_isHalo(cellId) <<
" at timestep " <<
globalTimeStep
34444 <<
", coords: " << m_solver->a_coordinate(cellId, 0) <<
" " << m_solver->a_coordinate(cellId, 10) <<
" "
34445 << m_solver->a_coordinate(cellId,
mMin(nDim - 1, 2)) << endl;
34447 if(rank >= min(recSize, minRecDim)) {
34448 cerr <<
"Succeeded using reduced-order reconstruction." << endl;
34450 cerr <<
"Failed also with reduced-order reconstruction, using fallback solution." << endl;
34454 for(
MInt k = 0; k < recSize; k++) {
34456 for(
MInt i = 0; i < nDim; i++) {
34457 matInv(cnt, k) *= normalizationFactor;
34460 for(cnt = nDim + 1; cnt < recDim; cnt++) {
34461 matInv(cnt, k) *=
POW2(normalizationFactor);
34469 m_bndryCell[bndryId].m_cellVarsRecConst.resize(recSize *
IPOW2(noSrfcs));
34470 for(
MInt p = 0;
p < recSize;
p++) {
34471 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) *
p] = matInv(0, p);
34474 if(condNum < F0 || condNum > condNumThreshold) {
34476 for(
MInt k = 0; k < recSize; k++) {
34477 const MInt nghbrId = m_bndryCell[bndryId].m_recNghbrIds[k];
34478 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k] = F0;
34479 if(k < noSrfcs + 1) {
34482 if(nghbrId == cellId) {
34488 volume = m_solver->a_cellVolume(nghbrId);
34489 for(
MInt i = 0; i < nDim; i++) {
34490 dx +=
POW2(m_solver->a_coordinate(nghbrId, i) - m_solver->a_coordinate(cellId, i));
34492 level = m_solver->a_level(nghbrId);
34494 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k] = fac /
mMax(1e-14, sqrt(dx));
34495 sumcnt += m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k];
34497 for(
MInt k = 0; k < recSize; k++) {
34498 m_bndryCell[bndryId].m_cellVarsRecConst[
IPOW2(noSrfcs) * k] /= sumcnt;
34500 cerr << m_solver->c_globalId(cellId) <<
" has special con.Numer treatment" << endl;
34505 m_log <<
"Small cell treatment average (maximum) condition numbers == Dirichlet stencil: " << avgCondNum0 / condCnt0
34506 <<
" (" << maxCondNum0 <<
"), Neumann stencil: " << avgCondNum1 / condCnt1 <<
" (" << maxCondNum1 <<
")."
34508 MInt noSmallCells = m_smallCutCells.size();
34510 MPI_Allreduce(MPI_IN_PLACE, &noSmallCells, 1, MPI_INT, MPI_SUM, mpiComm(), AT_,
"MPI_IN_PLACE",
"noSmallCells");
34512 m_log <<
"Number of small cut cells for flux redistribution: " << noSmallCells <<
" in solver " << m_solverId
34517template <MInt nDim,
class SysEqn>
34518template <
class _, std::enable_if_t<nDim == 3, _*>>
34521 ASSERT(m_cbcCutOff,
"");
34523 if(m_sortedCutOffCells[bcId]->size() == 0) {
34528 const MBool transversal =
false;
34530 const MInt otherDir[6] = {1, 0, 3, 2, 5, 4};
34532 MBool& first = m_static_cbc1099_1091_engine_first;
34533 MInt& dirN = m_static_cbc1099_1091_engine_dirN;
34534 MInt& dimN = m_static_cbc1099_1091_engine_dimN;
34535 MInt& dimT1 = m_static_cbc1099_1091_engine_dimT1;
34536 MFloat& inflowArea = m_static_cbc1099_1091_engine_inflowArea;
34537 MInt& domainMin = m_static_cbc1099_1091_engine_domainMin;
34539 MFloat(&dirNormal)[3] = m_static_cbc1099_1091_engine_normal;
34540 MFloat(&dirTangent)[3] = m_static_cbc1099_1091_engine_tangent;
34542 MInt& dimT2 = m_static_cbc1099_1091_engine_dimT2;
34547 if(noCutOffDirections != noCutOffBndryIds) {
34549 "Wrong number of cut off directions. Must be identical to number of cut off bndryIds! Please check!");
34551 MInt cutOffBndryIdTmp, cutOffDirectionTmp;
34552 for(
MInt i = 0; i < noCutOffBndryIds; i++) {
34553 cutOffBndryIdTmp = Context::getSolverProperty<MInt>(
"cutOffBndryIds", m_solverId, AT_, i);
34554 cutOffDirectionTmp = Context::getSolverProperty<MInt>(
"cutOffDirections", m_solverId, AT_, i);
34555 if(cutOffBndryIdTmp == m_cutOffBndryCndIds[bcId]) {
34556 dirN = otherDir[cutOffDirectionTmp];
34560 dimN = (
MInt)dirN / 2;
34561 dimT1 = (dimN + 1) % nDim;
34564 MFloat* referencePoint = referencePoint_Scratch.getPointer();
34566 inflowArea = computeCutoffBoundaryGeometry(bcId, dirN, referencePoint);
34568 dimT2 = (dimT1 + 1) % nDim;
34570 domainMin = domainId();
34571 if(noDomains() > 1) {
34572 MPI_Allreduce(MPI_IN_PLACE, &domainMin, 1, MPI_INT, MPI_MIN, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
34573 "MPI_IN_PLACE",
"domainMin");
34579 m_solver->m_geometry->getBoundingBox(tmp1);
34582 MFloat LN1 = (tmp1[dimN + nDim] - tmp1[dimN]);
34584 if(LN1 < m_solver->m_eps || std::isnan(LN1)) {
34585 m_solver->m_geometry->getBoundingBoxMB(tmp1);
34586 LN1 = (tmp1[dimN + nDim] - tmp1[dimN]);
34589 if(domainId() == domainMin) {
34590 cerr <<
" Characteristic length is " << LN1 << endl;
34593 for(
MInt n = 0; n < 3; n++) {
34595 dirTangent[n] = -2;
34611 for(
MInt n = 0; n < nDim; n++) {
34612 dirNormal[n] = Context::getSolverProperty<MFloat>(
"cbcNormalDir", m_solverId, AT_, nDim * bcId + n);
34615 dirTangent[0] = sqrt(
POW2(dirNormal[1] / dirNormal[0]) / (1 +
POW2(dirNormal[1] / dirNormal[0])));
34616 dirTangent[1] = sqrt(1 -
POW2(dirTangent[0]));
34619 if(dirNormal[0] > -2) {
34620 inflowArea = inflowArea * dirTangent[1];
34624 if(domainId() == domainMin && dirNormal[0] > -2) {
34625 cerr << bcId <<
" Normal vector is : " << dirNormal[0] <<
" " << dirNormal[1] <<
" " << dirNormal[2] << endl;
34626 cerr << bcId <<
" Tangential vector is : " << dirTangent[0] <<
" " << dirTangent[1] <<
" " << dirTangent[2]
34628 cerr << bcId <<
" Inflow normal Area is: " << inflowArea << endl;
34632 ASSERT(dimN >= 0 && dimT1 >= 0,
"No initialisation for this rank!");
34643 if(dirN % 2 == 0 && m_solver->m_engineSetup) {
34649 if(dirNormal[0] > -2) {
34655 const MFloat sigma_Inflow = sigma;
34656 const MFloat sigma_Outflow = sigma;
34664 m_solver->m_geometry->getBoundingBox(tmp);
34666 MFloat LN = (tmp[dimN + nDim] - tmp[dimN]);
34668 if(LN < m_solver->m_eps || std::isnan(LN)) {
34669 m_solver->m_geometry->getBoundingBoxMB(tmp);
34670 LN = (tmp[dimN + nDim] - tmp[dimN]);
34673 if(dirN % 2 == 0) {
34682 MFloat M_max = MFloatEps;
34689 MFloat massflux_pos = F0;
34690 MFloat massflux_neg = F0;
34695 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
34698 if(m_solver->a_isHalo(cellId))
continue;
34699 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
34700 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
34702 const MInt bndryId = m_solver->a_bndryId(cellId);
34707 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
34709 area = m_solver->a_surfaceArea(srfcId);
34710 ASSERT(area <=
POW2(m_solver->c_cellLengthAtCell(cellId)),
"");
34713 for(
MInt dir = 0; dir < m_noDirs; dir++) {
34714 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dir];
34715 if(srfcId > -1)
break;
34718 mTerm(1, AT_,
"something went wrong!");
34720 area = m_solver->a_surfaceArea(srfcId);
34723 area =
POW2(m_solver->c_cellLengthAtCell(cellId));
34726 ASSERT(area > 0,
"");
34729 if(dirNormal[0] > -2) {
34730 area = area * dirTangent[1];
34734 m_solver->setPrimitiveVariables(cellId);
34737 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
34738 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
34739 const MFloat T = sysEqn().temperature_ES(rho, p);
34740 const MFloat a = sysEqn().speedOfSound(T);
34742 MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
34744 if(dirNormal[0] > -2) {
34746 for(
MInt n = 0; n < nDim; n++) {
34747 un += m_solver->a_pvariable(cellId, PV->VV[n]) * dirNormal[n];
34751 const MFloat M = fabs(un) /
a;
34756 if(m_solver->checkNeighborActive(cellId, dirN) && m_solver->a_hasNeighbor(cellId, dirN)) {
34757 const MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
34759 if(dirNormal[0] > -2) {
34760 for(
MInt n = 0; n < nDim; n++) {
34761 un_N += m_solver->a_variable(nghbrN, CV->RHO_VV[n]) / m_solver->a_variable(nghbrN, CV->RHO) * dirNormal[n];
34764 un_N = m_solver->a_variable(nghbrN, CV->RHO_VV[dimN]) / m_solver->a_variable(nghbrN, CV->RHO);
34767 if(std::isnan(un_N)) {
34768 cerr <<
"NAN detected in cutOff-Neighbor! " << endl;
34771 T_N = sysEqn().temperature_ES(m_solver->a_variable(nghbrN, CV->RHO), m_solver->a_pvariable(nghbrN, PV->P));
34774 if(rho < F0 || std::isnan(rho) || std::isnan(un)) {
34775 cerr <<
"NAN detected in cutOff-Cell " << m_solver->c_globalId(cellId) <<
" " << m_solver->a_isHalo(cellId) <<
" "
34776 << m_solver->a_bndryId(cellId) <<
" " << rho <<
" " << bcId << endl;
34780 massflux_pos += un_N * area;
34783 massflux_neg += un_N * area;
34787 M_max =
mMax(M_max, M);
34788 M_mean += fabs(M) * area;
34790 massflux += un_N * area;
34791 T_mean += T_N * area;
34792 rho_mean += rho * area;
34793 rho_min =
mMin(rho, rho_min);
34794 rho_max =
mMax(rho, rho_max);
34797 if(noDomains() > 1) {
34798 const MInt noExchangeData = 8;
34801 comm_buff[0] = massflux;
34802 comm_buff[1] = M_mean;
34803 comm_buff[2] = T_mean;
34804 comm_buff[3] = massflux_pos;
34805 comm_buff[4] = massflux_neg;
34806 comm_buff[5] = rho_mean;
34807 comm_buff[6] = area_pos;
34808 comm_buff[7] = area_neg;
34810 if(noDomains() > 1) {
34811 MPI_Allreduce(MPI_IN_PLACE, &comm_buff[0], noExchangeData, MPI_DOUBLE, MPI_SUM,
34812 m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
"MPI_IN_PLACE",
"comm_buff[0]");
34813 MPI_Allreduce(MPI_IN_PLACE, &M_max, 1, MPI_DOUBLE, MPI_MAX, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
34814 "MPI_IN_PLACE",
"M_max");
34815 MPI_Allreduce(MPI_IN_PLACE, &rho_max, 1, MPI_DOUBLE, MPI_MAX, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
34816 "MPI_IN_PLACE",
"rho_max");
34817 MPI_Allreduce(MPI_IN_PLACE, &rho_min, 1, MPI_DOUBLE, MPI_MIN, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
34818 "MPI_IN_PLACE",
"rho_min");
34821 massflux = comm_buff[0];
34822 M_mean = comm_buff[1];
34823 T_mean = comm_buff[2];
34824 massflux_pos = comm_buff[3];
34825 massflux_neg = comm_buff[4];
34826 rho_mean = comm_buff[5];
34827 area_pos = comm_buff[6];
34828 area_neg = comm_buff[7];
34831 M_mean /= inflowArea;
34832 T_mean /= inflowArea;
34833 rho_mean /= inflowArea;
34834 const MFloat p_mean = sysEqn().pressure_ES(T_mean, rho_mean);
34842 MFloat T_out = sysEqn().temperature_IR(massflux / inflowArea);
34843 MFloat p_out = sysEqn().pressure_IR(T_out);
34847 if(p_out / sysEqn().p_Ref() > 1) p_out = sysEqn().p_Ref();
34848 if(T_out > 1) T_out = 1;
34851 const MFloat p_target = p_out;
34852 MFloat T_target = T_out;
34853 if(dirN % 2 == 0) {
34861 if( m_solver->m_RKStep == 0 && domainId() == domainMin) {
34863 <<
" M_mean, M_max, T_target, p_target, rho_mean, massflux, T_mean, rho_min, rho_max" << setprecision(9)
34864 << M_mean <<
", " << M_max <<
", " << T_target <<
", " << p_target <<
", " << rho_mean <<
", " << rho_min
34865 <<
", " << rho_max <<
", " << massflux <<
" " << T_mean << endl;
34868 const MFloat flux = massflux / inflowArea;
34869 const MFloat flux_pos = area_pos > 0 ? massflux_pos / area_pos : F0;
34870 const MFloat flux_neg = area_neg > 0 ? massflux_neg / area_neg : F0;
34871 cerr <<
"Mean flux " << flux <<
" positive flux " << flux_pos <<
" negative flux " << flux_neg << endl;
34875 ASSERT(!std::isnan(massflux),
"ERROR: Mass-flux is nan!");
34882 MInt noInflowCells = 0;
34883 MInt totalNoCutOffCell = 0;
34885 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
34888 if(m_solver->a_isHalo(cellId))
continue;
34889 if(!m_solver->a_hasProperty(cellId, SolverCell::IsOnCurrentMGLevel))
continue;
34890 if(m_solver->a_hasProperty(cellId, SolverCell::IsInactive))
continue;
34899 if(m_solver->checkNeighborActive(cellId, dirN) && m_solver->a_hasNeighbor(cellId, dirN)) {
34900 const MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
34902 if(dirNormal[0] > -2) {
34903 for(
MInt n = 0; n < nDim; n++) {
34904 un_N += m_solver->a_variable(nghbrN, CV->RHO_VV[n]) * dirNormal[n];
34905 ut_N += m_solver->a_variable(nghbrN, CV->RHO_VV[n]) * dirTangent[n];
34907 ut2_N = m_solver->a_variable(nghbrN, CV->RHO_VV[dimT2]);
34910 un_N = m_solver->a_variable(nghbrN, CV->RHO_VV[dimN]);
34911 ut_N = m_solver->a_variable(nghbrN, CV->RHO_VV[dimT1]);
34912 ut2_N = m_solver->a_variable(nghbrN, CV->RHO_VV[dimT2]);
34915 un_N2 = m_solver->a_variable(nghbrN, CV->RHO_VV[dimN]);
34927 const MFloat p = m_solver->a_pvariable(cellId, PV->P);
34928 const MFloat rho = m_solver->a_pvariable(cellId, PV->RHO);
34929 const MFloat T = sysEqn().temperature_ES(rho, p);
34930 const MFloat a = sysEqn().speedOfSound(T);
34932 MFloat un = m_solver->a_pvariable(cellId, PV->VV[dimN]);
34933 MFloat ut1 = m_solver->a_pvariable(cellId, PV->VV[dimT1]);
34935 MFloat dpdn = m_solver->a_slope(cellId, PV->P, dimN);
34936 MFloat dpdt1 = m_solver->a_slope(cellId, PV->P, dimT1);
34938 MFloat drhodn = m_solver->a_slope(cellId, PV->RHO, dimN);
34939 MFloat drhodt1 = m_solver->a_slope(cellId, PV->RHO, dimT1);
34941 MFloat dundn = m_solver->a_slope(cellId, PV->VV[dimN], dimN);
34942 MFloat dundt1 = m_solver->a_slope(cellId, PV->VV[dimN], dimT1);
34944 MFloat dut1dn = m_solver->a_slope(cellId, PV->VV[dimT1], dimN);
34945 MFloat dut1dt1 = m_solver->a_slope(cellId, PV->VV[dimT1], dimT1);
34947 const MFloat ut2 = m_solver->a_pvariable(cellId, PV->VV[dimT2]);
34949 MFloat dpdt2 = m_solver->a_slope(cellId, PV->P, dimT2);
34950 MFloat drhodt2 = m_solver->a_slope(cellId, PV->RHO, dimT2);
34951 MFloat dut2dt2 = m_solver->a_slope(cellId, PV->VV[dimT2], dimT2);
34953 MFloat dut2dn = m_solver->a_slope(cellId, PV->VV[dimT2], dimN);
34955 MFloat dundt2 = m_solver->a_slope(cellId, PV->VV[dimN], dimT2);
34956 MFloat dut1dt2 = m_solver->a_slope(cellId, PV->VV[dimT1], dimT2);
34958 MFloat dut2dt1 = m_solver->a_slope(cellId, PV->VV[dimT2], dimT1);
34963 if(dirNormal[0] > -2) {
34978 for(
MInt n = 0; n < nDim; n++) {
34979 un += m_solver->a_pvariable(cellId, PV->VV[n]) * dirNormal[n];
34980 ut1 += m_solver->a_pvariable(cellId, PV->VV[n]) * dirTangent[n];
34984 if(m_solver->checkNeighborActive(cellId, dirN) && m_solver->a_hasNeighbor(cellId, dirN)) {
34985 const MInt nghbrN = m_solver->c_neighborId(cellId, dirN);
34987 dpdn = m_solver->a_slope(cellId, PV->P, dimN) * dirNormal[dimN];
34988 drhodn = m_solver->a_slope(cellId, PV->RHO, dimN) * dirNormal[dimN];
34989 dundn = m_solver->a_slope(cellId, PV->VV[dimN], dimN) * dirNormal[dimN];
34990 dut1dn = m_solver->a_slope(cellId, PV->VV[dimT1], dimN) * dirNormal[dimN];
34991 dut2dn += m_solver->a_slope(cellId, PV->VV[dimT2], dimN) * dirNormal[dimN];
34993 for(
MInt n = 0; n < nDim; n++) {
34994 if(n == dimN)
continue;
34995 un += m_solver->a_pvariable(nghbrN, PV->VV[n]) * dirNormal[n];
34996 dpdn += m_solver->a_slope(nghbrN, PV->P, n) * dirNormal[n];
34997 drhodn += m_solver->a_slope(nghbrN, PV->RHO, n) * dirNormal[n];
34998 dundn += m_solver->a_slope(nghbrN, PV->VV[dimN], n) * dirNormal[n];
34999 dut1dn += m_solver->a_slope(nghbrN, PV->VV[dimT1], n) * dirNormal[n];
35000 dut2dn += m_solver->a_slope(nghbrN, PV->VV[dimT2], n) * dirNormal[n];
35004 for(
MInt n = 0; n < nDim; n++) {
35005 dpdn += m_solver->a_slope(cellId, PV->P, n) * dirNormal[n];
35006 drhodn += m_solver->a_slope(cellId, PV->RHO, n) * dirNormal[n];
35008 dpdt1 += m_solver->a_slope(cellId, PV->P, n) * dirTangent[n];
35009 drhodt1 += m_solver->a_slope(cellId, PV->RHO, n) * dirTangent[n];
35011 dundn += m_solver->a_slope(cellId, PV->VV[dimN], n) * dirNormal[n];
35012 dut1dn += m_solver->a_slope(cellId, PV->VV[dimT1], n) * dirNormal[n];
35014 dundt1 += m_solver->a_slope(cellId, PV->VV[dimN], n) * dirTangent[n];
35015 dut1dt1 += m_solver->a_slope(cellId, PV->VV[dimT1], n) * dirTangent[n];
35017 dut2dn += m_solver->a_slope(cellId, PV->VV[dimT2], n) * dirNormal[n];
35018 dut2dt1 += m_solver->a_slope(cellId, PV->VV[dimT2], n) * dirTangent[n];
35023 MBool upperBndry =
false;
35024 for(
MInt n = m_solver->a_noReconstructionNeighbors(cellId); n--;) {
35025 MInt recNghbr = m_solver->a_reconstructionNeighborId(cellId, n);
35026 if(m_solver->a_isBndryGhostCell(recNghbr)
35036 MFloat Sum_u = un * un + ut1 * ut1;
35039 Sum_u = Sum_u + ut2 * ut2;
35042 const MFloat E = sysEqn().internalEnergy(p, rho, Sum_u);
35044 MFloat Sum_du = un * dundt1 + ut1 * dut1dt1;
35045 Sum_du = Sum_du + ut2 * dut2dt1;
35047 MFloat dEdt1 = sysEqn().cp_Ref() * (F1 / rho * dpdt1 -
p /
POW2(rho) * drhodt1) + (Sum_du);
35048 MFloat dEdt2 = sysEqn().cp_Ref() * (F1 / rho * dpdt2 -
p /
POW2(rho) * drhodt2)
35049 + (un * dundt2 + ut1 * dut1dt2 + ut2 * dut2dt2);
35054 const MInt bndryId = m_solver->a_bndryId(cellId);
35058 MInt srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dirN];
35060 area = m_solver->a_surfaceArea(srfcId);
35062 for(
MInt dir = 0; dir < m_noDirs; dir++) {
35063 srfcId = m_bndryCells->a[bndryId].m_associatedSrfc[dir];
35069 mTerm(1, AT_,
"something went wrong!");
35071 area = m_solver->a_surfaceArea(srfcId);
35074 area =
POW2(m_solver->c_cellLengthAtCell(cellId));
35078 if(dirNormal[0] > -2) {
35079 area = area * dirTangent[1];
35082 pTotal += area * (
p / sysEqn().p_Ref() + F1B2 * rho * sqrt(Sum_u));
35086 const MFloat lambda1 = (un -
a);
35087 const MFloat lambda2 = un;
35088 const MFloat lambda5 = (un +
a);
35089 MFloat L1 = lambda1 * (dpdn - rho *
a * dundn);
35090 MFloat L2 = lambda2 * (
a *
a * drhodn - dpdn);
35091 MFloat L3 = lambda2 * (dut1dn);
35092 MFloat L5 = lambda5 * (dpdn + rho *
a * dundn);
35093 MFloat L4 = lambda2 * (dut2dn);
35096 MFloat T1 = -rho * (dut1dt1)-ut1 * drhodt1;
35097 MFloat T2 = -ut1 * dundt1;
35098 MFloat T3 = -ut1 * dut1dt1 - F1 / rho * dpdt1;
35099 MFloat T5 = -ut1 * dpdt1 -
p / sysEqn().p_Ref() * dut1dt1;
35101 T1 += -rho * dut2dt2 - ut2 * drhodt2;
35102 T2 += -ut2 * dundt2;
35103 T3 += -ut2 * dut1dt2;
35104 MFloat T4 = -ut1 * dut2dt1 - ut2 * dut2dt2 - F1 / rho * dpdt2;
35105 T5 += -ut2 * dpdt2 -
p / sysEqn().p_Ref() * dut2dt2;
35126 if(dirNormal[0] > -2 || !transversal) {
35134 MBool isInflow =
true;
35135 totalNoCutOffCell++;
35137 if(dirN % 2 == 0) {
35152 const MFloat K1 = sigma_Inflow *
a * (1 - M_max * M_max) / LN;
35153 const MFloat K2 = eta2 * rho *
a / LN;
35154 const MFloat K3 = eta3 *
a / LN;
35156 if(dirN % 2 == 0) {
35157 L1 = K1 * (
p - p_target) + (T5 - rho *
a * T2);
35159 L5 = K1 * (
p - p_target) + (T5 + rho *
a * T2);
35161 L2 = K2 * (T - T_target) + (
a *
a * T1 - T5);
35162 L3 = K3 * ut1 + T3;
35163 L4 = K3 * ut2 + T4;
35165 MBool limitVariable =
false;
35166 if(m_solver->a_pvariable(cellId, PV->RHO) > 1.0000001) {
35167 m_solver->a_pvariable(cellId, PV->RHO) = 1;
35168 limitVariable =
true;
35170 if(m_solver->a_pvariable(cellId, PV->P) / sysEqn().p_Ref() > 1.0000001) {
35171 m_solver->a_pvariable(cellId, PV->P) = sysEqn().p_Ref();
35172 limitVariable =
true;
35175 if(limitVariable) {
35176 m_solver->setConservativeVariables(cellId);
35181 MFloat K1 = sigma_Outflow *
a * (1 - M_max * M_max) / LN;
35182 const MFloat beta = M_mean;
35190 if(!m_solver->m_engineSetup) {
35196 if(fabs(un_N2) > 0.05 && fabs(massflux) > 0.05) {
35203 const MFloat K3 = eta3 *
a * 10 / LN;
35204 L3 = K3 * ut1 + T3;
35205 L4 = K3 * ut2 + T4;
35212 if(dirN % 2 == 0) {
35214 L1 = K1 * (
p - p_target) + (F1 - beta) * (T5 - rho *
a * T2);
35216 L5 = K1 * (
p - p_target) + (F1 - beta) * (T5 + rho *
a * T2);
35221 MBool walllike =
false;
35222 if(eddy > 1 && dirN % 2 == 0) walllike =
true;
35225 if(fabs(un_N2) < 0.005 ) {
35230 if(walllike && m_solver->m_engineSetup) {
35231 const MFloat K2_outflow = -sigma * rho *
a / LN;
35232 L2 = K2_outflow * (T - T_target) + (
a *
a * T1 - T5);
35234 if(dirN % 2 == 0 && eddy < 1) {
35235 const MFloat K3 = eta3 *
a / LN;
35236 L3 = K3 * ut1 + T3;
35237 L4 = K3 * ut2 + T4;
35249 if((abs(m_solver->a_pvariable(cellId, PV->W)) > 0.005 || abs(m_solver->a_pvariable(cellId, PV->U)) > 0.3)
35250 && m_solver->crankAngle(m_solver->m_physicalTime, 0) > 240) {
35255 cerr <<
"Limiting-cell " << m_solver->a_coordinate(cellId, 1) <<
" " << m_solver->a_coordinate(cellId, nDim - 1)
35256 <<
" " << upperBndry <<
" " << m_solver->a_pvariable(cellId, PV->U) << endl;
35260 m_solver->a_pvariable(cellId, PV->P) = 0.71428;
35261 m_solver->a_pvariable(cellId, PV->RHO) = 1;
35262 m_solver->a_pvariable(cellId, PV->VV[2]) = 0;
35263 m_solver->a_pvariable(cellId, PV->VV[0]) = 0.01 * dirNormal[0];
35264 m_solver->a_pvariable(cellId, PV->VV[1]) = 0.01 * dirNormal[1];
35272 m_solver->setConservativeVariables(cellId);
35275 if(abs(m_solver->a_pvariable(cellId, PV->W)) > 0.005) {
35276 m_solver->a_pvariable(cellId, PV->P) = p_mean;
35277 m_solver->a_pvariable(cellId, PV->RHO) = rho_mean;
35278 m_solver->a_pvariable(cellId, PV->VV[2]) = 0;
35279 if(m_solver->crankAngle(m_solver->m_physicalTime, 0) < 170) {
35280 m_solver->a_pvariable(cellId, PV->VV[0]) = 0.01 * dirNormal[0];
35281 m_solver->a_pvariable(cellId, PV->VV[1]) = 0.01 * dirNormal[1];
35290 cerr <<
"Limiting-cell " << m_solver->a_coordinate(cellId, 1) <<
" " << m_solver->a_coordinate(cellId, nDim - 1)
35291 <<
" " << upperBndry << endl;
35293 m_solver->setConservativeVariables(cellId);
35299 if(upperBndry && dirNormal[0] > -2) {
35302 if(dirN % 2 == 0) {
35332 const MFloat K3 = sigma *
a / LN;
35333 L3 = K3 * ut1 + T3;
35334 L4 = K3 * ut2 + T4;
35337 const MFloat K2_outflow = -sigma * rho *
a / LN;
35338 L2 = K2_outflow * (T - T_target) + (
a *
a * T1 - T5);
35385 MFloat d1 = F1 / (
a *
a) * (L2 + F1B2 * (L5 + L1));
35386 MFloat d2 = F1B2 * (L5 + L1);
35387 MFloat d3 = F1B2 / (rho *
a) * (L5 - L1);
35393 if(dirNormal[0] > -2) {
35394 d1 = dirNormal[0] * F1 / (
a *
a) * L2 + dirNormal[1] * L4 - dirNormal[2] * L3 + F1B2 * F1 / (
a *
a) * (L5 + L1);
35396 const MFloat d3_old = d3;
35397 d3 = dirNormal[0] * d3_old - dirNormal[2] * L4 - dirNormal[1] * L3;
35398 d4 = dirNormal[0] * L3 + dirNormal[1] * d3_old + dirNormal[2] * F1 / (
a *
a) * L2;
35399 d5 = dirNormal[0] * L4 + dirNormal[2] * d3_old - dirNormal[1] * F1 / (
a *
a) * L2;
35403 MFloat rhs_rho = -d1 - rho * (dut1dt1)-ut1 * drhodt1;
35405 MFloat rhs_rhoun = -un * d1 - rho * (d3 + un * dut1dt1 + ut1 * dundt1) - un * (ut1 * drhodt1);
35407 MFloat rhs_rhout1 = -ut1 * d1 - rho * (d4 + F2 * ut1 * dut1dt1) - ut1 * (ut1 * drhodt1) - dpdt1;
35409 MFloat rhs_rhoe = -F1B2 * (
POW2(un) +
POW2(ut1)) * d1 - d2 * sysEqn().cp_Ref() - rho * (un * d3 + ut1 * d4)
35410 - ut1 * (rho * dEdt1 + E * drhodt1 + dpdt1) - (rho * E +
p) * dut1dt1;
35412 rhs_rho += -rho * dut2dt2 - ut2 * drhodt2;
35415 rhs_rhoun += -rho * (un * dut2dt2 + ut2 * dundt2) - un * ut2 * drhodt2;
35418 rhs_rhout1 += -rho * (ut1 * dut2dt2 + ut2 * dut1dt2) - ut1 * ut2 * drhodt2;
35421 MFloat rhs_rhout2 = -ut2 * d1 - rho * (d5 + ut2 * dut1dt1 + ut1 * dut2dt1 + F2 * ut2 * dut2dt2)
35422 - ut2 * (ut1 * drhodt1 + ut2 * drhodt2) - dpdt2;
35426 -F1B2 * (
POW2(ut2)) * d1 - rho * ut2 * d5 - ut2 * (rho * dEdt2 + E * drhodt2 + dpdt2) - (rho * E +
p) * dut2dt2;
35430 if(dirNormal[0] > -2 || !transversal) {
35432 rhs_rhoun = -un * d1 - rho * d3;
35433 rhs_rhout1 = -ut1 * d1 - rho * d4;
35434 rhs_rhoe = -F1B2 * (
POW2(un) +
POW2(ut1)) * d1 - d2 * sysEqn().cp_Ref() - rho * (un * d3 + ut1 * d4);
35435 rhs_rhout2 = -ut2 * d1 - rho * d5;
35436 rhs_rhoe += -F1B2 *
POW2(ut2) * d1 - rho * ut2 * d5;
35440 m_solver->a_rightHandSide(cellId, CV->RHO) = -m_solver->a_cellVolume(cellId) * rhs_rho;
35441 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimN]) = -m_solver->a_cellVolume(cellId) * rhs_rhoun;
35442 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT1]) = -m_solver->a_cellVolume(cellId) * rhs_rhout1;
35443 m_solver->a_rightHandSide(cellId, CV->RHO_E) = -m_solver->a_cellVolume(cellId) * rhs_rhoe;
35444 m_solver->a_rightHandSide(cellId, CV->RHO_VV[dimT2]) = -m_solver->a_cellVolume(cellId) * rhs_rhout2;
35448 if(noDomains() > 1) {
35449 MPI_Allreduce(MPI_IN_PLACE, &pTotal, 1, MPI_DOUBLE, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
35450 "MPI_IN_PLACE",
"pTotal");
35452 MPI_Allreduce(MPI_IN_PLACE, &noInflowCells, 1, MPI_INT, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
35453 "MPI_IN_PLACE",
"noInflowCells");
35455 MPI_Allreduce(MPI_IN_PLACE, &totalNoCutOffCell, 1, MPI_INT, MPI_SUM, m_comm_bcCo[m_bcCo_comm_pointer[bcId]], AT_,
35456 "MPI_IN_PLACE",
"totalNoCutOffCell");
35459 pTotal /= inflowArea;
35461 if(dirN % 2 == 0 && domainId() == domainMin) {
35462 cerr <<
"Average total pressure at outlet is: " << pTotal << endl;
35463 }
else if(domainId() == domainMin) {
35464 cerr <<
"Average total pressure at inlet is: " << pTotal << endl;
35468 if(dirN % 2 == 1 && domainId() == domainMin) {
35469 cerr <<
"Inflow cell percentage: " << ratio <<
" at inlet!" << endl;
35470 }
else if(domainId() == domainMin) {
35471 cerr <<
"Inflow cell percentage: " << ratio <<
" at outlet!" << endl;
35476template <MInt nDim,
class SysEqn>
35483 fn <<
"bc30022.txt";
35485 if(m_solver->domainId() == 0) cerr <<
"loading BC data from " << fname <<
"...";
35488 vnData.open(fname);
35489 vector<MFloat> data;
35493 while(vnData >> num) {
35494 data.push_back(num);
35499 MInt horDataVarCount = Context::getSolverProperty<MInt>(
"bc30022DataCount", m_solverId, AT_, &horDataVarCount);
35500 MInt horTargetDataCount = data.size() / horDataVarCount;
35502 mAlloc(m_horTargetData, m_sortedCutOffCells[bcId]->size(), 3,
"m_horTargetData", F0, AT_);
35504 for(
MInt d = 0; d < horTargetDataCount - 1; d++) {
35505 MInt index1 = horDataVarCount * d;
35506 MInt index2 = horDataVarCount * (d + 1);
35507 MFloat xTarget1 = data[index1];
35508 MFloat xTarget2 = data[index2];
35509 MFloat uTarget1 = data[index1 + 1];
35510 MFloat uTarget2 = data[index2 + 1];
35511 MFloat vTarget1 = data[index1 + 2];
35512 MFloat vTarget2 = data[index2 + 2];
35513 MFloat rhoTarget1 = data[index1 + 3];
35514 MFloat rhoTarget2 = data[index2 + 3];
35516 for(
MInt id = 0;
id < m_sortedCutOffCells[bcId]->size();
id++) {
35518 MFloat x = m_solver->a_coordinate(cellId, 0);
35519 if(xTarget2 > x && xTarget1 <= x) {
35520 m_horTargetData[
id][0] = uTarget1 + (uTarget2 - uTarget1) / (xTarget2 - xTarget1) * (x - xTarget1);
35521 m_horTargetData[
id][1] = vTarget1 + (vTarget2 - vTarget1) / (xTarget2 - xTarget1) * (x - xTarget1);
35522 m_horTargetData[
id][2] = rhoTarget1 + (rhoTarget2 - rhoTarget1) / (xTarget2 - xTarget1) * (x - xTarget1);
MLong allocatedBytes()
Return the number of allocated bytes.
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
MBool mDeallocate(T *&a)
deallocates the memory previously allocated for element 'a'
MInt m_regenerationInterval
MBool m_regenerateSeeding
void checkRegeneration(const MFloat time)
Bc1601Class(MPI_Comm &communicator, const MInt m_solverId, const MInt domainId, MFloat &u_total, MFloat &invSigmaSponge)
void generateAndCommRandomNumbers()
Bc1601Class functions:
void calculateFlucts(const MFloat that, const MFloat xhat, const MFloat yhat, const MFloat zhat, MFloat *fluctChol)
MBool loadRandomNumbers()
MInt m_regenerationCounter
static MInt propertyLength(const MString &name, MInt solverId=m_noSolvers)
Returns the number of elements of a property.
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
static MInt staticElementSize()
void storeBoundaryVariables()
void addBesselModes(MInt)
virtual void generateBndryCells()
generate finite-volume boundary cells
void cbc1099_1091_local_comb(MInt)
void cbc1091b_after(MInt)
Subsonic fully reflecting characteristic inflow condition - cut off - sets T0,u,v to prescribed value...
void cbc1099_1091_local(MInt)
void allocateCutOffMemory()
allocates the cut off list memory
void cbcRHS(MInt, MInt, MFloat *, MFloat *, MFloat *)
Calculates the right hand side.
virtual void bc19520(MInt)
void recorrectCellCoordinates()
void sbc2801y(MInt)
Solid wall Navier-Stokes boundary condition Computes ghost cell slopes for the viscous flux computati...
void sbc1000co(const MInt)
Cut off condition for the slopes.
void sbc00co(const MInt)
Cut off condition for the slopes.
void computeTetra(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
void updateCutOffSlopesViscous()
void cbc1091e_after(MInt)
Subsonic fully reflecting characteristic inflow condition - cut off - sets T0,u,v to prescribed value...
void cbc1099a_after(MInt)
Subsonic fully reflecting characteristic outflow condition - cut off - sets pstat to prescribed value...
void calcBesselFractions(const MFloat, const MFloat, const MFloat, MFloat &, MFloat &)
void plotAllCutPoints()
writes a .vtk file containing all cut points stored on the cut cells
void initCutOffBndryCnds()
void sbc2720co(MInt)
Cut off condition for the slopes copys the slopes, and sets pressure slope to sero NOTIMPLEMENTED ver...
void cbcDampingOutflow(MInt, MInt, MFloat, MFloat *)
Calculates the outflow damping terms.
void cbc1099_1091d_after(MInt)
void bcNeumannMb(MInt)
Moving boundary Neumann condition.
void cbc109911(MInt)
Characteristic boundary condition. Outflow. Prescribed: p. Partially Refelecting.
void copyRHSIntoGhostCells()
virtual void bc2001(MInt)
void initBesselModes(MInt)
void bcNeumannIsothermalUnburntProfileH(MInt)
Computes the p and rho slopes on boundary cells using the least-squares method and setting implicitel...
virtual void bc1801(MInt)
void sbc2001(MInt)
Solid wall Navier-Stokes boundary condition Computes ghost cell slopes for the viscous flux computati...
void bcInit2700(MInt)
init for the acoustic and entropy waves
virtual void sbc2710co(MInt)
void initSmallCellCorrection(MInt updateOnlyBndryCndId=-1)
Initialize the small-cell correction for the flux-redistribution method The cell vars are computed us...
virtual void bc1901(MInt)
void updateCutOffSlopesInviscid()
void updateGhostCellSlopesViscous()
void cbcViscousTerms(MInt, MInt, MFloat *, MFloat *, MFloat *, MFloat *, MInt *, MFloat *)
Calculates the outgoing viscous terms V.
void checkBoundaryCells()
void setGapGhostCellVariables(MInt bcId)
update ghostCell variables for gap-Cells
void bcInit0004(MInt)
Sets up the reconstruction stencil for boundary cells (quadratic least-squares reconstruction)
void deleteBndryCell(MInt)
Deletes a boundary cell (without collector fragmentation)
void cbcGradients(MInt, MInt, MFloat *, MFloat *, MFloat *, MFloat *)
Calculates the gradients of the cbcCell.
void cbc2099_1091_local_comb(MInt)
void bcNeumannIsothermalUnburntProfile(MInt)
Computes the p and rho slopes on boundary cells using the least-squares method and setting implicitel...
void updateCutOffCellVariables()
void bcNeumannIsothermalBurntProfileH(MInt)
Computes the p and rho slopes on boundary cells using the least-squares method and setting implicitel...
MFloat * vecScalarMul(MFloat, MFloat *, MFloat *)
virtual void bc2770(MInt)
virtual void bc1003(MInt)
void computeTri(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
void cbcMeanPressureCo(MInt, MFloat *)
void detectSmallBndryCells()
Detects small cells and identifies a master cell Calls mergeCell to merge master and small cell.
void markCutOff(MIntScratchSpace &cutOffCells)
void computePlaneVectors()
uses Gram-Schmidt to compute orthonormal vectors in the cut plane
void createCutFace()
computes the geometry of each the cut cells (2D version) 2 cut points are assumed for each boundary c...
FvBndryCndXD(FvCartesianSolverXD< nDim, SysEqn > *solver)
MBool checkInside(MInt)
checks if all corners of a cell are located in the computational domain
void bcInit0002(MInt)
Sets up the reconstruction stencil for boundary cells.
void cbcTurbulenceInjection(MInt, MFloat *, MInt)
Turbulence injection (identical to bc1601) adjusted for Taylor's Hypothesis for cbc.
void computeCutPoints()
computes the cut points where a boundary cell intersects with the geometry computes the following bou...
void correctCellCoordinates()
void computeReconstructionConstants_interpolation()
void cbc1099_1091_engineOld(MInt)
void exchangeCutOffBoundaryCells()
exchanges the cut off boundary cells and adds them to the accordings cut off boundary lists
void cbcGradientsViscous(MInt, MInt, MFloat *, MFloat *, MFloat *, MFloat *, MInt *)
Calculates the viscous gradients of the cbcCell.
void correctBoundarySurfaceVariablesMGC()
corrects the left and right variables values on the boundary surface
MFloat computeCutoffBoundaryGeometry(const MInt, const MInt, MFloat *)
computes centroid and radius (return parameter) of a cut-off boundary surface assumes that the surfac...
void correctBoundarySurfaceVariablesMGCSurface()
corrects the left and right variables values on the boundary surface
void computePoly5(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
void correctMasterSlaveSurfaces()
Removes surfaces between master-slave pairs and reassigns slave cell surfaces.
virtual void bc3037MGC(MInt)
void computeImagePointRecConst(MInt updateOnlyBndryCndId=-1)
virtual void bc2003(MInt)
virtual void bc10990(MInt)
void updateGhostCellVariables()
void correctNormal(MFloat *)
void writeStlOfNodes(MInt, MInt *&, const char *)
void getFeatureEdges(MInt &, MFloat **&, MInt, MInt *&, MFloat *&, MFloat *&)
void cbc1099_1091_engine(MInt)
void correctCell(MFloat *, MFloat *, MFloat *, MFloat *)
void computeMirrorCoordinates(MInt, MFloat *, MInt)
void addBoundarySurfacesMGC()
adds a surface for the ghost-boundary cell intersections
void cbc109921(MInt)
Characteristic boundary condition. Outflow. Prescribed: p. Partially Refelecting.
void getIntersectionPoints(MFloat **&, MFloat **&, MInt, MInt, MFloat **&, MInt &)
MFloat updateImagePointVariables(MInt)
Updates the image point variables used with multiple ghost cell formulation.
void bcNeumannIsothermal(MInt)
Computes the p and rho slopes on boundary cells using the least-squares method and setting implicitel...
void plotIntersectionPoints(MInt *, MFloat ***&)
void createCutFaceMGC()
ONLY 3D VERSIONS.
void correctCoarseBndryCells()
void correctFace(MFloat *, MFloat *, MFloat *, MFloat *)
void bcNeumannIsothermalBurntProfile(MInt)
Computes the p and rho slopes on boundary cells using the least-squares method and setting implicitel...
virtual void bc1401(MInt)
void updateRHSSmallCells()
void correctInflowBoundary(MInt)
MFloat * vecSub(MFloat *, MFloat *, MFloat *)
void resetCutOffFirst()
reset first for cutOffBndryCnd, this is necessary after a balance!
void plotTriangle(std::ofstream &, MFloat *, MFloat *, MFloat *, MFloat *)
void cbc1091c_after(MInt)
Subsonic fully reflecting characteristic inflow condition - cut off - sets T0,u,v to prescribed value...
void checkCutPointsValidity()
checks the validity of a boundary cell
void plotEdges(MInt &, MFloat **&)
void addModes(MInt)
supersonic inflow with imposed onlique shock wave version: cut-off boundary condition author: Thomas ...
void computeNeumannLSConstants(MInt)
Sets up the reconstruction stencil for boundary cells.
void cbcTransversalTerms(MInt, MInt, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
Calculates the transversal correction terms T.
void computePoly4(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
void applyNonReflectingBCCutOff()
virtual void bc2002(MInt)
void computePoly6(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
void detectSmallBndryCellsMGC()
Detects small cells and identifies a master cell Calls mergeCell to merge master and small cell.
MInt createSplitCell_MGC(MInt, MInt)
produces an exact copy of a fvcell and the respective boundary cell
void cbcOutgoingAmplitudeVariation(MInt, MInt, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
Calculates the outgoing terms wave amplitude variation L.
void setBCTypes(MInt updateOnlyBndryCndId=-1)
void cbcDampingInflow(MInt, MInt, MFloat, MFloat *, MString)
Calculates the inflow damping terms.
void exchangeComputedCutPoints()
void createBndryCndHandler()
creates pointers to the boundary conditions
void applyNeumannBoundaryCondition()
void updateGhostCellSlopesInviscid()
void checkCutPointsValidityParGeom()
checks the validity of a boundary cell using parallel geometry
void sbc2801x(MInt)
Solid wall Navier-Stokes boundary condition Computes ghost cell slopes for the viscous flux computati...
void cbc1091d_after(MInt)
Subsonic fully reflecting characteristic inflow condition - cut off - sets un to prescribed value aft...
void addBoundarySurfaces()
adds a surface for the ghost-boundary cell intersections
void cbcMachCo(MInt, MFloat *)
Returns the mean and maximum Mach number of the cut off cells.
void computePolygon(MFloat *x, const MInt N, MFloat *centroid, MFloat *area)
void setNearBoundaryRecNghbrs(MInt updateOnlyBndryCndId=-1)
virtual void bc1001coflowY(MInt)
void correctGhostCellSlopesViscous()
void bcInit1601(MInt)
Initialize bc1601.
MInt isCutOffInterface(MInt cellId)
void createBoundaryAtCutoff()
void applyNonReflectingBCAfterTreatmentCutOff()
void createSpongeAtSpongeBndryCnds()
creates Sponge Cells at spongeBndryCnds
void mergeCellsMGC()
merges master and small cells - for multiple ghost cells formulation
void resetCutOff()
reset sorterdCutOff Cells and cutOff communicator before balancing and adaptation!
void computeGhostCellsMGC()
Computes one ghost cell for each boundary surface.
void createSortedBndryCellList()
void precomputeBesselTrigonometry(MInt)
void getSortedElements(const std::vector< MInt > &, MInt &, MInt *&, MInt &, MInt *&, MInt)
void sbc1002(MInt)
Symmetry boundary condition about x-axis (slopes)
void cbc2091b_after(MInt)
Subsonic fully reflecting characteristic inflow condition - cut off - sets T0,u,v to prescribed value...
virtual void bc1791(MInt)
virtual void writeStlFileOfCell(MInt, const MChar *)
void bcInit2770(MInt)
supersonic inflow with imposed onlique shock wave and linear waves version: cut-off boundary conditio...
void cbc2091d_after(MInt)
Subsonic fully reflecting characteristic inflow condition - cut off - sets un to prescribed value aft...
virtual void bc10910(MInt)
void cbc109910(MInt)
Characteristic boundary condition. Outflow. Prescribed: p. Partially Refelecting.
void cbcTauQ(MInt, MFloat *, MFloat *, MInt *)
Calculates the stress tensor tau and the heat flux q and the mean velocity on the construction stenci...
virtual void bc1005(MInt)
virtual void bc1004(MInt)
void bc1952(MInt)
Subsonic outflow boundary condition (applied directly to the (boundary) cell). Set of variables: Stan...
void initSmallCellRHSCorrection(MInt updateOnlyBndryCndId=-1)
void cutOffBcMissingNeighbor(const MInt cellId, const MString bcName)
void bcNeumannIsothermalUnburnt(MInt)
Computes the p and rho slopes on boundary cells using the least-squares method, and setting implicite...
void computeReverseMap()
Creates a mapping (boundary cell id) -> (cell id) in m_bndryCellIds.
void bcNeumann3600(MInt)
Simple and fast fixed adiabatic wall boundary condition for use with the flux-redistribution method.
void initBndryCommunications()
inits the commnicators for the boundaries
void computeTrapez(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
void rerecorrectCellCoordinates()
void bcInit0001(MInt)
Sets up the reconstruction stencil for boundary cells.
void resetBndryCommunication()
void computePyra(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
void computePoly3(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
Collector< FvBndryCell< nDim, SysEqn > > * m_bndryCells
MPI_Comm globalMpiComm() const
Return the global MPI communicator used by the grid.
MFloat m_inflowTemperatureRatio
void open(const MString &filename, const MString &projectName, MInt fileType=0, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool rootOnlyHardwired=false)
Opens a file by passing the parameters to InfoOut_<xyz>FileBuffer::open(...).
void init(MInt commStgRoot)
This class is a ScratchSpace.
T * getPointer() const
Deprecated: use begin() instead!
void fill(T val)
fill the scratch with a given value
pointer p
Deprecated: use [] instead!
void prepareInterpolationField(MInt *noReceiverCells, MFloat **receiverCoordinates)
Prepares interpolation for field For a given 3D coordinate field the method computes the transformed ...
void interpolateField(MString, MFloat *)
interpolates a field interpolates a given varName and varF
Checks if the primitive variable C exists.
Checks if the primitive variable N exists.
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
void mTerm(const MInt errorCode, const MString &location, const MString &message)
constexpr Real POW3(const Real x)
constexpr Real POW2(const Real x)
MBool approx(const T &, const U &, const T)
constexpr T mMin(const T &x, const T &y)
double doubleSwap(double f)
constexpr T mMax(const T &x, const T &y)
void printAllocatedMemory(const MLong oldAllocatedBytes, const MString &solverName, const MPI_Comm comm)
Prints currently allocated memory.
MInt globalNoDomains()
Return global number of domains.
constexpr MLong IPOW2(MInt x)
constexpr MFloat FPOW2(MInt x)
std::basic_string< char > MString
int MPI_Comm_free(MPI_Comm *comm, const MString &name, const MString &varname)
same as MPI_Comm_free, but updates the number of MPI communicators
int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm, const MString &name, const MString &varname)
same as MPI_Comm_create, but updates the number of MPI communicators
int MPI_Group_incl(MPI_Group group, int n, const int ranks[], MPI_Group *newgroup, const MString &name)
same as MPI_Group_incl
int MPI_Comm_group(MPI_Comm comm, MPI_Group *group, const MString &name, const MString &varname)
same as MPI_Comm_group
int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, int root, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Gatherv
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
int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm, const MString &name, const MString &varname)
same as MPI_Bcast
int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Gather
int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allgather
int MPI_Group_free(MPI_Group *group, const MString &name)
same as MPI_Group_free
constexpr std::underlying_type< FcCell >::type p(const FcCell property)
Converts property name to underlying integer value.
T cos(const T a, const T b, const T x)
Cosine slope filter.
IdType index(const FloatType *const x, const IdType level)
Return Hilbert index for given location and level in 2D or 3D.
void cross(const T *const u, const T *const v, T *const c)
MFloat RBF(const MFloat R, const MFloat R0)
radial base function
MFloat besselJ0(MFloat x)
MInt removeDoubleEntries(MInt *a, MInt size)
void invert(MFloat *A, const MInt m, const MInt n)
MFloat besselJ1(MFloat x)
MFloat frobeniusMatrixNormSquared(MFloatScratchSpace &m, MInt dim1, MInt dim2)
MFloat deltaFun(const MFloat r, const MFloat r0, const MFloat r1)
void calcEigenVectors(MFloat A[3][3], MFloat Q[3][3], MFloat w[3])
void quickSort(MInt *a, MInt start, MInt end)
MFloat norm(const std::array< T, N > &u)
MFloat lincos(MFloat arg)
MInt inverse(MFloat **a, MFloat **ainv, MInt n, const MFloat epsilon)
MInt invertR(T &A, T &weights, T &AInv, const MInt m, const MInt n)
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)
static constexpr MFloat beta0