00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _CUTCELLMOMENTSIMPLEM_H_
00012 #define _CUTCELLMOMENTSIMPLEM_H_
00013
00014
00015 #if defined(CH_Darwin) && defined(__GNUC__) && ( __GNUC__ == 3 )
00016
00017 #include <unistd.h>
00018 #define _GLIBCPP_USE_C99 1
00019 #endif
00020
00021 #include <cmath>
00022 #include <cstdio>
00023 #include <cstdlib>
00024 #include <fstream>
00025 #include <iostream>
00026 #include <string>
00027
00028 #include "MayDay.H"
00029
00030 #include "NoRefinement.H"
00031 #include "LSProblem.H"
00032
00033 #include "NamespaceHeader.H"
00034
00035
00036 template <int dim> inline CutCellMoments<dim>::CutCellMoments()
00037 {
00038 }
00039
00040 inline CutCellMoments<1>::CutCellMoments()
00041 {
00042 }
00043
00044
00045 template <int dim> inline CutCellMoments<dim>::CutCellMoments(const CutCellMoments<dim>& a_cutCellMoments)
00046 :m_moments(a_cutCellMoments.m_moments),
00047 m_EBmoments(a_cutCellMoments.m_EBmoments),
00048 m_bdCutCellMoments(a_cutCellMoments.m_bdCutCellMoments),
00049 m_iFData(a_cutCellMoments.m_iFData),
00050 m_bdCCOn(a_cutCellMoments.m_bdCCOn),
00051 m_residual(a_cutCellMoments.m_residual)
00052 {
00053 }
00054
00055
00056 inline CutCellMoments<1>::CutCellMoments(const CutCellMoments<1>& a_thisCutCellMoments)
00057
00058 :m_moments(a_thisCutCellMoments.m_moments),
00059 m_iFData(a_thisCutCellMoments.m_iFData)
00060 {
00061 }
00062
00063
00064 template <int dim> inline CutCellMoments<dim>::CutCellMoments(const IFData<dim>& a_info)
00065 :m_iFData(a_info)
00066 {
00067 CH_TIME("CutCellMoments::constructor");
00068
00069 m_bdCCOn = false;
00070
00071 for (int hilo = 0; hilo < 2; ++hilo)
00072 {
00073 for (int idir = 0; idir < dim; ++idir)
00074 {
00075 Iv2 bdId;
00076 bdId[BDID_DIR] = idir;
00077 bdId[BDID_HILO] = hilo;
00078
00079 IFData<dim-1> reducedInfo(a_info,idir,hilo);
00080 CutCellMoments<dim-1>bdCutCellMoments(reducedInfo);
00081
00082 m_bdCutCellMoments[bdId] = bdCutCellMoments;
00083
00084
00085
00086 if (reducedInfo.m_allVerticesOn)
00087 {
00088 m_bdCCOn = true;
00089 }
00090 }
00091 }
00092 }
00093
00094
00095 inline CutCellMoments<1>::CutCellMoments(const IFData<1> & a_info)
00096 :m_iFData(a_info)
00097 {
00098 }
00099
00100
00101 template <int dim> inline CutCellMoments<dim>::~CutCellMoments()
00102 {
00103 }
00104
00105 inline CutCellMoments<1>::~CutCellMoments()
00106 {
00107 }
00108
00109 template <int dim> inline const CutCellMoments<dim - 1> CutCellMoments<dim>::getBdCutCellMoments(const Iv2 & a_bdId) const
00110 {
00111 typename BdCutCellMoments::const_iterator it = m_bdCutCellMoments.find(a_bdId);
00112
00113 if (it == m_bdCutCellMoments.end())
00114 {
00115 MayDay::Abort("Can't find this bdId in m_bdCutCellMoments");
00116 }
00117
00118 return it->second;
00119 }
00120
00121
00122 template <int dim> inline void CutCellMoments<dim>::computeMoments(const int & a_order,
00123 const int & a_degreeP,
00124 const bool & a_useConstraints,
00125 RefinementCriterion & a_refinementCriterion)
00126 {
00127 CH_TIME("CutCellMoments::ComputeMoments");
00128
00129 Vector<Real> RNorm(3);
00130 for (int i = 0; i < 3; i++)
00131 {
00132 RNorm[i] = LARGEREALVAL;
00133 }
00134
00135 for (int i = 0; i < a_degreeP + 1; i++)
00136 {
00137 m_residual.push_back(RNorm);
00138 }
00139
00140 if (m_iFData.m_allVerticesOut)
00141 {
00142 for (int iDegree = a_degreeP; iDegree >= 0; --iDegree)
00143 {
00144 LSProblem<dim> lsp(iDegree,a_useConstraints);
00145
00146
00147 const PthMomentLoc monDegreeP = lsp.getMonomialLocMapDegreeP();
00148 for (typename PthMomentLoc::const_iterator it=monDegreeP.begin(); it != monDegreeP.end(); ++it)
00149 {
00150 m_EBmoments[it->first] = 0.0;
00151 }
00152
00153 const PthMomentLoc monDegreePLess1 = lsp.getMonomialLocMapDegreePLess1();
00154 for (typename PthMomentLoc::const_iterator it = monDegreePLess1.begin(); it != monDegreePLess1.end(); ++it)
00155 {
00156 m_moments[it->first] = 0.0;
00157 }
00158 }
00159 }
00160 else if (m_iFData.m_allVerticesIn && !m_bdCCOn)
00161 {
00162 for (int iDegree = a_degreeP; iDegree >= 0; --iDegree)
00163 {
00164 LSProblem<dim> lsp(iDegree,a_useConstraints);
00165
00166
00167 const PthMomentLoc monDegreeP = lsp.getMonomialLocMapDegreeP();
00168 for (typename PthMomentLoc::const_iterator it = monDegreeP.begin(); it != monDegreeP.end(); ++it)
00169 {
00170 m_EBmoments[it->first] = 0.0;
00171 }
00172
00173 const PthMomentLoc monDegreePLess1 = lsp.getMonomialLocMapDegreePLess1();
00174 for (typename PthMomentLoc::const_iterator it = monDegreePLess1.begin(); it != monDegreePLess1.end(); ++it)
00175 {
00176 m_moments[it->first] = fullCellQuadrature(it->first);
00177 }
00178 }
00179 }
00180 else
00181 {
00182 for (typename BdCutCellMoments::iterator it = m_bdCutCellMoments.begin(); it != m_bdCutCellMoments.end(); ++it)
00183 {
00184 NoRefinement noRefinement;
00185 it->second.computeMoments(a_order,a_degreeP+1,a_useConstraints,noRefinement);
00186 }
00187
00188 for (int iDegree = a_degreeP; iDegree >= 0; --iDegree)
00189 {
00190
00191 LSProblem<dim> lsp(a_order,iDegree,a_useConstraints,m_iFData.m_normal);
00192
00193 Vector<Real> rhs = computeRhs(lsp,a_order);
00194
00195 if (a_useConstraints)
00196 {
00197 lsp.computeBounds(m_iFData.m_dx,*this);
00198 }
00199
00200
00201 lsp.invertNormalEq(rhs,m_residual[iDegree]);
00202
00203
00204 const PthMomentLoc monDegreeP = lsp.getMonomialLocMapDegreeP();
00205 for (typename PthMomentLoc::const_iterator it = monDegreeP.begin(); it != monDegreeP.end(); ++it)
00206 {
00207 m_EBmoments[it->first] = lsp.getUnknown(it->second);
00208 }
00209
00210 const PthMomentLoc monDegreePLess1 = lsp.getMonomialLocMapDegreePLess1();
00211 for (typename PthMomentLoc::const_iterator it = monDegreePLess1.begin(); it != monDegreePLess1.end(); ++it)
00212 {
00213 m_moments[it->first] = lsp.getUnknown(it->second
00214 + lsp.getNumberDegP());
00215 }
00216 }
00217 }
00218
00219 Vector<int> refineInDir(dim);
00220 Vector<Real> vectDx (dim);
00221
00222 for (int idir = 0; idir < dim; idir++)
00223 {
00224 vectDx[idir] = m_iFData.m_dx[idir];
00225 }
00226
00227 if (a_refinementCriterion.doRefine(refineInDir,dim,vectDx,m_residual))
00228 {
00229
00230
00231 Vector<CutCellMoments<dim> > refinedCCMoms = refine(a_order,a_degreeP,a_useConstraints,a_refinementCriterion,refineInDir);
00232
00233
00234
00235 addMomentMaps(refinedCCMoms,a_degreeP,a_useConstraints);
00236
00237
00238 computeResiduals(refinedCCMoms,a_degreeP);
00239 }
00240 }
00241
00242
00243 inline void CutCellMoments<1>::computeMoments(const int & a_order,
00244 const int & a_degree,
00245 const bool & a_useConstraints,
00246 RefinementCriterion & a_refinementCriterion)
00247 {
00248 int lo = 0;
00249 int hi = 1;
00250 int loSign = m_iFData.m_cornerSigns[lo];
00251 int hiSign = m_iFData.m_cornerSigns[hi];
00252
00253
00254 if (loSign <= ON && hiSign<= ON)
00255 {
00256 for (int iDegree = 0; iDegree <= a_degree; ++iDegree)
00257 {
00258
00259
00260 IndexTM<int,1> degree;
00261 degree[0] = iDegree;
00262 m_moments[degree] = 0.0;
00263 }
00264 }
00265 else
00266 {
00267
00268
00269 Real loPt = LARGEREALVAL;
00270 Real hiPt = LARGEREALVAL;
00271
00272 if (loSign >= ON)
00273 {
00274 loPt = -0.5 * m_iFData.m_dx;
00275 }
00276 else
00277 {
00278 loPt = 0.5 * m_iFData.m_intersection * m_iFData.m_dx;
00279 }
00280
00281 if (hiSign >= ON)
00282 {
00283 hiPt = 0.5 * m_iFData.m_dx;
00284 }
00285 else
00286 {
00287 hiPt = 0.5 * m_iFData.m_intersection * m_iFData.m_dx;
00288 }
00289
00290 CH_assert(-0.5*m_iFData.m_dx <= loPt && loPt <= 0.5*m_iFData.m_dx);
00291 CH_assert(-0.5*m_iFData.m_dx <= hiPt && hiPt <= 0.5*m_iFData.m_dx);
00292
00293
00294 computeMomentsUsingBinomial(loPt,hiPt,loSign,hiSign,a_degree);
00295 }
00296 }
00297
00298 inline void CutCellMoments<1>::simpleComputeMoments(const Real & a_loPt,
00299 const Real & a_hiPt,
00300 const int & a_degree)
00301 {
00302 for (int iDegree = 0; iDegree <= a_degree; ++iDegree)
00303 {
00304
00305 IndexTM<int,1>degree;
00306 degree[0] = iDegree;
00307 m_moments[degree] = pow(a_hiPt,iDegree + 1) - pow(a_loPt,iDegree +1);
00308 m_moments[degree] /= (iDegree + 1);
00309 }
00310 }
00311
00312 inline void CutCellMoments<1>::computeMomentsUsingBinomial(const Real & a_loPt,
00313 const Real & a_hiPt,
00314 const int & a_loSign,
00315 const int & a_hiSign,
00316 const int & a_degree)
00317 {
00318 for (int iDegree = 0; iDegree <= a_degree; ++iDegree)
00319 {
00320 Real epsilon = a_hiPt - a_loPt;
00321
00322
00323 IndexTM<int,1> degree;
00324 degree[0] = iDegree;
00325 m_moments[degree] = 0.0;
00326
00327
00328 for (int j = 1; j <= iDegree + 1; j++)
00329 {
00330 int bigger = j;
00331 int smaller = j;
00332 if (iDegree + 1 - j > j)
00333 {
00334 bigger = iDegree + 1 - j;
00335 }
00336 else
00337 {
00338 smaller = iDegree + 1 - j;
00339 }
00340
00341 int numerator = 1;
00342 for (int i = bigger + 1; i <= iDegree + 1; ++i)
00343 {
00344 numerator *= i;
00345 }
00346
00347 int denominator = 1;
00348 for (int i = 1; i <= smaller; ++i)
00349 {
00350 denominator *= i;
00351 }
00352
00353 Real factor = numerator / denominator;
00354 if (a_loSign >= ON)
00355 {
00356 m_moments[degree] += factor * pow(a_loPt,iDegree + 1 - j) * pow(epsilon,j);
00357 }
00358 else if (a_hiSign >= ON)
00359 {
00360 m_moments[degree] -= factor * pow(a_hiPt,iDegree + 1 - j) * pow(epsilon,j) * pow(-1.0,j);
00361 }
00362 }
00363
00364 m_moments[degree] /= iDegree + 1;
00365 }
00366 }
00367
00368 template <int dim> inline Real CutCellMoments<dim>::fullCellQuadrature(const IvDim & a_mono)
00369 {
00370 Real moment = 1.0;
00371 RvDim vectDx = m_iFData.m_dx;
00372
00373 for (int idir = 0; idir < dim; ++idir)
00374 {
00375 Real idirInt = pow( 0.5*vectDx[idir],a_mono[idir] + 1)
00376 - pow(-0.5*vectDx[idir],a_mono[idir] + 1);
00377
00378 idirInt /= (a_mono[idir] + 1);
00379 moment *= idirInt;
00380 }
00381
00382 return moment;
00383 }
00384
00385 template <int dim> inline Vector<Real> CutCellMoments<dim>::computeRhs(LSProblem<dim> & a_lsp,
00386 const int & a_order)
00387 {
00388
00389 int numEq = dim*a_lsp.getNumberDegP();
00390 Vector<Real> rhs(numEq);
00391
00392 Vector< IndexTM<Real,dim> > gradNorm = m_iFData.m_gradNormal;
00393
00394
00395
00396 const LocPthMoment& locMap = a_lsp.getLocMonomialMapDegreeP();
00397 for (typename LocPthMoment::const_iterator it = locMap.begin(); it != locMap.end(); ++it)
00398 {
00399 int jth = it->first;
00400 IvDim mono = it->second;
00401
00402 int hiSide = 1;
00403 int loSide = 0;
00404 Iv2 bdId;
00405
00406 for (int idir = 0; idir < dim; ++idir)
00407 {
00408
00409 IndexTM<int,dim-1> mono1Less;
00410 for (int jdir = 0; jdir < dim; ++jdir)
00411 {
00412 if (jdir < idir)
00413 {
00414 mono1Less[jdir] = mono[jdir];
00415 }
00416 else if (jdir > idir)
00417 {
00418 mono1Less[jdir-1] = mono[jdir];
00419 }
00420 }
00421
00422 bdId[0] = idir;
00423 bdId[1] = hiSide;
00424
00425 Real hiMom = m_bdCutCellMoments[bdId].m_moments[mono1Less];
00426
00427 bdId[1] = loSide;
00428
00429 Real loMom = m_bdCutCellMoments[bdId].m_moments[mono1Less];
00430 int exponent = it->second[idir];
00431
00432 Real hiFactor = pow(0.5*m_iFData.m_dx[idir],exponent);
00433 Real loFactor = pow(-0.5*m_iFData.m_dx[idir],exponent);
00434
00435 rhs[(dim*jth) + idir] = hiMom*hiFactor - loMom*loFactor;
00436
00437
00438 if (a_order < 0 || a_order > 1)
00439 {
00440 MayDay::Abort("CutCellMoments::computeMoments not set up for orders not 0 or 1");
00441 }
00442
00443 if (a_order == 1)
00444 {
00445
00446 for (int jdir = 0; jdir < dim; jdir++)
00447 {
00448 IvDim monoPlus1 = mono;
00449 monoPlus1[jdir] += 1;
00450
00451 if (m_EBmoments.find(monoPlus1) != m_EBmoments.end())
00452 {
00453 Real moment = m_EBmoments[monoPlus1];
00454 rhs[(dim*jth) + idir] += gradNorm[idir][jdir] * moment;
00455 }
00456 }
00457 }
00458 }
00459 }
00460
00461 return rhs;
00462 }
00463
00464 template <int dim> inline Vector< CutCellMoments<dim> > CutCellMoments<dim>::refine(const int & a_order,
00465 const int & a_degreeP,
00466 const bool & a_useConstraints,
00467 RefinementCriterion & a_refinementCriterion,
00468 const Vector<int> & a_refineInDir)
00469 {
00470 CH_assert(m_iFData.m_changingDir.size() == dim);
00471
00472 Vector<CutCellMoments<dim> > refinedCutCellMoments;
00473
00474
00475
00476 IndexTM<Real,dim> refinedDx = m_iFData.m_dx;
00477
00478
00479 IndexTM<int,dim> curIter;
00480 IndexTM<int,dim> maxIter;
00481
00482 for (int idir = 0; idir < dim; idir++)
00483 {
00484 if (a_refineInDir[idir] != 0)
00485 {
00486
00487 refinedDx[idir] /= 2.0;
00488 maxIter[idir] = 1;
00489 }
00490 else
00491 {
00492
00493 maxIter[idir] = 0;
00494 }
00495
00496
00497 curIter[idir] = 0;
00498 }
00499
00500
00501 while (1)
00502 {
00503
00504 IndexTM<Real,GLOBALDIM> refinedCellCenter = m_iFData.m_globalCellCenter;
00505
00506 for (int idir = 0; idir < dim; idir++)
00507 {
00508 int globalDir = m_iFData.m_changingDir[idir];
00509
00510 if (a_refineInDir[idir] != 0)
00511 {
00512 int sign = 2*curIter[idir] - 1;
00513 refinedCellCenter[globalDir] += sign * 0.5*refinedDx[idir];
00514 }
00515 }
00516
00517
00518
00519
00520 IFData<dim> refinedIFData(*m_iFData.m_function,refinedDx,refinedCellCenter,m_iFData.m_normalDir);
00521
00522
00523 CutCellMoments<dim> refinedCCMom(refinedIFData);
00524
00525
00526 refinedCCMom.computeMoments(a_order,a_degreeP,a_useConstraints,a_refinementCriterion);
00527 refinedCutCellMoments.push_back(refinedCCMom);
00528
00529
00530 int idir;
00531 for (idir = 0; idir < dim; idir++)
00532 {
00533 if (curIter[idir] < maxIter[idir])
00534 {
00535
00536 curIter[idir]++;
00537 break;
00538 }
00539 else
00540 {
00541
00542
00543 curIter[idir] = 0;
00544 }
00545 }
00546
00547
00548 if (idir == dim)
00549 {
00550 break;
00551 }
00552 }
00553
00554 return refinedCutCellMoments;
00555 }
00556
00557 template <int dim> inline void CutCellMoments<dim>::addMomentMaps(const Vector<CutCellMoments<dim> > & a_refinedCutCellVector,
00558 const int & a_degreeP,
00559 const bool & a_useConstraints)
00560 {
00561 int numberOfRefinedCC = a_refinedCutCellVector.size();
00562 CH_assert(numberOfRefinedCC>0);
00563
00564 IndexTM<int,2> bdId;
00565
00566
00567
00568
00569 CutCellMoments<dim> cutCell;
00570 int k = 0;
00571
00572 while ((a_refinedCutCellVector[k].m_iFData.m_allVerticesOut || a_refinedCutCellVector[k].m_iFData.m_allVerticesIn)
00573 && k < numberOfRefinedCC)
00574 {
00575 k++;
00576 }
00577
00578 if (k >= numberOfRefinedCC)
00579 {
00580 MayDay::Abort("Exceeded the number of refined CutCellMoments in vector");
00581 }
00582 else
00583 {
00584 cutCell = a_refinedCutCellVector[k];
00585 }
00586
00587 initialize(cutCell);
00588
00589
00590
00591
00592 for (int i = 0; i < numberOfRefinedCC; i++)
00593 {
00594
00595
00596
00597 CutCellMoments<dim> refinedCutCell = a_refinedCutCellVector[i];
00598 IndexTM<int,dim> hilo = LARGEINTVAL*IndexTM<int,dim>::Unit;
00599 IndexTM<Real,dim> refinedCenterDelta = IndexTM<Real,dim>::Zero;
00600
00601 int ii = i;
00602 for (int j = 0; j < dim; ++j)
00603 {
00604 hilo[j] = (ii & 1);
00605 ii = ii >> 1;
00606 }
00607
00608 IndexTM<int,dim> sign = 2*hilo-1;
00609
00610 for (int idir = 0; idir < dim; idir++)
00611 {
00612 refinedCenterDelta[idir] = 0.25*sign[idir]*m_iFData.m_dx[idir];
00613 }
00614
00615
00616 addMoments(m_moments,refinedCutCell.m_moments,refinedCenterDelta);
00617 addMoments(m_EBmoments,refinedCutCell.m_EBmoments,refinedCenterDelta);
00618
00619
00620 for (int idir = 0; idir < dim; idir++)
00621 {
00622 bdId[0] = idir;
00623
00624
00625
00626
00627 IndexTM<Real,dim-1> localRefinedCenterDelta;
00628 IndexTM<int,dim-1> localHilo;
00629
00630 for (int jdir = 0; jdir < dim; jdir++)
00631 {
00632 if (jdir < idir)
00633 {
00634 localRefinedCenterDelta[jdir] = refinedCenterDelta[jdir];
00635 localHilo[jdir] = hilo[jdir];
00636 }
00637 else if (jdir > idir)
00638 {
00639 localRefinedCenterDelta[jdir-1] = refinedCenterDelta[jdir];
00640 localHilo[jdir-1] = hilo[jdir];
00641 }
00642 }
00643
00644 if (hilo[idir] != LARGEINTVAL)
00645 {
00646 bdId[1] = hilo[idir];
00647
00648
00649
00650
00651 (refinedCutCell.m_bdCutCellMoments[bdId]).addBdMoments(
00652 m_bdCutCellMoments[bdId],
00653 refinedCutCell.m_iFData,
00654 a_degreeP,
00655 a_useConstraints,
00656 localRefinedCenterDelta,
00657 localHilo);
00658 }
00659 else
00660 {
00661 for (int side = 0; side < 2; side++)
00662 {
00663 bdId[1] = side;
00664 (refinedCutCell.m_bdCutCellMoments[bdId]).addBdMoments(
00665 m_bdCutCellMoments[bdId],
00666 refinedCutCell.m_iFData,
00667 a_degreeP+1,
00668 a_useConstraints,
00669 localRefinedCenterDelta,
00670 localHilo);
00671 }
00672 }
00673 }
00674 }
00675 }
00676
00677 template <int dim> inline void CutCellMoments<dim>::addMoments(PthMoment & a_momentMap,
00678 PthMoment & a_refinedMomentMap,
00679 const IndexTM<Real,dim> & a_refinedCenterDelta)
00680 {
00681
00682
00683 for (typename PthMoment::const_iterator it = a_refinedMomentMap.begin(); it != a_refinedMomentMap.end(); ++it)
00684 {
00685 IndexTM<int,dim> monomial = it->first;
00686 Real moment = changeMomentCoordinates(a_refinedMomentMap,monomial,a_refinedCenterDelta);
00687
00688 a_momentMap[it->first] += moment;
00689 }
00690 }
00691
00692
00693
00694
00695
00696 template <int dim> inline void CutCellMoments<dim>::addBdMoments(CutCellMoments<dim> & a_coarseBdCutCell,
00697 const IFData<dim+1> & a_iFData,
00698 const int & a_degreeP,
00699 const bool & a_useConstraints,
00700 const IndexTM<Real,dim> & a_refinedCenterDelta,
00701 const IndexTM<int,dim> & a_hilo)
00702 {
00703 typedef map<IvDim,int,LexLT <IvDim> > PthMomentLoc;
00704
00705 if (a_iFData.m_allVerticesIn)
00706 {
00707
00708
00709
00710 PthMoment fullCellMap;
00711
00712 for (int iDegree = a_degreeP; iDegree >= 0; iDegree--)
00713 {
00714
00715
00716 LSProblem<dim> lsp(iDegree,a_useConstraints);
00717 const PthMomentLoc& momMap = lsp.getMonomialLocMapDegreePLess1();
00718
00719 for (typename PthMomentLoc::const_iterator it = momMap.begin(); it != momMap.end(); ++it)
00720 {
00721 fullCellMap[it->first] = fullCellQuadrature(it->first);
00722 }
00723 }
00724
00725 for (int iDegree = a_degreeP; iDegree >= 0; iDegree--)
00726 {
00727 LSProblem<dim> lsp(iDegree,a_useConstraints);
00728
00729
00730
00731
00732 const PthMomentLoc& momMap = lsp.getMonomialLocMapDegreePLess1();
00733
00734 for (typename PthMomentLoc::const_iterator it = momMap.begin(); it != momMap.end(); ++it)
00735 {
00736 Real bdMoment = getBdMoment(it->first,a_iFData,a_refinedCenterDelta,fullCellMap);
00737 a_coarseBdCutCell.m_moments[it->first] += bdMoment;
00738 }
00739 }
00740 }
00741 else
00742 {
00743 for (int iDegree = a_degreeP; iDegree >= 0; iDegree--)
00744 {
00745 LSProblem<dim> lsp(iDegree,a_useConstraints);
00746
00747
00748
00749
00750 const PthMomentLoc& momMap = lsp.getMonomialLocMapDegreePLess1();
00751
00752 for (typename PthMomentLoc::const_iterator it = momMap.begin(); it != momMap.end(); ++it)
00753 {
00754 Real bdMoment = getBdMoment(it->first,a_iFData,a_refinedCenterDelta);
00755 a_coarseBdCutCell.m_moments[it->first] += bdMoment;
00756 }
00757 }
00758 }
00759
00760 for (int iDegree = a_degreeP; iDegree >= 0; iDegree--)
00761 {
00762 LSProblem<dim> lsp(iDegree,a_useConstraints);
00763
00764
00765
00766 const PthMomentLoc& momMapP = lsp.getMonomialLocMapDegreeP();
00767
00768 for (typename PthMomentLoc::const_iterator it = momMapP.begin(); it != momMapP.end(); ++it)
00769 {
00770 Real bdEBMoment = getBdEBMoment(it->first,a_iFData,a_refinedCenterDelta);
00771 a_coarseBdCutCell.m_EBmoments[it->first] += bdEBMoment;
00772 }
00773 }
00774
00775 IndexTM<int,2> bdId;
00776
00777 for (int idir = 0; idir < dim; idir++)
00778 {
00779 bdId[0] = idir;
00780
00781
00782
00783
00784 IndexTM<Real,dim-1> localRefinedCellCenter;
00785 IndexTM<int,dim-1> localHilo;
00786
00787 for (int jdir = 0; jdir < dim; jdir++)
00788 {
00789 if (jdir < idir)
00790 {
00791 localRefinedCellCenter[jdir] = a_refinedCenterDelta[jdir];
00792 localHilo[jdir] = a_hilo[jdir];
00793 }
00794 else if (jdir > idir)
00795 {
00796 localRefinedCellCenter[jdir-1] = a_refinedCenterDelta[jdir];
00797 localHilo[jdir-1] = a_hilo[jdir];
00798 }
00799 }
00800
00801 if (a_hilo[idir] != LARGEINTVAL)
00802 {
00803 bdId[1] = a_hilo[idir];
00804
00805
00806
00807 (m_bdCutCellMoments[bdId]).addBdMoments(a_coarseBdCutCell.m_bdCutCellMoments[bdId],m_iFData,a_degreeP+1,a_useConstraints,localRefinedCellCenter,localHilo);
00808 }
00809 else
00810 {
00811 for (int side = 0; side < 2; side++)
00812 {
00813 bdId[1]=side;
00814 (m_bdCutCellMoments[bdId]).addBdMoments(a_coarseBdCutCell.m_bdCutCellMoments[bdId],m_iFData,a_degreeP,a_useConstraints,localRefinedCellCenter,localHilo);
00815 }
00816 }
00817 }
00818 }
00819
00820 void CutCellMoments<1>::addBdMoments(CutCellMoments<1> & a_coarseBdCutCell,
00821 const IFData<2> & a_iFData,
00822 const int & a_degreeP,
00823 const bool & a_useConstraints,
00824 const IndexTM<Real,1> & a_refinedCenterDelta,
00825 const IndexTM<int,1> & a_localHilo)
00826 {
00827 OneDMoments fullCellMap;
00828
00829 if (a_iFData.m_allVerticesIn)
00830 {
00831 IndexTM<int,1> degree;
00832
00833 for (int iDegree = 0; iDegree <= a_degreeP; ++iDegree)
00834 {
00835 degree[0] = iDegree;
00836 Real loPt = -0.5*m_iFData.m_dx;
00837 Real hiPt = 0.5*m_iFData.m_dx;
00838 fullCellMap[degree] = pow(hiPt,degree[0] + 1) - pow(loPt,degree[0] +1);
00839 fullCellMap[degree] /= degree[0]+1;
00840 }
00841 }
00842
00843 for (int iDegree = 0; iDegree <= a_degreeP; ++iDegree)
00844 {
00845 IndexTM<int,1>degree;
00846 degree[0] = iDegree;
00847 Real bdMoment;
00848 if (a_iFData.m_allVerticesIn)
00849 {
00850 bdMoment = getBdMoment(degree,a_iFData,a_refinedCenterDelta,fullCellMap);
00851 }
00852 else
00853 {
00854 bdMoment = getBdMoment(degree,a_iFData,a_refinedCenterDelta);
00855 }
00856
00857 a_coarseBdCutCell.m_moments[degree] += bdMoment;
00858 }
00859 }
00860
00861 template <int dim> inline Real CutCellMoments<dim>::changeMomentCoordinates(PthMoment & a_refinedMomentMap,
00862 const IndexTM<int,dim> & a_monomial,
00863 const IndexTM<Real,dim> & a_refinedCenterDelta)
00864 {
00865
00866
00867
00868
00869
00870 Real moment = 0.0;
00871
00872
00873 int degree = 0;
00874
00875 for (int i = 0; i < dim; i++)
00876 {
00877 degree += a_monomial[i];
00878 }
00879
00880
00881
00882
00883 for (int r = 0; r <= degree; r++)
00884 {
00885 if (r >= 0)
00886 {
00887
00888 IndexTM<int,dim> derivative;
00889
00890 for (int idir = 0; idir < dim; ++idir)
00891 {
00892 derivative[idir] = 0;
00893 }
00894
00895 while (true)
00896 {
00897 for (int j = 1; j < dim-1; ++j)
00898 {
00899 int t = r;
00900 for (int k = j+1; k < dim; ++k)
00901 {
00902 t -= derivative[k];
00903 }
00904
00905 if (derivative[j] > t)
00906 {
00907 derivative[j+1] += 1;
00908 derivative[j ] = 0;
00909 }
00910 else
00911 {
00912 break;
00913 }
00914 }
00915
00916 if (derivative[dim-1] > r)
00917 {
00918 break;
00919 }
00920
00921 derivative[0] = r;
00922
00923 for (int j = 1; j < dim; ++j)
00924 {
00925 derivative[0] -= derivative[j];
00926 }
00927
00928
00929 Real coeff = 1.0;
00930 Real factorial = 1.0;
00931
00932 for (int idir = 0; idir < dim; idir++)
00933 {
00934 for (int j = 0; j < derivative[idir]; j++)
00935 {
00936 coeff *= a_monomial[idir] - j;
00937 factorial *= j+1;
00938 }
00939
00940
00941
00942 if (a_monomial[idir]-derivative[idir] < 0)
00943 {
00944 if (coeff != 0)
00945 {
00946 MayDay::Abort("Coeff should be zero when the derivative has higher coefficient than the monomial");
00947 }
00948 }
00949 else
00950 {
00951 coeff *= pow(a_refinedCenterDelta[idir],a_monomial[idir]-derivative[idir]);
00952 }
00953 }
00954
00955 moment += coeff * a_refinedMomentMap[derivative] / factorial;
00956
00957
00958 derivative[1] += 1;
00959 }
00960 }
00961 }
00962
00963 return moment;
00964 }
00965
00966 inline Real CutCellMoments<1>::changeMomentCoordinates(OneDMoments & a_refinedMomentMap,
00967 const IndexTM<int,1> & a_monomial,
00968 const IndexTM<Real,1> & a_refinedCenterDelta)
00969 {
00970 Real moment = 0.0;
00971 int degree = 0;
00972 degree += a_monomial[0];
00973
00974
00975 for (int r = 0; r <= degree; r++)
00976 {
00977
00978 IndexTM<int,1> derivative;
00979 derivative[0] = r;
00980
00981
00982 Real coeff = 1.0;
00983 Real factorial = 1.0;
00984
00985 for (int j = 0; j < derivative[0]; j++)
00986 {
00987 coeff *= a_monomial[0] - j;
00988 factorial *= j+1;
00989 }
00990
00991 coeff *= pow(a_refinedCenterDelta[0],a_monomial[0]-derivative[0]);
00992
00993 moment += coeff * a_refinedMomentMap[derivative] / factorial;
00994 }
00995
00996 return moment;
00997 }
00998
00999 template <int dim> inline void CutCellMoments<dim>::initialize(CutCellMoments<dim> & a_refinedCutCell)
01000 {
01001
01002
01003 initializeMap(m_EBmoments,a_refinedCutCell.m_EBmoments);
01004 initializeMap(m_moments,a_refinedCutCell.m_moments);
01005
01006
01007 IndexTM<int,2> bdId;
01008
01009 for (int idir = 0; idir < dim; idir++)
01010 {
01011 bdId[0] = idir;
01012
01013 for (int hilo = 0; hilo < 2; hilo++)
01014 {
01015 bdId[1] = hilo;
01016 CutCellMoments<dim-1> refinedBdCutCell = a_refinedCutCell.getBdCutCellMoments(bdId);
01017
01018 m_bdCutCellMoments[bdId].initialize(refinedBdCutCell);
01019 }
01020 }
01021 }
01022
01023 inline void CutCellMoments<1>::initialize(CutCellMoments<1> & a_refinedCutCell)
01024 {
01025 initializeMap(m_EBmoments,a_refinedCutCell.m_EBmoments);
01026 initializeMap(m_moments,a_refinedCutCell.m_moments);
01027 }
01028
01029 template <int dim> inline void CutCellMoments<dim>::initializeMap(PthMomentLesserDimension & a_map1,
01030 PthMomentLesserDimension & a_map2)
01031 {
01032 for (typename PthMomentLesserDimension::const_iterator it = a_map2.begin(); it != a_map2.end(); ++it)
01033 {
01034 a_map1[it->first] = 0.0;
01035 }
01036 }
01037
01038 inline void CutCellMoments<1>::initializeMap(OneDMoments & a_map1,
01039 OneDMoments & a_map2)
01040 {
01041 for (OneDMoments::const_iterator it = a_map2.begin(); it != a_map2.end(); ++it)
01042 {
01043 a_map1[it->first] = 0.0;
01044 }
01045 }
01046
01047 template <int dim> inline void CutCellMoments<dim>::initializeMap(PthMoment & a_map1,
01048 PthMoment & a_map2)
01049 {
01050 for (typename PthMoment::const_iterator it = a_map2.begin(); it != a_map2.end(); ++it)
01051 {
01052 a_map1[it->first] = 0.0;
01053 }
01054 }
01055
01056 template <int dim> inline void CutCellMoments<dim>::initializeMap(OneDMoments & a_map1,
01057 OneDMoments & a_map2)
01058 {
01059 for (typename OneDMoments::const_iterator it = a_map2.begin(); it != a_map2.end(); ++it)
01060 {
01061 a_map1[it->first] = 0.0;
01062 }
01063 }
01064
01065 template <int dim> inline Real CutCellMoments<dim>::getBdMoment(const IvDim & a_mono,
01066 const IFData<dim+1> & a_iFData,
01067 const IndexTM<Real,dim> & a_refinedCenterDelta,
01068 PthMoment a_fullCellMap)
01069 {
01070
01071
01072
01073 Real moment = LARGEREALVAL;
01074
01075 if (a_iFData.m_allVerticesOut)
01076 {
01077 moment = 0.0;
01078 }
01079 else if (a_iFData.m_allVerticesIn)
01080 {
01081 moment = changeMomentCoordinates(a_fullCellMap,a_mono,a_refinedCenterDelta);
01082 }
01083 else
01084 {
01085 moment = changeMomentCoordinates(m_moments,a_mono,a_refinedCenterDelta);
01086 }
01087
01088 return moment;
01089 }
01090
01091 inline Real CutCellMoments<1>::getBdMoment(const IndexTM<int,1> & a_mono,
01092 const IFData<2> & a_iFData,
01093 const IndexTM<Real,1> & a_refinedCenterDelta,
01094 OneDMoments a_fullCellMap)
01095 {
01096 Real moment = LARGEREALVAL;
01097
01098 if (a_iFData.m_allVerticesOut)
01099 {
01100 moment = 0.0;
01101 }
01102 else if (a_iFData.m_allVerticesIn)
01103 {
01104 Real loPt = -0.5*m_iFData.m_dx;
01105 Real hiPt = 0.5*m_iFData.m_dx;
01106
01107 moment = pow(hiPt,a_mono[0] + 1) - pow(loPt,a_mono[0] +1);
01108 moment = changeMomentCoordinates(a_fullCellMap,a_mono,a_refinedCenterDelta);
01109 }
01110 else
01111 {
01112 moment = changeMomentCoordinates(m_moments,a_mono,a_refinedCenterDelta);
01113 }
01114
01115 return moment;
01116 }
01117
01118 template <int dim> inline Real CutCellMoments<dim>::getBdEBMoment(const IvDim & a_mono,
01119 const IFData<dim+1> & a_iFData,
01120 const IndexTM<Real,dim> & a_refinedCenterDelta)
01121 {
01122
01123
01124 Real EBmoment = LARGEREALVAL;
01125
01126 if (a_iFData.m_allVerticesOut || a_iFData.m_allVerticesIn)
01127 {
01128 EBmoment = 0.0;
01129 }
01130 else
01131 {
01132 EBmoment = changeMomentCoordinates(m_EBmoments,a_mono,a_refinedCenterDelta);
01133 }
01134
01135 return EBmoment;
01136 }
01137
01138 inline Real CutCellMoments<1>::getBdEBMoment(const IndexTM<int,1> & a_mono,
01139 const IFData<2> & a_iFData,
01140 const IndexTM<Real,1> & a_refinedCenterDelta)
01141 {
01142 Real EBmoment = 0.0;
01143
01144 return EBmoment;
01145 }
01146
01147 template <int dim> inline void CutCellMoments<dim>::computeResiduals(const int & a_order,
01148 const int & a_degreeP,
01149 const bool & a_useConstraints)
01150 {
01151 for (int iDegree = a_degreeP; iDegree >= 0; iDegree--)
01152 {
01153
01154 int nNorm = 3;
01155 m_residual[iDegree].resize(nNorm);
01156
01157 for (int i = 0; i < nNorm; i++)
01158 {
01159 m_residual[iDegree][i] = 0.0;
01160 }
01161
01162
01163 LSProblem<dim> lsp(a_order,iDegree,a_useConstraints,m_iFData.m_normal);
01164
01165
01166 Vector<Real> rhs = computeRhs(lsp,a_order);
01167
01168
01169 Vector<Real> unknowns(lsp.m_numP+lsp.m_numPLess1);
01170
01171 for (typename PthMomentLoc::const_iterator it = lsp.m_monoLocP.begin(); it != lsp.m_monoLocP.end(); ++it)
01172 {
01173 unknowns[it->second] = m_EBmoments[it->first];
01174 }
01175
01176 for (typename PthMomentLoc::const_iterator it = lsp.m_monoLocPLess1.begin(); it != lsp.m_monoLocPLess1.end(); ++it)
01177 {
01178 unknowns[it->second + lsp.m_numP] = m_moments[it->first];
01179 }
01180
01181
01182 Real maxRi = 0.0;
01183
01184 for (int i = 0; i < lsp.m_numP*dim; i++)
01185 {
01186 Real AtimeX = 0.0;
01187
01188 for (int j = 0; j < lsp.m_numP + lsp.m_numPLess1; j++)
01189 {
01190 AtimeX += lsp.m_matrix[i][j] * unknowns[j];
01191 }
01192
01193 Real ri = AtimeX - rhs[i];
01194
01195 if (Abs(ri) > maxRi)
01196 {
01197 m_residual[iDegree][0] = Abs(ri);
01198 maxRi = Abs(ri);
01199 }
01200
01201 m_residual[iDegree][1] += Abs(ri);
01202 m_residual[iDegree][2] += ri * ri;
01203 }
01204
01205 m_residual[iDegree][2] = sqrt(m_residual[iDegree][2]);
01206 }
01207 }
01208
01209 template <int dim> inline void CutCellMoments<dim>::computeResiduals(const Vector< CutCellMoments<dim> > & a_refinedCCMoms,
01210 const int & a_degreeP)
01211 {
01212 for (int iDegree = 0; iDegree <= a_degreeP; iDegree++)
01213 {
01214 Real maxRes = 0.0;
01215 Real tempRes2 = 0.0;
01216 Real tempRes1 = 0.0;
01217
01218 for (int i = 0; i < a_refinedCCMoms.size(); i++)
01219 {
01220 Real res0 = a_refinedCCMoms[i].m_residual[iDegree][0];
01221 Real res1 = a_refinedCCMoms[i].m_residual[iDegree][1];
01222 Real res2 = a_refinedCCMoms[i].m_residual[iDegree][2];
01223
01224 if (res0 > maxRes && res0 != LARGEREALVAL)
01225 {
01226 maxRes = res0;
01227 m_residual[iDegree][0] = res0;
01228 }
01229
01230 if (res1 != LARGEREALVAL)
01231 {
01232 tempRes1 += res1;
01233 }
01234
01235 if (res2 != LARGEREALVAL)
01236 {
01237 tempRes2 += res2*res2;
01238 }
01239 }
01240
01241 m_residual[iDegree][1] = tempRes1;
01242
01243 if (tempRes2 != LARGEREALVAL)
01244 {
01245 m_residual[iDegree][2] = sqrt(tempRes2);
01246 }
01247 }
01248 }
01249
01250
01251 template <int dim> inline Real CutCellMoments<dim>::getMoment(const IvDim & a_mono,
01252 const EBorVol & a_EBorVol) const
01253 {
01254 Real moment = LARGEREALVAL;
01255
01256 if (a_EBorVol == VolMoment)
01257 {
01258
01259 typename PthMoment::const_iterator it = m_moments.find(a_mono);
01260
01261 if (it != m_moments.end())
01262 {
01263 moment = it->second;
01264 }
01265 else
01266 {
01267 MayDay::Abort("No volume moment in m_moments");
01268 }
01269 }
01270 else if (a_EBorVol == EBMoment)
01271 {
01272
01273 typename PthMoment::const_iterator it = m_EBmoments.find(a_mono);
01274
01275 if (it != m_EBmoments.end())
01276 {
01277 moment = it->second;
01278 }
01279 else
01280 {
01281 MayDay::Abort("No volume moment in m_bdMoments");
01282 }
01283 }
01284 else
01285 {
01286 MayDay::Abort("Must ask for EBMoment or VolMoment");
01287 }
01288
01289 return moment;
01290 }
01291
01292 inline Real CutCellMoments<1>::getMoment(const IndexTM<int,1> & a_mono,
01293 const EBorVol & a_EBorVOL) const
01294 {
01295 return getMoment(a_mono);
01296 }
01297
01298
01299 inline Real CutCellMoments<1>::getMoment(const IndexTM<int,1> & a_mono) const
01300 {
01301 Real moment = LARGEREALVAL;
01302
01303
01304 OneDMoments::const_iterator it = m_moments.find(a_mono);
01305
01306 if (it != m_moments.end())
01307 {
01308 moment = it->second;
01309 }
01310 else
01311 {
01312 MayDay::Abort("No volume moment in top face moment map");
01313 }
01314
01315 return moment;
01316 }
01317
01318 template <int dim> inline Real CutCellMoments<dim>::getVol(const EBorVol& a_EBorVol) const
01319 {
01320 Real volume;
01321
01322
01323 IvDim zero;
01324
01325 for (int idir = 0; idir < dim; ++idir)
01326 {
01327 zero[idir] = 0;
01328 }
01329
01330 volume = getMoment(zero,a_EBorVol);
01331
01332 return volume;
01333 }
01334
01335
01336 inline Real CutCellMoments<1>::getVol(const EBorVol & a_EBorVol) const
01337 {
01338 IndexTM<int,1> zero;
01339 zero[0] = 0;
01340 Real volume = getMoment(zero);
01341
01342 return volume;
01343 }
01344
01345 template <int dim> inline IndexTM<Real,dim> CutCellMoments<dim>::getCentroid(const EBorVol& a_EBorVol) const
01346 {
01347
01348 Real volume = getVol(a_EBorVol);
01349
01350 RvDim centroid;
01351
01352
01353 for (int idir = 0; idir < dim; ++idir)
01354 {
01355 IvDim mono = BASISV_TM<int,dim>(idir);
01356 centroid[idir] = getMoment(mono,a_EBorVol);
01357
01358 if (volume < 0.0)
01359 {
01360 MayDay::Warning("CutCellMoments::getCentroid: Volume fraction is negative");
01361 }
01362 else if (volume == 0.0)
01363 {
01364 MayDay::Error("CutCellMoments::getCentroid: Volume fraction is zero");
01365 }
01366
01367 centroid[idir] /= volume;
01368 }
01369
01370 return centroid;
01371 }
01372
01373 inline IndexTM<Real,1> CutCellMoments<1>::getCentroid(const EBorVol& a_EBorVol) const
01374 {
01375 IndexTM<Real,1> centroid;
01376 IndexTM<int,1> first;
01377 first[0] = 1;
01378
01379 Real volume = getVol(a_EBorVol);
01380
01381 if (volume <= 0)
01382 {
01383 MayDay::Abort("Volume equals 0");
01384 }
01385 else
01386 {
01387 centroid[0] = getMoment(first)/volume;
01388 }
01389
01390 return centroid;
01391 }
01392
01393 template <int dim> inline Real CutCellMoments<dim>::getResidual(const int & a_iDegree,
01394 const int & a_normJ) const
01395 {
01396 return m_residual[a_iDegree][a_normJ];
01397 }
01398
01399 template <int dim> inline bool CutCellMoments<dim>::isCovered() const
01400 {
01401 return m_iFData.m_allVerticesOut;
01402 }
01403
01404 inline bool CutCellMoments<1>::isCovered() const
01405 {
01406 return m_iFData.m_allVerticesOut;
01407 }
01408
01409 template <int dim> inline bool CutCellMoments<dim>::isRegular() const
01410 {
01411 return (m_iFData.m_allVerticesIn && (!m_bdCCOn));
01412 }
01413
01414 inline bool CutCellMoments<1>::isRegular() const
01415 {
01416 return m_iFData.m_allVerticesIn;
01417 }
01418
01419 template <int dim> inline void CutCellMoments<dim>::print(ostream& a_out) const
01420 {
01421
01422 a_out << "m_pthMoment:\n";
01423
01424 for (typename PthMoment::const_iterator it = m_moments.begin(); it != m_moments.end(); ++it)
01425 {
01426 a_out << " Integral " << it->first << " = " << it->second << '\n';
01427 }
01428
01429 for (typename PthMoment::const_iterator it = m_EBmoments.begin(); it != m_EBmoments.end(); ++it)
01430 {
01431 a_out << " EBIntegral " << it->first << " = " << it->second << '\n';
01432 }
01433
01434 a_out << "IFData:\n" << m_iFData << "**" << "\n";
01435
01436 a_out << "Dim = " << dim << '\n';
01437 a_out << "Number of bdCutCellMoments = " << m_bdCutCellMoments.size() << '\n';
01438
01439 for (typename BdCutCellMoments::const_iterator it = m_bdCutCellMoments.begin(); it != m_bdCutCellMoments.end(); ++it)
01440 {
01441 a_out << "BdId = " << it->first << ", m_iFData = " << '\n';
01442 a_out << it->second.m_iFData << '\n';
01443
01444 typedef map<IndexTM<int,dim-1>,Real,LexLT <IndexTM<int,dim-1> > > BdPthMoment;
01445
01446 for (typename BdPthMoment::const_iterator itbd = it->second.m_moments.begin(); itbd != it->second.m_moments.end(); ++itbd)
01447 {
01448 a_out << " Integral " << itbd->first << " = " << itbd->second << '\n';
01449 }
01450
01451 for (typename BdPthMoment::const_iterator itbd = it->second.m_EBmoments.begin(); itbd != it->second.m_EBmoments.end(); ++itbd)
01452 {
01453 a_out << " EBIntegral " << itbd->first << " = " << itbd->second << '\n';
01454 }
01455 }
01456 }
01457
01458 inline void CutCellMoments<1>::print(ostream & a_out) const
01459 {
01460 a_out << "IFData = " << m_iFData << "\n";
01461 for (OneDMoments::const_iterator it = m_moments.begin(); it != m_moments.end();++it)
01462 {
01463 a_out << "Moment: " << it->first << " = " << it->second << "\n";
01464 }
01465 }
01466
01467 template <int dim> inline void CutCellMoments<dim>::dump() const
01468 {
01469 print(pout());
01470 }
01471
01472 template <int dim> inline void CutCellMoments<dim>::printMoments()
01473 {
01474 pout() << "EB Moments" << "\n";
01475 for (typename PthMoment::const_iterator it = m_EBmoments.begin(); it != m_EBmoments.end(); ++it)
01476 {
01477 pout() << "EB Integral" << it->first << "=" << m_EBmoments[it->first] << "\n";
01478 }
01479
01480 pout() << "Moments" << "\n";
01481 for (typename PthMoment::const_iterator it = m_moments.begin(); it != m_moments.end(); ++it)
01482 {
01483 pout() << "Integral" << it->first << "=" << m_moments[it->first] << "\n";
01484 }
01485 }
01486
01487 template <int dim> inline void CutCellMoments<dim>::printBdMoments()
01488 {
01489 IndexTM<int,2> bdId;
01490
01491 for (int idir = 0; idir < dim; idir++)
01492 {
01493 bdId[0] = idir;
01494
01495 for (int hilo = 0; hilo <= 1; hilo++)
01496 {
01497 bdId[1] = hilo;
01498
01499 pout() << "bdId" << bdId << "\n";
01500
01501 pout() << "EB Moments" << "\n";
01502 CutCellMoments<dim-1> bdCutCell = getBdCutCellMoments(bdId);
01503 for (typename PthMomentLesserDimension::const_iterator it = bdCutCell.m_EBmoments.begin(); it != bdCutCell.m_EBmoments.end(); ++it)
01504 {
01505 pout() << "EB Integral" << it->first << "=" << bdCutCell.m_EBmoments[it->first] << "\n";
01506 }
01507
01508 pout() << "Moments" << "\n";
01509 for (typename PthMomentLesserDimension::const_iterator it = bdCutCell.m_moments.begin(); it != bdCutCell.m_moments.end(); ++it)
01510 {
01511 pout() << "Integral" << it->first << "=" << bdCutCell.m_moments[it->first] << "\n";
01512 }
01513 }
01514 }
01515 }
01516
01517
01518 template <int dim> inline void CutCellMoments<dim>::operator=(const CutCellMoments<dim> & a_cutCellMoments)
01519 {
01520 m_moments = a_cutCellMoments.m_moments;
01521 m_EBmoments = a_cutCellMoments.m_EBmoments;
01522 m_bdCutCellMoments = a_cutCellMoments.m_bdCutCellMoments;
01523 m_iFData = a_cutCellMoments.m_iFData;
01524 m_bdCCOn = a_cutCellMoments.m_bdCCOn;
01525 m_residual = a_cutCellMoments.m_residual;
01526 }
01527
01528 inline void CutCellMoments<1>::operator=(const CutCellMoments<1> & a_cutCellMoments)
01529 {
01530 m_iFData = a_cutCellMoments.m_iFData;
01531 m_moments = a_cutCellMoments.m_moments;
01532 }
01533
01534 template <int dim> inline ostream& operator<<(ostream & a_out,
01535 const CutCellMoments<dim> & a_cutCellMoments)
01536 {
01537 a_cutCellMoments.print(a_out);
01538 return a_out;
01539 }
01540
01541 #include "NamespaceFooter.H"
01542
01543 #endif