22template <MInt nDim,
class SysEqn>
35template <MInt nDim,
class SysEqn>
37 mAlloc(fvSolver().m_levelSetValues, lsSolver().m_noSets,
"fvSolver().m_levelSetValues", AT_);
38 mAlloc(fvSolver().m_curvatureG, lsSolver().m_noSets,
"fvSolver().m_curvatureG", AT_);
39 mAlloc(fvSolver().m_flameSpeedG, lsSolver().m_noSets,
"fvSolver().m_flameSpeedG", AT_);
40 computeGCellTimeStep();
42template <MInt nDim,
class SysEqn>
44 computeGCellTimeStep();
45 exchangeCouplingData();
47template <MInt nDim,
class SysEqn>
50template <MInt nDim,
class SysEqn>
52 for(
MInt s = 0; s < lsSolver().m_noSets; s++) {
53 fvSolver().m_levelSetValues[s].resize(fvSolver().a_noCells());
54 fvSolver().m_curvatureG[s].resize(fvSolver().a_noCells());
55 fvSolver().m_flameSpeedG[s].resize(fvSolver().a_noCells());
57 computeGCellTimeStep();
58 setRhoFlameTubeInLs();
62template <MInt nDim,
class SysEqn>
64 if(lsSolver().m_gRKStep != 0)
return;
65 if(!lsSolver().m_computeExtVel)
return;
67 if(!lsSolver().m_smoothExtVel) {
68 fastInterfaceExtensionVelocity();
71 switch(lsSolver().m_computeExtVel) {
73 for(
MInt set = lsSolver().m_startSet; set < lsSolver().m_noSets; set++) {
75 fluidDensity.
fill(-F1);
76 if(!lsSolver().m_interpolateFlowFieldToFlameFront) {
77 collectGEquationModelDataOpt(fluidDensity.
getPointer(), set);
79 collectGEquationModelDataOptInterpolate(fluidDensity.
getPointer(), set);
81 lsSolver().computeExtensionVelocityGEQUPVMarksteinOpt(fluidDensity.
getPointer(), set);
91template <MInt nDim,
class SysEqn>
95 MInt baseGCellId, cellId;
96 for(
MInt id = 0;
id < lsSolver().a_noBandCells(set);
id++) {
97 cellId = lsSolver().a_bandCellId(
id, set);
98 for(
MInt i = 0; i < lsSolver().nDim; i++) {
99 lsSolver().a_extensionVelocityG(cellId, i, set) = F0;
101 lsSolver().a_correctedBurningVelocity(cellId, set) = F0;
106 for(
MInt id = 0;
id < lsSolver().a_noG0Cells(set);
id++) {
107 if(lsSolver().a_isHalo(lsSolver().a_G0CellId(
id, set))
108 || lsSolver().a_level(lsSolver().a_G0CellId(
id, set)) != lsSolver().a_maxGCellLevel()) {
109 for(
MInt i = 0; i < lsSolver().nDim; i++)
110 lsSolver().a_extensionVelocityG(lsSolver().a_G0CellId(
id, set), i, set) = F0;
111 fluidDensity[
id] = -F1;
115 baseGCellId = lsSolver().a_G0CellId(
id, set);
117 if(lsSolver().a_isGBoundaryCellG(baseGCellId, 0))
continue;
118 if(lsSolver().a_isBndryCellG(baseGCellId))
continue;
120 while(ls2fvId(baseGCellId) == -1) {
121 baseGCellId = lsSolver().c_parentId(baseGCellId);
123 if(baseGCellId == -1) {
124 cerr <<
"ERROR: no parent cell found for connecting" << endl;
126 MInt flowCell = baseGCellId;
128 fluidDensity[
id] = collectFvDataForCollectGEquationModelDataOpt(flowCell,
id);
134template <MInt nDim,
class SysEqn>
137 for(
MInt c = 0; c < fvSolver().m_bndryGhostCellsOffset; c++) {
138 if(fvSolver().grid().tree().hasProperty(c, Cell::IsHalo)) {
141 if(!fvSolver().a_hasProperty(c, SolverCell::IsOnCurrentMGLevel)) {
144 MInt cLs = fv2lsId(c);
148 fvSolver().a_levelSetFunction(c, 0) = -999999;
153 if(
ABS(lsSolver().m_outsideGValue -
ABS(lsSolver().a_levelSetFunctionG(gc, 0))) < 0.02) {
154 fvSolver().a_levelSetFunction(c, 0) = -999999;
157 if(lsSolver().a_level(gc) != fvSolver().maxRefinementLevel()) {
158 fvSolver().a_levelSetFunction(c, 0) = -999999;
162 fvSolver().a_levelSetFunction(c, 0) = lsSolver().a_levelSetFunctionG(gc, 0);
163 fvSolver().a_flameSpeed(c, 0) = lsSolver().a_flameSpeedG(gc, 0);
164 fvSolver().a_curvatureG(c, 0) = lsSolver().a_curvatureG(gc, 0);
168 constructExtensionVelocity();
171template <MInt nDim,
class SysEqn>
173 lsSolver().m_timeStep = fvSolver().timeStep(
true);
176template <MInt nDim,
class SysEqn>
178 lsSolver().m_timeStep = timeStep;
182template <MInt nDim,
class SysEqn>
184 MInt flowCellFv = ls2fvId(flowCell);
186 if(flowCellFv == -1) {
189 for(
MInt i = 0; i < nDim; i++) {
190 lsSolver().a_extensionVelocityG(lsSolver().a_G0CellId(
id, 0), i, 0) =
191 fvSolver().a_pvariable(flowCellFv, fvSolver().PV->VV[i]);
194 return F1 / fvSolver().a_pvariable(flowCellFv, fvSolver().PV->RHO);
198template <MInt nDim,
class SysEqn>
200 lsSolver().m_rhoFlameTube = fvSolver().m_rhoFlameTube;
202template <MInt nDim,
class SysEqn>
204 lsSolver().m_rhoInfinity = fvSolver().m_rhoInfinity;
208template <MInt nDim,
class SysEqn>
210 if(i + 1 > fvSolver().grid().tree().size()) {
213 if(fvSolver().grid().tree().hasProperty(i, Cell::IsHalo)) {
216 MInt iLs = fv2lsId(i);
218 if(iLs < 0 || iLs > lsSolver().grid().tree().size()) {
221 return (lsSolver().a_levelSetFunctionG(iLs, 0));
224template <MInt nDim,
class SysEqn>
226 if(i + 1 > fvSolver().grid().tree().size()) {
229 if(fvSolver().grid().tree().hasProperty(i, Cell::IsHalo)) {
232 MInt iLs = fv2lsId(i);
233 if(iLs < 0 || iLs > lsSolver().grid().tree().size()) {
236 return (lsSolver().a_curvatureG(iLs, 0));
239template <MInt nDim,
class SysEqn>
241 MInt noLevelSetFieldData = 0;
242 if(fvSolver().m_levelSet) {
243 if(lsSolver().m_writeOutAllLevelSetFunctions) {
244 noLevelSetFieldData += lsSolver().m_noSets;
245 noLevelSetFieldData += lsSolver().m_noSets;
247 noLevelSetFieldData += 1;
248 if(lsSolver().m_writeOutAllCurvatures)
249 noLevelSetFieldData += lsSolver().m_noSets;
251 noLevelSetFieldData += 1;
254 return noLevelSetFieldData;
258template <MInt nDim,
class SysEqn>
260 if(fvSolver().m_combustion && fvSolver().m_recordPressure &&
globalTimeStep % 10 == 0) {
261 lsSolver().computeZeroLevelSetArcLength();
262 if(fvSolver().domainId() == 0) {
264 datei = fopen(
"pressureSensor",
"a+");
266 fprintf(datei,
" %f", fvSolver().m_time);
267 fprintf(datei,
" %-10.10f", fvSolver().a_pvariable(fvSolver().m_cellToRecordData, fvSolver().PV->P));
268 fprintf(datei,
" %-10.10f", fvSolver().m_meanPressure);
269 fprintf(datei,
" %-10.10f", fvSolver().a_pvariable(fvSolver().m_cellToRecordData, fvSolver().PV->V));
270 fprintf(datei,
" %-10.10f", lsSolver().m_arcLength);
271 fprintf(datei,
" %-10.10f", fvSolver().m_totalHeatReleaseRate);
272 fprintf(datei,
" %-10.10f", lsSolver().m_minFlameFrontPosition[1]);
273 fprintf(datei,
" %-10.10f", lsSolver().m_maxFlameFrontPosition[1]);
274 fprintf(datei,
" %-10.10f", lsSolver().m_meanFlameFrontPosition[1]);
275 fprintf(datei,
"\n");
280 if(fvSolver().m_combustion && fvSolver().m_recordFlameFrontPosition &&
globalTimeStep % 10 == 0) {
281 lsSolver().computeZeroLevelSetArcLength();
282 if(fvSolver().domainId() == 0) {
284 datei = fopen(
"flameFrontData",
"a+");
286 fprintf(datei,
" %f", fvSolver().m_time);
287 fprintf(datei,
" %f", lsSolver().m_arcLength);
288 fprintf(datei,
" %-10.15f", lsSolver().m_minFlameFrontPosition[1]);
289 fprintf(datei,
" %-10.15f", lsSolver().m_maxFlameFrontPosition[1]);
290 fprintf(datei,
"\n");
295 if(fvSolver().m_combustion && !fvSolver().m_forcing && !fvSolver().m_structuredFlameOutput
296 && fvSolver().domainId() == 0) {
298 datei00 = fopen(
"flameSurfaceAreaROH_steady",
"a+");
300 fprintf(datei00,
" %f", fvSolver().m_time);
301 fprintf(datei00,
" %-10.10f", lsSolver().m_massConsumption);
302 fprintf(datei00,
" %-10.10f", fvSolver().m_totalHeatReleaseRate);
303 fprintf(datei00,
" %-10.10f", lsSolver().m_arcLength);
304 fprintf(datei00,
"\n");
309 if(fvSolver().m_combustion && (fvSolver().m_structuredFlameOutput || fvSolver().m_structuredFlameOutputLevel == 7)) {
311 MInt sweepStartRow = 0;
313 MInt sample, currentCycle;
315 MInt samplingStartCycle = fvSolver().m_samplingStartCycle;
316 MInt samplingEndCycle = fvSolver().m_samplingEndCycle;
317 MFloat St = fvSolver().m_flameStrouhal;
323 currentCycle = (
MInt)(sample / fvSolver().m_samplesPerCycle);
326 lsSolver().computeZeroLevelSetArcLength();
327 forcingAmplitude = fvSolver().m_forcingAmplitude * sin(St * fvSolver().m_time);
329 if(fvSolver().domainId() == 0) {
331 datei0 = fopen(
"flameSurfaceAreaROH",
"a+");
333 fprintf(datei0,
" %d", currentCycle);
334 fprintf(datei0,
" %d", sample);
335 fprintf(datei0,
" %f", fvSolver().m_time);
336 fprintf(datei0,
" %f", forcingAmplitude);
337 fprintf(datei0,
" %-10.10f", lsSolver().m_massConsumption);
338 fprintf(datei0,
" %-10.10f", fvSolver().m_totalHeatReleaseRate);
339 fprintf(datei0,
" %-10.10f", lsSolver().m_arcLength);
340 fprintf(datei0,
"\n");
345 switch(fvSolver().m_structuredFlameOutputLevel) {
347 if(
globalTimeStep % fvSolver().m_noTimeStepsBetweenSamples != 0) {
355 if(fvSolver().domainId() == 0) {
358 datei = fopen(
"flameSurfaceArea",
"a+");
360 fprintf(datei,
" %d", currentCycle);
361 fprintf(datei,
" %d", sample);
362 fprintf(datei,
" %f", fvSolver().m_time);
363 fprintf(datei,
" %-10.10f", forcingAmplitude);
364 fprintf(datei,
" %-10.10f", lsSolver().m_massConsumption);
365 fprintf(datei,
" %-10.10f", fvSolver().m_totalHeatReleaseRate);
366 fprintf(datei,
" %-10.10f", lsSolver().m_arcLength);
367 fprintf(datei,
"\n");
372 switch(fvSolver().m_structuredFlameOutputLevel) {
374 if(currentCycle < samplingStartCycle || currentCycle > samplingEndCycle) {
392 switch(fvSolver().m_structuredFlameOutputLevel) {
395 MFloat FtimeStep = 1 / fvSolver().timeStep();
397 const MFloat gammaMinusOne = fvSolver().m_gamma - 1.0;
400 MFloat velPOW2 = -9999999.0;
410 <= (
MInt)(samplingStartCycle * fvSolver().m_samplesPerCycle + fvSolver().m_noTimeStepsBetweenSamples)
411 ||
globalTimeStep <= (
MInt)(fvSolver().m_restartTimeStep + fvSolver().m_noTimeStepsBetweenSamples)) {
413 if(fvSolver().m_plenum) {
414 for(
MInt ac = 0; ac < fvSolver().m_noActiveCells; ac++) {
415 if(fvSolver().a_coordinate(fvSolver().m_activeCellIds[ac], 0) > -(fvSolver().m_radiusFlameTube + 0.1))
417 if(fvSolver().a_coordinate(fvSolver().m_activeCellIds[ac], 1) > -1.1)
continue;
418 if(fvSolver().a_hasNeighbor(fvSolver().m_activeCellIds[ac], 0) > 0
419 && fvSolver().a_hasNeighbor(fvSolver().m_activeCellIds[ac], 2)
422 fvSolver().m_sweepStartFirstCell =
423 fvSolver().m_activeCellIds[ac];
428 for(
MInt ac = 0; ac < fvSolver().m_noActiveCells; ac++) {
429 if(fvSolver().a_hasNeighbor(fvSolver().m_activeCellIds[ac], 0) > 0)
continue;
430 if(fvSolver().a_hasNeighbor(fvSolver().m_activeCellIds[ac], 2) > 0)
continue;
431 if(fvSolver().a_coordinate(fvSolver().m_activeCellIds[ac], 1) > -0.8)
continue;
432 if(fvSolver().a_level(fvSolver().m_activeCellIds[ac]) != fvSolver().maxRefinementLevel())
continue;
433 fvSolver().m_sweepStartFirstCell = fvSolver().m_activeCellIds[ac];
437 m_log <<
"Structured Output starting from Cell ... :" << endl;
438 m_log <<
"cellId: " << fvSolver().m_sweepStartFirstCell << endl;
439 m_log <<
"x: " << fvSolver().a_coordinate(fvSolver().m_sweepStartFirstCell, 0) << endl;
440 m_log <<
"y: " << fvSolver().a_coordinate(fvSolver().m_sweepStartFirstCell, 1) << endl;
442 cerr <<
"Structured Output starting from Cell ... :" << endl;
443 cerr <<
"cellId: " << fvSolver().m_sweepStartFirstCell << endl;
444 cerr <<
"x: " << fvSolver().a_coordinate(fvSolver().m_sweepStartFirstCell, 0) << endl;
445 cerr <<
"y: " << fvSolver().a_coordinate(fvSolver().m_sweepStartFirstCell, 1) << endl;
448 stringstream StartEndCoord;
449 StartEndCoord <<
"out/StartEndCoord_" << currentCycle <<
"_" << (
MInt)sample;
450 pv6 = fopen((StartEndCoord.str()).c_str(),
"w");
451 current = fvSolver().m_sweepStartFirstCell;
452 fprintf(pv6,
"%f ", fvSolver().a_coordinate(current, 0));
453 fprintf(pv6,
"%f ", fvSolver().a_coordinate(current, 1));
455 while(fvSolver().a_hasNeighbor(current, 1) > 0) {
456 current = fvSolver().c_neighborId(current, 1);
457 fprintf(pv6,
"%f ", fvSolver().a_coordinate(current, 0));
458 fprintf(pv6,
"%f ", fvSolver().a_coordinate(current, 1));
463 sweepStartRow = fvSolver().m_sweepStartFirstCell;
464 while(fvSolver().a_hasNeighbor(sweepStartRow, 3) > 0) {
465 sweepStartRow = fvSolver().c_neighborId(sweepStartRow, 3);
468 while(fvSolver().a_hasNeighbor(sweepStartRow, 0) > 0
469 && fvSolver().a_hasNeighbor(fvSolver().c_neighborId(sweepStartRow, 0), 3) > 0) {
470 sweepStartRow = fvSolver().c_neighborId(sweepStartRow, 0);
472 current = sweepStartRow;
473 fprintf(pv6,
"%f ", fvSolver().a_coordinate(current, 0));
474 fprintf(pv6,
"%f ", fvSolver().a_coordinate(current, 1));
476 while(fvSolver().a_hasNeighbor(current, 1) > 0) {
477 current = fvSolver().c_neighborId(current, 1);
478 fprintf(pv6,
"%f ", fvSolver().a_coordinate(current, 0));
479 fprintf(pv6,
"%f ", fvSolver().a_coordinate(current, 1));
482 while(fvSolver().a_hasNeighbor(sweepStartRow, 3) == 0 && fvSolver().a_hasNeighbor(sweepStartRow, 1) > 0) {
483 sweepStartRow = fvSolver().c_neighborId(sweepStartRow, 1);
490 if(((
MInt)sample < (
MInt)(samplingStartCycle * fvSolver().m_samplesPerCycle))
491 ||
globalTimeStep <= (
MInt)(fvSolver().m_restartTimeStep + fvSolver().m_noTimeStepsBetweenSamples))
493 if(lsSolver().m_noSets > 1) {
495 "This routine should only be called if lsSolver().m_noSets = 1, which is not the case here... "
502 if(((
MInt)sample < (
MInt)(samplingStartCycle * fvSolver().m_samplesPerCycle)))
break;
512 stringstream u, v, p, dpdt, rho, c, G;
513 u <<
"out/u_" << currentCycle <<
"_" << (
MInt)sample;
514 v <<
"out/v_" << currentCycle <<
"_" << (
MInt)sample;
515 p <<
"out/p_" << currentCycle <<
"_" << (
MInt)sample;
516 dpdt <<
"out/dpdt_" << currentCycle <<
"_" << (
MInt)sample;
517 rho <<
"out/rho_" << currentCycle <<
"_" << (
MInt)sample;
518 c <<
"out/c_" << currentCycle <<
"_" << (
MInt)sample;
519 G <<
"out/G_" << currentCycle <<
"_" << (
MInt)sample;
521 pv0 = fopen((u.str()).c_str(),
"w");
522 pv1 = fopen((v.str()).c_str(),
"w");
523 pv2 = fopen((rho.str()).c_str(),
"w");
524 pv3 = fopen((p.str()).c_str(),
"w");
525 pv4 = fopen((c.str()).c_str(),
"w");
526 pv5 = fopen((G.str()).c_str(),
"w");
527 pv6 = fopen((dpdt.str()).c_str(),
"w");
528 if(fvSolver().m_sweepStartFirstCell < 0) {
529 MString errorMessage =
"sweep start cell is negative";
530 mTerm(1, AT_, errorMessage);
533 current = fvSolver().m_sweepStartFirstCell;
536 fprintf(pv0,
"%f ", fvSolver().a_pvariable(current, 0));
537 fprintf(pv1,
"%f ", fvSolver().a_pvariable(current, 1));
538 fprintf(pv2,
"%f ", fvSolver().a_pvariable(current, 2));
539 fprintf(pv3,
"%f ", fvSolver().a_pvariable(current, 3));
540 fprintf(pv4,
"%f ", fvSolver().a_pvariable(current, 4));
541 fprintf(pv5,
"%f ", lsSolver().a_levelSetFunctionG(fv2lsId(current), 0));
543 fRho = F1 / fvSolver().a_oldVariable(current, fvSolver().CV->RHO);
545 for(
MInt i = 0; i < nDim; i++) {
546 vel = fvSolver().a_oldVariable(current, fvSolver().CV->RHO_VV[i]) * fRho;
547 velPOW2 +=
POW2(vel);
550 dPdT = fvSolver().a_pvariable(current, 3);
553 * (fvSolver().a_oldVariable(current, fvSolver().CV->RHO_E)
554 - F1B2 * fvSolver().a_oldVariable(current, fvSolver().CV->RHO) * velPOW2);
557 fprintf(pv6,
"%f ", dPdT);
559 while(fvSolver().a_hasNeighbor(current, 1) > 0) {
560 current = fvSolver().c_neighborId(current, 1);
561 fprintf(pv0,
"%f ", fvSolver().a_pvariable(current, 0));
562 fprintf(pv1,
"%f ", fvSolver().a_pvariable(current, 1));
563 fprintf(pv2,
"%f ", fvSolver().a_pvariable(current, 2));
564 fprintf(pv3,
"%f ", fvSolver().a_pvariable(current, 3));
565 fprintf(pv4,
"%f ", fvSolver().a_pvariable(current, 4));
566 fprintf(pv5,
"%f ", lsSolver().a_levelSetFunctionG(fv2lsId(current), 0));
568 fRho = F1 / fvSolver().a_oldVariable(current, fvSolver().CV->RHO);
570 for(
MInt i = 0; i < nDim; i++) {
571 vel = fvSolver().a_oldVariable(current, fvSolver().CV->RHO_VV[i]) * fRho;
572 velPOW2 +=
POW2(vel);
575 dPdT = fvSolver().a_pvariable(current, 3);
578 * (fvSolver().a_oldVariable(current, fvSolver().CV->RHO_E)
579 - F1B2 * fvSolver().a_oldVariable(current, fvSolver().CV->RHO) * velPOW2);
582 fprintf(pv6,
"%f ", dPdT);
593 sweepStartRow = fvSolver().m_sweepStartFirstCell;
594 while(fvSolver().a_hasNeighbor(sweepStartRow, 3) > 0) {
595 sweepStartRow = fvSolver().c_neighborId(sweepStartRow, 3);
597 while(fvSolver().a_hasNeighbor(sweepStartRow, 0) > 0
598 && fvSolver().a_hasNeighbor(fvSolver().c_neighborId(sweepStartRow, 0), 3) > 0) {
599 sweepStartRow = fvSolver().c_neighborId(sweepStartRow, 0);
601 current = sweepStartRow;
603 fprintf(pv0,
"%f ", fvSolver().a_pvariable(current, 0));
604 fprintf(pv1,
"%f ", fvSolver().a_pvariable(current, 1));
605 fprintf(pv2,
"%f ", fvSolver().a_pvariable(current, 2));
606 fprintf(pv3,
"%f ", fvSolver().a_pvariable(current, 3));
607 fprintf(pv4,
"%f ", fvSolver().a_pvariable(current, 4));
608 fprintf(pv5,
"%f ", lsSolver().a_levelSetFunctionG(fv2lsId(current), 0));
610 fRho = F1 / fvSolver().a_oldVariable(current, fvSolver().CV->RHO);
612 for(
MInt i = 0; i < nDim; i++) {
613 vel = fvSolver().a_oldVariable(current, fvSolver().CV->RHO_VV[i]) * fRho;
614 velPOW2 +=
POW2(vel);
617 dPdT = fvSolver().a_pvariable(current, 3);
620 * (fvSolver().a_oldVariable(current, fvSolver().CV->RHO_E)
621 - F1B2 * fvSolver().a_oldVariable(current, fvSolver().CV->RHO) * velPOW2);
624 fprintf(pv6,
"%f ", dPdT);
627 while(fvSolver().a_hasNeighbor(current, 1) > 0) {
628 current = fvSolver().c_neighborId(current, 1);
629 fprintf(pv0,
"%f ", fvSolver().a_pvariable(current, 0));
630 fprintf(pv1,
"%f ", fvSolver().a_pvariable(current, 1));
631 fprintf(pv2,
"%f ", fvSolver().a_pvariable(current, 2));
632 fprintf(pv3,
"%f ", fvSolver().a_pvariable(current, 3));
633 fprintf(pv4,
"%f ", fvSolver().a_pvariable(current, 4));
634 fprintf(pv5,
"%f ", lsSolver().a_levelSetFunctionG(fv2lsId(current), 0));
637 fRho = F1 / fvSolver().a_oldVariable(current, fvSolver().CV->RHO);
639 for(
MInt i = 0; i < nDim; i++) {
640 vel = fvSolver().a_oldVariable(current, fvSolver().CV->RHO_VV[i]) * fRho;
641 velPOW2 +=
POW2(vel);
643 dPdT = fvSolver().a_pvariable(current, 3);
646 * (fvSolver().a_oldVariable(current, fvSolver().CV->RHO_E)
647 - F1B2 * fvSolver().a_oldVariable(current, fvSolver().CV->RHO) * velPOW2);
650 fprintf(pv6,
"%f ", dPdT);
662 while(fvSolver().a_hasNeighbor(sweepStartRow, 3) == 0 && fvSolver().a_hasNeighbor(sweepStartRow, 1) > 0) {
663 sweepStartRow = fvSolver().c_neighborId(sweepStartRow, 1);
679 const MFloat gammaMinusOne = fvSolver().m_gamma - F1;
680 const MFloat FgammaMinusOne = F1 / gammaMinusOne;
681 MFloat reactionEnthalpy = (fvSolver().m_burntUnburntTemperatureRatio - F1) * FgammaMinusOne;
682 MFloat halfWidth = 9999999.0;
683 const MFloat eps = fvSolver().c_cellLengthAtLevel(fvSolver().maxRefinementLevel()) * 0.00000000001;
692 for(
MInt cell = 0; cell < fvSolver().noInternalCells(); cell++) {
693 if(!fvSolver().a_hasProperty(cell, SolverCell::IsOnCurrentMGLevel))
continue;
695 halfWidth = F1B2 * fvSolver().c_cellLengthAtCell(cell) + eps;
697 if(fvSolver().a_coordinate(cell, 0) > halfWidth || fvSolver().a_coordinate(cell, 0) < F0)
continue;
700 nghbrId = fvSolver().c_neighborId(cell, 0);
702 check = fvSolver().a_coordinate(cell, 0) + fvSolver().a_coordinate(nghbrId, 0);
704 if(fabs(check) > eps)
mTerm(1, AT_,
"ERROR: coord check failed");
707 pressure[cnt] = fvSolver().a_pvariable(cell, 3);
708 pressure[cnt] += fvSolver().a_pvariable(nghbrId, 3);
709 pressure[cnt] *= F1B2;
711 heatRelease[cnt] = fvSolver().a_reactionRate(cell, 0) * fvSolver().a_cellVolume(cell) * reactionEnthalpy;
713 fvSolver().a_reactionRate(nghbrId, 0) * fvSolver().a_cellVolume(nghbrId) * reactionEnthalpy;
714 heatRelease[cnt] *= F1B2;
716 coords[cnt] = fvSolver().a_coordinate(cell, 1);
727 MPI_Gather(&cnt, 1, MPI_INT, globalCnt.
getPointer(), 1, MPI_INT, root, fvSolver().mpiComm(), AT_,
"cnt",
728 "globalCnt.getPointer()");
730 for(
MInt i = 0; i < fvSolver().noDomains(); i++) {
731 offsetIO[i] = totalCnt;
732 totalCnt += globalCnt[i];
734 if(fvSolver().domainId() != root) totalCnt = 0;
741 offsetIO.
getPointer(), MPI_DOUBLE, root, fvSolver().mpiComm(), AT_,
"pressure.getPointer()",
744 offsetIO.
getPointer(), MPI_DOUBLE, root, fvSolver().mpiComm(), AT_,
"heatRelease.getPointer()",
745 "tmp1.getPointer()");
747 offsetIO.
getPointer(), MPI_DOUBLE, root, fvSolver().mpiComm(), AT_,
"coords.getPointer()",
748 "tmp2.getPointer()");
758 p <<
"out/centerline_p";
759 h <<
"out/centerline_h";
760 y <<
"out/centerline_y";
761 if(fvSolver().domainId() == root) {
762 pv0 = fopen((p.str()).c_str(),
"a+");
763 pv1 = fopen((h.str()).c_str(),
"a+");
764 pv2 = fopen((
y.str()).c_str(),
"w");
766 for(
MInt c = 0; c < totalCnt; c++) {
767 fprintf(pv0,
"%f ", tmp[c]);
769 fprintf(pv1,
"%f ", tmp1[c]);
771 fprintf(pv2,
"%f ", tmp2[c]);
781 if(
globalTimeStep % fvSolver().m_noTimeStepsBetweenSamples != 0) {
785 if(((
MInt)sample < (
MInt)(samplingStartCycle * fvSolver().m_samplesPerCycle)))
break;
787 stringstream varFileName;
788 varFileName << fvSolver().outputDir() <<
"Q_" << currentCycle <<
"_" << (
MInt)sample << ParallelIo::fileExt();
790 MFloatScratchSpace dbVariables(fvSolver().a_noCells() * (fvSolver().CV->noVariables + 5), AT_,
"dbVariables");
794 vector<MString> dbVariablesName;
795 vector<MString> idVariablesName;
796 vector<MString> dbParametersName;
797 vector<MString> idParametersName;
798 vector<MString> name;
800 if(fvSolver().m_levelSet) {
804 for(
MInt cell = 0; cell < fvSolver().a_noCells(); cell++) {
805 const MInt gCellId = fv2lsId(cell);
806 levelSetFunction[cell] = lsSolver().a_levelSetFunctionG(gCellId, 0);
807 curvature[cell] = lsSolver().a_curvatureG(gCellId, 0);
814 name.push_back(gName.str());
815 fvSolver().collectVariables(levelSetFunction.
begin(), dbVariables, name, dbVariablesName, 1,
816 fvSolver().a_noCells());
818 name.push_back(gCurv.str());
819 fvSolver().collectVariables(curvature.
begin(), dbVariables, name, dbVariablesName, 1, fvSolver().a_noCells());
822 const MFloat gammaMinusOne = fvSolver().m_gamma - F1;
823 const MFloat FgammaMinusOne = F1 / gammaMinusOne;
824 MFloat reactionEnthalpy = (fvSolver().m_burntUnburntTemperatureRatio - F1) * FgammaMinusOne;
825 MFloat FtimeStep = 1 / fvSolver().timeStep();
828 MFloat velPOW2 = -9999999.0;
835 for(
MInt cell = 0; cell < fvSolver().a_noCells(); cell++) {
840 if(!fvSolver().a_hasProperty(cell, SolverCell::IsOnCurrentMGLevel))
continue;
843 fRho = F1 / fvSolver().a_oldVariable(cell, fvSolver().CV->RHO);
845 for(
MInt i = 0; i < nDim; i++) {
846 vel = fvSolver().a_oldVariable(cell, fvSolver().CV->RHO_VV[i]) * fRho;
847 velPOW2 +=
POW2(vel);
850 dPdT[cell] = fvSolver().a_pvariable(cell, 3);
853 * (fvSolver().a_oldVariable(cell, fvSolver().CV->RHO_E)
854 - F1B2 * fvSolver().a_oldVariable(cell, fvSolver().CV->RHO) * velPOW2);
856 dPdT[cell] *= FtimeStep;
858 h[cell] = fvSolver().a_reactionRate(cell, 0);
859 h[cell] *= fvSolver().a_cellVolume(cell) * reactionEnthalpy;
860 dHdT[cell] = fvSolver().a_reactionRate(cell, 0);
861 dHdT[cell] -= fvSolver().a_reactionRateBackup(cell, 0);
862 dHdT[cell] *= fvSolver().a_cellVolume(cell) * reactionEnthalpy;
863 dHdT[cell] *= FtimeStep;
865 stringstream dPdTname;
866 stringstream dHdTname;
872 name.push_back(dPdTname.str());
873 fvSolver().collectVariables(dPdT.
begin(), dbVariables, name, dbVariablesName, 1, fvSolver().a_noCells());
875 name.push_back(dHdTname.str());
876 fvSolver().collectVariables(dHdT.
begin(), dbVariables, name, dbVariablesName, 1, fvSolver().a_noCells());
878 name.push_back(hName.str());
879 fvSolver().collectVariables(h.
begin(), dbVariables, name, dbVariablesName, 1, fvSolver().a_noCells());
883 for(
MInt v = 0; v < fvSolver().PV->noVariables; v++) {
884 name.push_back(fvSolver().m_variablesName[v]);
886 fvSolver().collectVariables(&fvSolver().a_pvariable(0, 0), dbVariables, name, dbVariablesName,
887 fvSolver().PV->noVariables, fvSolver().a_noCells());
889 fvSolver().setRestartFileOutputTimeStep();
890 fvSolver().collectParameters(fvSolver().m_noSamples, idParameters,
"noSamples", idParametersName);
891 fvSolver().collectParameters(
globalTimeStep, idParameters,
"globalTimeStep", idParametersName);
892 fvSolver().collectParameters(fvSolver().m_time, dbParameters,
"time", dbParametersName);
893 fvSolver().collectParameters(fvSolver().m_restartFileOutputTimeStep, dbParameters,
"timeStep",
895 fvSolver().collectParameters(fvSolver().m_noTimeStepsBetweenSamples, idParameters,
"noTimeStepsBetweenSamples",
897 fvSolver().collectParameters(fvSolver().m_physicalTime, dbParameters,
"physicalTime", dbParametersName);
898 fvSolver().collectParameters((
MInt)fvSolver().m_forcing, idParameters,
"forcing", idParametersName);
904 fvSolver().saveGridFlowVarsPar((varFileName.str()).c_str(), fvSolver().a_noCells(),
905 fvSolver().noInternalCells(), dbVariables, dbVariablesName, 0, idVariables,
906 idVariablesName, 0, dbParameters, dbParametersName, idParameters,
907 idParametersName, fvSolver().m_recalcIds);
911 mTerm(1, AT_,
"change solution output format to NETCDF or change code");
920 for(
MInt ac = 0; ac < fvSolver().m_noActiveCells; ac++) {
921 if(fvSolver().a_hasNeighbor(fvSolver().m_activeCellIds[ac], 0) > 0)
continue;
922 if(fvSolver().a_hasNeighbor(fvSolver().m_activeCellIds[ac], 2) > 0)
continue;
923 if(
ABS(fvSolver().a_coordinate(fvSolver().m_activeCellIds[ac], 0)) > 0.5)
continue;
924 if(fvSolver().a_level(fvSolver().m_activeCellIds[ac]) != fvSolver().maxRefinementLevel())
continue;
925 sweepStart = fvSolver().m_activeCellIds[ac];
936 stringstream u, v, p, rho, c, G;
937 u <<
"out/u_" << currentCycle <<
"_" << (
MInt)sample;
938 v <<
"out/v_" << currentCycle <<
"_" << (
MInt)sample;
939 p <<
"out/p_" << currentCycle <<
"_" << (
MInt)sample;
940 rho <<
"out/rho_" << currentCycle <<
"_" << (
MInt)sample;
941 c <<
"out/c_" << currentCycle <<
"_" << (
MInt)sample;
942 G <<
"out/G_" << currentCycle <<
"_" << (
MInt)sample;
943 pv0 = fopen((u.str()).c_str(),
"w");
944 pv1 = fopen((v.str()).c_str(),
"w");
945 pv2 = fopen((rho.str()).c_str(),
"w");
946 pv3 = fopen((p.str()).c_str(),
"w");
947 pv4 = fopen((c.str()).c_str(),
"w");
948 pv5 = fopen((G.str()).c_str(),
"w");
950 current = sweepStart;
951 fprintf(pv0,
"%f ", fvSolver().a_pvariable(current, 0));
952 fprintf(pv1,
"%f ", fvSolver().a_pvariable(current, 1));
953 fprintf(pv2,
"%f ", fvSolver().a_pvariable(current, 2));
954 fprintf(pv3,
"%f ", fvSolver().a_pvariable(current, 3));
955 fprintf(pv4,
"%f ", fvSolver().a_pvariable(current, 4));
956 fprintf(pv5,
"%f ", lsSolver().a_levelSetFunctionG(fv2lsId(current), 0));
957 while(fvSolver().a_hasNeighbor(current, 1) > 0) {
958 current = fvSolver().c_neighborId(current, 1);
959 if(
ABS(fvSolver().a_coordinate(current, 0)) > 0.5)
break;
960 fprintf(pv0,
"%f ", fvSolver().a_pvariable(current, 0));
961 fprintf(pv1,
"%f ", fvSolver().a_pvariable(current, 1));
962 fprintf(pv2,
"%f ", fvSolver().a_pvariable(current, 2));
963 fprintf(pv3,
"%f ", fvSolver().a_pvariable(current, 3));
964 fprintf(pv4,
"%f ", fvSolver().a_pvariable(current, 4));
965 fprintf(pv5,
"%f ", lsSolver().a_levelSetFunctionG(fv2lsId(current), 0));
974 while(fvSolver().a_hasNeighbor(sweepStart, 3) > 0) {
975 sweepStart = fvSolver().c_neighborId(sweepStart, 3);
976 current = sweepStart;
978 fprintf(pv0,
"%f ", fvSolver().a_pvariable(current, 0));
979 fprintf(pv1,
"%f ", fvSolver().a_pvariable(current, 1));
980 fprintf(pv2,
"%f ", fvSolver().a_pvariable(current, 2));
981 fprintf(pv3,
"%f ", fvSolver().a_pvariable(current, 3));
982 fprintf(pv4,
"%f ", fvSolver().a_pvariable(current, 4));
983 fprintf(pv5,
"%f ", lsSolver().a_levelSetFunctionG(fv2lsId(current), 0));
984 while(fvSolver().a_hasNeighbor(current, 1) > 0) {
985 current = fvSolver().c_neighborId(current, 1);
986 if(
ABS(fvSolver().a_coordinate(current, 0)) > 0.5)
break;
987 fprintf(pv0,
"%f ", fvSolver().a_pvariable(current, 0));
988 fprintf(pv1,
"%f ", fvSolver().a_pvariable(current, 1));
989 fprintf(pv2,
"%f ", fvSolver().a_pvariable(current, 2));
990 fprintf(pv3,
"%f ", fvSolver().a_pvariable(current, 3));
991 fprintf(pv4,
"%f ", fvSolver().a_pvariable(current, 4));
992 fprintf(pv5,
"%f ", lsSolver().a_levelSetFunctionG(fv2lsId(current), 0));
1015template <MInt nDim,
class SysEqn>
1021 MInt m_constantFlameSpeed = fvSolver().m_constantFlameSpeed;
1022 MFloat m_subfilterVariance = fvSolver().m_subfilterVariance;
1023 MFloat m_rhoEInfinity = fvSolver().m_rhoEInfinity;
1024 MInt m_useCorrectedBurningVelocity = fvSolver().m_useCorrectedBurningVelocity;
1025 MFloat m_integralLengthScale = fvSolver().m_integralLengthScale;
1026 MFloat m_marksteinLength = fvSolver().m_marksteinLength;
1027 MFloat m_dampingDistanceFlameBase = fvSolver().m_dampingDistanceFlameBase;
1028 MFloat m_sutherlandConstant = fvSolver().m_sutherlandConstant;
1029 MFloat m_sutherlandPlusOne = fvSolver().m_sutherlandPlusOne;
1030 MFloat m_TInfinity = fvSolver().m_TInfinity;
1031 MFloat m_flameSpeed = fvSolver().m_flameSpeed;
1032 MFloat m_turbFlameSpeed = fvSolver().m_turbFlameSpeed;
1033 MFloat m_noReactionCells = fvSolver().m_noReactionCells;
1034 MFloat m_NuT = fvSolver().m_NuT;
1035 MFloat m_ScT = fvSolver().m_ScT;
1036 MFloat m_Pr = fvSolver().m_Pr;
1037 MFloat m_integralAmplitude = fvSolver().m_integralAmplitude;
1038 MFloat m_Re0 = fvSolver().m_sysEqn.m_Re0;
1039 MFloat m_yOffsetFlameTube = fvSolver().m_yOffsetFlameTube;
1040 MInt m_temperatureChange = fvSolver().m_temperatureChange;
1041 MInt m_heatReleaseDamp = fvSolver().m_heatReleaseDamp;
1042 MInt m_bndryGhostCellsOffset = fvSolver().m_bndryGhostCellsOffset;
1043 MInt m_initialCondition = fvSolver().m_initialCondition;
1044 MFloat m_rhoUnburnt = fvSolver().m_rhoUnburnt;
1045 MFloat m_rhoFlameTube = fvSolver().m_rhoFlameTube;
1046 MInt m_restartTimeStep = fvSolver().m_restartTimeStep;
1049 const MInt noCells = fvSolver().a_noCells();
1051 MFloat factor, Psi, xi = F0, cbar,
a = F0, a1 = F0, a2 = F0,
b = F0, b2 = F0, b1 = F0, c1 = F0, FD, Rr,
1053 MFloat reactionEnthalpy, rhoBar;
1054 const MFloat gammaMinusOne = fvSolver().m_gamma - F1;
1055 const MFloat FgammaMinusOne = F1 / gammaMinusOne;
1057 MFloat FlaminarFlameThickness = F1 / fvSolver().m_laminarFlameThickness;
1059 MFloat rhoUFrhoB = fvSolver().m_burntUnburntTemperatureRatio;
1060 MFloat rhoBurnt = fvSolver().m_rhoInfinity / fvSolver().m_burntUnburntTemperatureRatio;
1061 MFloat rhoJump = F1 / fvSolver().m_burntUnburntTemperatureRatio - F1;
1062 MFloat FrhoBurnt = fvSolver().m_burntUnburntTemperatureRatio;
1063 MFloat factor1 = fvSolver().m_c0 / (F1 - fvSolver().m_c0);
1064 MFloat echekkiFerzigerPrefactor = F1 / (F1 - fvSolver().m_c0) * (F1 / (F1 - fvSolver().m_c0) - F1);
1065 const MFloat sq1F2 = sqrt(F1B2);
1066 const MFloat eps = fvSolver().c_cellLengthAtLevel(fvSolver().maxRefinementLevel()) * 0.00000000001;
1067 MFloat levelSetNegative = F0, levelSetPlus = F0;
1069 if(lsSolver().m_noSets > 1) {
1071 "This routine should only be called if lsSolver().m_noSets = 1, which is not the case here... Please "
1077 fvSolver().m_maxReactionRate = F0;
1078 fvSolver().m_totalHeatReleaseRate = F0;
1080 reactionEnthalpy = (fvSolver().m_burntUnburntTemperatureRatio - F1) * FgammaMinusOne;
1082 if(fvSolver().m_RKStep == 0) {
1084 memcpy(&fvSolver().a_reactionRateBackup(0, 0), &fvSolver().a_reactionRate(0, 0),
1085 sizeof(
MFloat) * fvSolver().noInternalCells());
1088 for(
MInt c = 0; c < noCells; c++) {
1089 fvSolver().a_reactionRate(c, 0) = F0;
1092 sigma = m_subfilterVariance * fvSolver().c_cellLengthAtLevel(fvSolver().maxLevel());
1093 factor = F1 / (sqrt(F2) * sigma);
1095 if(reactionEnthalpy < m_rhoEInfinity * 0.00001) {
1098 switch(m_initialCondition) {
1106 MFloat diffTimeStep = 50000;
1107 if(m_temperatureChange && (
globalTimeStep - m_restartTimeStep) <= diffTimeStep) {
1109 (fvSolver().m_burntUnburntTemperatureRatioEnd - fvSolver().m_burntUnburntTemperatureRatioStart);
1110 fvSolver().m_burntUnburntTemperatureRatio = (diffTemp / diffTimeStep) * (
globalTimeStep - m_restartTimeStep)
1111 + fvSolver().m_burntUnburntTemperatureRatioStart;
1113 rhoBurnt = m_rhoFlameTube / fvSolver().m_burntUnburntTemperatureRatio;
1114 FrhoBurnt = fvSolver().m_burntUnburntTemperatureRatio * F1 / m_rhoFlameTube;
1115 rhoJump = F1 - fvSolver().m_burntUnburntTemperatureRatio;
1116 for(
MInt c = 0; c < m_bndryGhostCellsOffset; c++) {
1117 if(fvSolver().grid().tree().hasProperty(c, Cell::IsHalo)) {
1120 if(!fvSolver().a_hasProperty(c, SolverCell::IsOnCurrentMGLevel)) {
1123 MInt cLs = fv2lsId(c);
1134 if(
ABS(lsSolver().m_outsideGValue -
ABS(lsSolver().a_levelSetFunctionG(gc, 0))) < 0.02) {
1137 if(lsSolver().a_level(gc) != fvSolver().maxRefinementLevel()) {
1145 FD = F1 / fvSolver().m_DthInfinity;
1147 levelSetNegative = lsSolver().a_levelSetFunctionG(gc, 0) - m_noReactionCells;
1148 levelSetPlus = lsSolver().a_levelSetFunctionG(gc, 0) + m_noReactionCells;
1150 if(m_useCorrectedBurningVelocity) {
1151 if(lsSolver().m_sharpDamp) {
1152 Rr = echekkiFerzigerPrefactor *
POW2(lsSolver().a_correctedBurningVelocity(gc, 0)) * FD * F1B4
1153 * (1 + tanh(levelSetPlus * 100.0)) * (1 - tanh(levelSetNegative * 100.0));
1155 Rr = echekkiFerzigerPrefactor *
POW2(lsSolver().a_correctedBurningVelocity(gc, 0)) * FD;
1158 if(lsSolver().m_sharpDamp) {
1159 Rr = echekkiFerzigerPrefactor
1160 *
POW2(lsSolver().a_flameSpeedG(gc, 0) * (F1 - lsSolver().a_curvatureG(gc, 0) * m_marksteinLength))
1161 * FD * F1B4 * (1 + tanh(levelSetPlus * 100.0)) * (1 - tanh(levelSetNegative * 100.0));
1163 Rr = echekkiFerzigerPrefactor
1164 *
POW2(lsSolver().a_flameSpeedG(gc, 0) * (F1 - lsSolver().a_curvatureG(gc, 0) * m_marksteinLength))
1170 if(m_heatReleaseDamp) {
1171 if(lsSolver().c_coordinate(gc, 1) < (0.0234 + m_dampingDistanceFlameBase)) {
1172 if(lsSolver().c_coordinate(gc, 1) > 0.0234) {
1173 Rr *= 1. / m_dampingDistanceFlameBase * (lsSolver().c_coordinate(gc, 1) - 0.0234);
1176 if(lsSolver().c_coordinate(gc, 1) < 0.0234) {
1182 xi = lsSolver().a_levelSetFunctionG(gc, 0) * factor;
1185 a = xi - sq1F2 * factor1 * sigma * FlaminarFlameThickness;
1186 a1 = F1B2 * (
POW2(sigma * factor1 * FlaminarFlameThickness))
1187 - SQRT2 * xi * sigma * factor1 * FlaminarFlameThickness;
1189 a2 = (F1 - fvSolver().m_c0) * exp(a1) * F1B2
1192 a2 = (F1 - fvSolver().m_c0) * exp(a1) * F1B2 * (erf(
a) + F1);
1194 b = xi + sq1F2 * sigma * FlaminarFlameThickness;
1195 b1 = F1B2 *
POW2(sigma * FlaminarFlameThickness) + SQRT2 * xi * sigma * FlaminarFlameThickness;
1197 b2 = fvSolver().m_c0 * exp(b1) * F1B2 * (-erfc(
b));
1199 b2 = fvSolver().m_c0 * exp(b1) * F1B2 * (erf(
b) - F1);
1201 c1 = F1B2 * (erf(xi) - F1);
1202 cbar = F1 - (a2 + b2 - c1);
1205 if(
ABS(F1 - cbar) < eps) {
1208 Psi = a2 / ((F1 - cbar) *
POW2((rhoUFrhoB + cbar * rhoJump)));
1211 fvSolver().a_psi(c) = Psi;
1214 rhoBar = m_rhoUnburnt / (1 - fvSolver().a_pvariable(c, fvSolver().PV->C) * rhoJump);
1217 fvSolver().a_reactionRate(c, 0) =
1218 m_Re0 * rhoBar * rhoUFrhoB * Rr * (F1 - fvSolver().a_pvariable(c, fvSolver().PV->C)) * Psi;
1221 if(!(fvSolver().a_reactionRate(c, 0) >= F0) && !(fvSolver().a_reactionRate(c, 0) <= F0)) {
1223 cerr <<
"reaction rate is nan!!!" << endl;
1252 fvSolver().a_rightHandSide(c, fvSolver().CV->RHO_C) -=
1253 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c);
1254 fvSolver().a_rightHandSide(c, fvSolver().CV->RHO_E) -=
1255 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c) * reactionEnthalpy;
1258 if(!fvSolver().a_hasProperty(c, Cell::IsHalo)) {
1259 fvSolver().m_maxReactionRate =
mMax(fvSolver().a_reactionRate(c, 0), fvSolver().m_maxReactionRate);
1260 fvSolver().m_totalHeatReleaseRate +=
1261 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c) * reactionEnthalpy;
1264 MPI_Allreduce(MPI_IN_PLACE, &diverged, 1, MPI_INT, MPI_MAX, fvSolver().mpiComm(), AT_,
"MPI_IN_PLACE",
1267 cerr <<
"Solution diverged, writing NETCDF file for debugging" << endl;
1268 MString errorMessage =
"reaction rate is nan";
1269 fvSolver().saveSolverSolution(1);
1270 stringstream fileNameVtk;
1271 stringstream levelSetFileName;
1272 levelSetFileName <<
"restartLevelSetNewGCellGrid_"
1275 stringstream levelSetFileNameSol;
1276 levelSetFileNameSol <<
"restartLevelSetNew_"
1279 lsSolver().writeRestartLevelSetFileCG(1, (levelSetFileName.str()).c_str(), (levelSetFileNameSol.str()).c_str());
1281 mTerm(1, AT_, errorMessage);
1295 MFloat diffTimeStep = 50000;
1296 if(m_temperatureChange && (
globalTimeStep - m_restartTimeStep) <= diffTimeStep) {
1298 (fvSolver().m_burntUnburntTemperatureRatioEnd - fvSolver().m_burntUnburntTemperatureRatioStart);
1299 fvSolver().m_burntUnburntTemperatureRatio = (diffTemp / diffTimeStep) * (
globalTimeStep - m_restartTimeStep)
1300 + fvSolver().m_burntUnburntTemperatureRatioStart;
1302 rhoBurnt = m_rhoFlameTube / fvSolver().m_burntUnburntTemperatureRatio;
1303 FrhoBurnt = fvSolver().m_burntUnburntTemperatureRatio * F1 / m_rhoFlameTube;
1304 rhoJump = F1 - fvSolver().m_burntUnburntTemperatureRatio;
1305 for(
MInt c = 0; c < m_bndryGhostCellsOffset; c++) {
1306 if(fvSolver().grid().tree().hasProperty(c, Cell::IsHalo)) {
1309 if(!fvSolver().a_hasProperty(c, SolverCell::IsOnCurrentMGLevel)) {
1312 MInt cLs = fv2lsId(c);
1322 if(
ABS(lsSolver().m_outsideGValue -
ABS(lsSolver().a_levelSetFunctionG(gc, 0))) < eps) {
1330 FD = F1 / fvSolver().m_DthInfinity;
1332 levelSetNegative = lsSolver().a_levelSetFunctionG(gc, 0) - m_noReactionCells;
1333 levelSetPlus = lsSolver().a_levelSetFunctionG(gc, 0) + m_noReactionCells;
1335 if(!m_constantFlameSpeed) {
1336 if(lsSolver().m_sharpDamp) {
1337 Rr = echekkiFerzigerPrefactor
1338 *
POW2(lsSolver().a_flameSpeedG(gc, 0) * (F1 - lsSolver().a_curvatureG(gc, 0) * m_marksteinLength))
1339 * FD * F1B4 * (1 + tanh(levelSetPlus * 100.0)) * (1 - tanh(levelSetNegative * 100.0));
1341 Rr = echekkiFerzigerPrefactor
1342 *
POW2(lsSolver().a_flameSpeedG(gc, 0) * (F1 - lsSolver().a_curvatureG(gc, 0) * m_marksteinLength))
1346 if(lsSolver().m_sharpDamp) {
1347 Rr = echekkiFerzigerPrefactor *
POW2(lsSolver().a_flameSpeedG(gc, 0)) * FD * F1B4
1348 * (1 + tanh(levelSetPlus * 100.0)) * (1 - tanh(levelSetNegative * 100.0));
1350 Rr = echekkiFerzigerPrefactor *
POW2(lsSolver().a_flameSpeedG(gc, 0)) * FD;
1354 if(m_heatReleaseDamp) {
1355 if(lsSolver().c_coordinate(gc, 1) < (m_yOffsetFlameTube + m_dampingDistanceFlameBase)) {
1356 if(lsSolver().c_coordinate(gc, 1) > m_yOffsetFlameTube) {
1357 Rr *= 1. / m_dampingDistanceFlameBase * (lsSolver().c_coordinate(gc, 1) - m_yOffsetFlameTube);
1360 if(lsSolver().c_coordinate(gc, 1) < m_yOffsetFlameTube) {
1365 xi = lsSolver().a_levelSetFunctionG(gc, 0) * factor;
1368 a = xi - sq1F2 * factor1 * sigma * FlaminarFlameThickness;
1369 a1 = F1B2 * (
POW2(sigma * factor1 * FlaminarFlameThickness))
1370 - SQRT2 * xi * sigma * factor1 * FlaminarFlameThickness;
1372 a2 = (F1 - fvSolver().m_c0) * exp(a1) * F1B2
1375 a2 = (F1 - fvSolver().m_c0) * exp(a1) * F1B2 * (erf(
a) + F1);
1377 b = xi + sq1F2 * sigma * FlaminarFlameThickness;
1378 b1 = F1B2 *
POW2(sigma * FlaminarFlameThickness) + SQRT2 * xi * sigma * FlaminarFlameThickness;
1380 b2 = fvSolver().m_c0 * exp(b1) * F1B2 * (-erfc(
b));
1382 b2 = fvSolver().m_c0 * exp(b1) * F1B2 * (erf(
b) - F1);
1384 c1 = F1B2 * (erf(xi) - F1);
1385 cbar = F1 - (a2 + b2 - c1);
1388 if(
ABS(F1 - cbar) < eps) {
1391 Psi = a2 / ((F1 - cbar) *
POW2((rhoUFrhoB + cbar * rhoJump)));
1394 fvSolver().a_psi(c) = Psi;
1397 rhoBar = m_rhoUnburnt / (1 - fvSolver().a_pvariable(c, fvSolver().PV->C) * rhoJump);
1400 fvSolver().a_reactionRate(c, 0) =
1401 m_Re0 * rhoBar * rhoUFrhoB * Rr * (F1 - fvSolver().a_pvariable(c, fvSolver().PV->C)) * Psi;
1404 if(!(fvSolver().a_reactionRate(c, 0) >= F0) && !(fvSolver().a_reactionRate(c, 0) <= F0)) {
1434 fvSolver().a_rightHandSide(c, fvSolver().CV->RHO_C) -=
1435 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c);
1436 fvSolver().a_rightHandSide(c, fvSolver().CV->RHO_E) -=
1437 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c) * reactionEnthalpy;
1440 if(!fvSolver().a_hasProperty(c, Cell::IsHalo)) {
1441 fvSolver().m_maxReactionRate =
mMax(fvSolver().a_reactionRate(c, 0), fvSolver().m_maxReactionRate);
1442 fvSolver().m_totalHeatReleaseRate +=
1443 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c) * reactionEnthalpy;
1446 MPI_Allreduce(MPI_IN_PLACE, &diverged, 1, MPI_INT, MPI_MAX, fvSolver().mpiComm(), AT_,
"MPI_IN_PLACE",
1450 MString errorMessage =
"reaction rate is nan";
1460 mTerm(1, AT_, errorMessage);
1469 MFloat diffTimeStep = 50000;
1470 if(m_temperatureChange && (
globalTimeStep - m_restartTimeStep) <= diffTimeStep) {
1472 (fvSolver().m_burntUnburntTemperatureRatioEnd - fvSolver().m_burntUnburntTemperatureRatioStart);
1473 fvSolver().m_burntUnburntTemperatureRatio = (diffTemp / diffTimeStep) * (
globalTimeStep - m_restartTimeStep)
1474 + fvSolver().m_burntUnburntTemperatureRatioStart;
1476 rhoBurnt = m_rhoFlameTube / fvSolver().m_burntUnburntTemperatureRatio;
1478 FrhoBurnt = fvSolver().m_burntUnburntTemperatureRatio * F1 / m_rhoFlameTube;
1480 rhoJump = F1 - fvSolver().m_burntUnburntTemperatureRatio;
1482 for(
MInt c = 0; c < m_bndryGhostCellsOffset; c++) {
1483 if(fvSolver().grid().tree().hasProperty(c, Cell::IsHalo)) {
1486 if(!fvSolver().a_hasProperty(c, SolverCell::IsOnCurrentMGLevel)) {
1489 MInt cLs = fv2lsId(c);
1501 if(
ABS(lsSolver().m_outsideGValue -
ABS(lsSolver().a_levelSetFunctionG(gc, 0))) < eps) {
1510 FD = F1 / fvSolver().m_DthInfinity;
1512 levelSetNegative = lsSolver().a_levelSetFunctionG(gc, 0) - m_noReactionCells;
1513 levelSetPlus = lsSolver().a_levelSetFunctionG(gc, 0) + m_noReactionCells;
1516 MFloat turbFlameSpeed = m_turbFlameSpeed;
1517 MFloat delta = fvSolver().c_cellLengthAtLevel(fvSolver().maxLevel());
1518 MFloat uAmpl = pow(m_integralAmplitude, 3);
1520 uAmpl /= m_integralLengthScale;
1521 uAmpl = pow(uAmpl, F1B3);
1522 MFloat flameSpeed = m_flameSpeed;
1524 MFloat Dt = m_NuT / m_ScT;
1527 if(fvSolver().m_Da > 1) {
1528 FDa *= F1 / pow(fvSolver().m_Da, 2);
1532 - lsSolver().a_curvatureG(gc, 0)
1533 * m_marksteinLength);
1535 flameSpeed += turbFlameSpeed;
1537 flameSpeed -= FDa * lsSolver().a_curvatureG(gc, 0);
1539 flameSpeed = pow(flameSpeed, 2);
1542 Rr = echekkiFerzigerPrefactor * flameSpeed * FD;
1545 if(m_heatReleaseDamp) {
1546 if(lsSolver().c_coordinate(gc, 1) < (m_yOffsetFlameTube + m_dampingDistanceFlameBase)) {
1547 if(lsSolver().c_coordinate(gc, 1) > m_yOffsetFlameTube) {
1548 Rr *= 1. / m_dampingDistanceFlameBase * (lsSolver().c_coordinate(gc, 1) - m_yOffsetFlameTube);
1551 if(lsSolver().c_coordinate(gc, 1) < m_yOffsetFlameTube) {
1559 xi = lsSolver().a_levelSetFunctionG(gc, 0) * factor;
1562 a = xi - sq1F2 * factor1 * sigma * FlaminarFlameThickness;
1563 a1 = F1B2 * (
POW2(sigma * factor1 * FlaminarFlameThickness))
1564 - SQRT2 * xi * sigma * factor1 * FlaminarFlameThickness;
1566 a2 = (F1 - fvSolver().m_c0) * exp(a1) * F1B2
1569 a2 = (F1 - fvSolver().m_c0) * exp(a1) * F1B2 * (erf(
a) + F1);
1571 b = xi + sq1F2 * sigma * FlaminarFlameThickness;
1572 b1 = F1B2 *
POW2(sigma * FlaminarFlameThickness) + SQRT2 * xi * sigma * FlaminarFlameThickness;
1574 b2 = fvSolver().m_c0 * exp(b1) * F1B2 * (-erfc(
b));
1576 b2 = fvSolver().m_c0 * exp(b1) * F1B2 * (erf(
b) - F1);
1578 c1 = F1B2 * (erf(xi) - F1);
1579 cbar = F1 - (a2 + b2 - c1);
1582 if(
ABS(F1 - cbar) < eps) {
1585 Psi = a2 / ((F1 - cbar) *
POW2((rhoUFrhoB + cbar * rhoJump)));
1588 fvSolver().a_psi(c) = Psi;
1591 rhoBar = m_rhoUnburnt / (1 - fvSolver().a_pvariable(c, fvSolver().PV->C) * rhoJump);
1594 fvSolver().a_reactionRate(c, 0) =
1595 m_Re0 * rhoBar * rhoUFrhoB * Rr * (F1 - fvSolver().a_pvariable(c, fvSolver().PV->C)) * Psi;
1598 if(!(fvSolver().a_reactionRate(c, 0) >= F0) && !(fvSolver().a_reactionRate(c, 0) <= F0)) {
1628 fvSolver().a_rightHandSide(c, fvSolver().CV->RHO_C) -=
1629 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c);
1630 fvSolver().a_rightHandSide(c, fvSolver().CV->RHO_E) -=
1631 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c) * reactionEnthalpy;
1634 if(!fvSolver().a_hasProperty(c, Cell::IsHalo)) {
1635 fvSolver().m_maxReactionRate =
mMax(fvSolver().a_reactionRate(c, 0), fvSolver().m_maxReactionRate);
1636 fvSolver().m_totalHeatReleaseRate +=
1637 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c) * reactionEnthalpy;
1640 MPI_Allreduce(MPI_IN_PLACE, &diverged, 1, MPI_INT, MPI_MAX, fvSolver().mpiComm(), AT_,
"MPI_IN_PLACE",
1644 MString errorMessage =
"reaction rate is nan";
1647 mTerm(1, AT_, errorMessage);
1652 for(
MInt c = 0; c < m_bndryGhostCellsOffset; c++) {
1653 if(fvSolver().grid().tree().hasProperty(c, Cell::IsHalo)) {
1656 if(!fvSolver().a_hasProperty(c, SolverCell::IsOnCurrentMGLevel)) {
1659 MInt cLs = fv2lsId(c);
1670 if(
ABS(lsSolver().m_outsideGValue -
ABS(lsSolver().a_levelSetFunctionG(gc, 0))) < eps) {
1677 rhoU = fvSolver().m_rhoInfinity;
1680 Dth = SUTHERLANDLAW(m_TInfinity) / (rhoU * m_Pr);
1683 Rr = echekkiFerzigerPrefactor *
POW2(lsSolver().a_correctedBurningVelocity(gc, 0)) * FD;
1687 xi = lsSolver().a_levelSetFunctionG(gc, 0) * factor;
1689 a = xi - sq1F2 * factor1 * sigma * FlaminarFlameThickness;
1691 a1 = F1B2 * (
POW2(sigma * factor1 * FlaminarFlameThickness))
1692 - SQRT2 * xi * sigma * factor1 * FlaminarFlameThickness;
1694 a2 = (F1 - fvSolver().m_c0) * exp(a1) * F1B2
1697 a2 = (F1 - fvSolver().m_c0) * exp(a1) * F1B2 * (erf(
a) + F1);
1699 b = xi + sq1F2 * sigma * FlaminarFlameThickness;
1700 b1 = F1B2 *
POW2(sigma * FlaminarFlameThickness) + SQRT2 * xi * sigma * FlaminarFlameThickness;
1702 b2 = fvSolver().m_c0 * exp(b1) * F1B2 * (-erfc(
b));
1704 b2 = fvSolver().m_c0 * exp(b1) * F1B2 * (erf(
b) - F1);
1706 c1 = F1B2 * (erf(xi) - F1);
1707 cbar = F1 - (a2 + b2 - c1);
1709 denominator = (F1 - cbar) *
POW2((rhoUFrhoB + cbar * rhoJump * FrhoBurnt));
1710 if(
approx(denominator, 0.0, MFloatEps)) {
1713 Psi = a2 / denominator;
1717 rhoBar = fvSolver().m_rhoInfinity / (1 - fvSolver().a_pvariable(c, fvSolver().PV->C) * rhoJump / rhoBurnt);
1720 fvSolver().a_reactionRate(c, 0) = m_Re0 * fvSolver().a_pvariable(c, fvSolver().PV->RHO) * rhoUFrhoB * Rr
1721 * (F1 - fvSolver().a_pvariable(c, fvSolver().PV->C)) * Psi;
1724 if(!(fvSolver().a_reactionRate(c, 0) >= F0) && !(fvSolver().a_reactionRate(c, 0) <= F0)) {
1740 mTerm(1, AT_,
"reaction rate is nan!!!");
1744 fvSolver().a_rightHandSide(c, fvSolver().CV->RHO_C) -=
1745 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c);
1746 fvSolver().a_rightHandSide(c, fvSolver().CV->RHO_E) -=
1747 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c) * reactionEnthalpy;
1750 fvSolver().m_maxReactionRate =
mMax(fvSolver().a_reactionRate(c, 0), fvSolver().m_maxReactionRate);
1751 fvSolver().m_totalHeatReleaseRate +=
1752 fvSolver().a_reactionRate(c, 0) * fvSolver().a_cellVolume(c) * reactionEnthalpy;
1757 if(fvSolver().noDomains() > 1) {
1758 MPI_Allreduce(MPI_IN_PLACE, &fvSolver().m_totalHeatReleaseRate, 1, MPI_DOUBLE, MPI_SUM, fvSolver().mpiComm(), AT_,
1759 "MPI_IN_PLACE",
"fvSolver().m_totalHeatReleaseRate");
1760 MPI_Allreduce(MPI_IN_PLACE, &fvSolver().m_maxReactionRate, 1, MPI_DOUBLE, MPI_MAX, fvSolver().mpiComm(), AT_,
1761 "MPI_IN_PLACE",
"fvSolver().m_maxReactionRate");
1777template <MInt nDim,
class SysEqn>
1781 std::ignore = fluidDensity;
1885template <MInt nDim,
class SysEqn>
1889 for(
MInt set = lsSolver().m_startSet; set < lsSolver().m_noSets; set++) {
1891 for(
MInt id = 0;
id < lsSolver().a_bandLayer(0, set);
id++) {
1892 MFloat correctedBurningVelocity =
1893 lsSolver().a_flameSpeedG(lsSolver().a_bandCellId(
id, set), set)
1894 * (F1 - lsSolver().a_curvatureG(lsSolver().a_bandCellId(
id, set), set) * lsSolver().m_marksteinLength);
1896 for(
MInt i = 0; i < nDim; i++)
1897 lsSolver().a_extensionVelocityG(lsSolver().a_bandCellId(
id, set), i, set) =
1898 fvSolver().a_variable(lsSolver().a_bandCellId(
id, set), fvSolver().PV->VV[i])
1899 + lsSolver().a_normalVectorG(lsSolver().a_bandCellId(
id, set), i, set) * correctedBurningVelocity;
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
void exchangeCouplingData()
void setRhoFlameTubeInLs()
void setRhoInfinityInLs()
MInt noLevelSetFieldData()
MFloat collectFvDataForCollectGEquationModelDataOpt(MInt, MInt)
void computeGCellTimeStep()
void computeSourceTerms()
MFloat collectGFromCouplingClass(MInt)
void constructExtensionVelocity()
void collectGEquationModelDataOpt(MFloat *fluidDensity, MInt set)
MFloat collectCurvFromCouplingClass(MInt)
void setLsTimeStep(MFloat)
void fastInterfaceExtensionVelocity()
void finalizeCouplerInit() override
LsFvCombustion(const MInt couplingId, LsSolver *ls, FvCartesianSolver *fv)
void preCouple(MInt) override
LsSolver & lsSolver() const
void collectGEquationModelDataOptInterpolate(MFloat *fluidDensity, MInt set)
transfers v from the flow to the G-grid (highest level) via interpolation
This class is a ScratchSpace.
T * getPointer() const
Deprecated: use begin() instead!
void fill(T val)
fill the scratch with a given value
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 POW2(const Real x)
MBool approx(const T &, const U &, const T)
constexpr T mMax(const T &x, const T &y)
std::basic_string< char > MString
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_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