11 #ifndef _INDEXEDMOMENTSIMPLEM_H_    12 #define _INDEXEDMOMENTSIMPLEM_H_    22 #include "NamespaceHeader.H"    38 template<
int Dim, 
int ORDER>
    43              const Real                 & a_tolerance,
    44              const bool                 & a_ebMoment,
    45              const bool                 & a_bindMoments)
    49   if(a_ebMoment && a_bindMoments)
    56   a_bogusPowers.resize(0);
    58   for(
int idir = 0; idir < Dim; idir++)
    66   a_moments.
shift(shiftvec);
    70   const Real zerval = 0;
    71   for(momit.
reset(); momit.
ok(); ++momit)
    75       Real maxval = POW<Dim>(a_dx, p);
    79       Real& momval = a_moments[p];
    82           if((zerval - momval) > a_tolerance*maxval)
    84               a_bogusPowers.push_back(p);
    92       else if((momval > maxval) && (!a_ebMoment))
    94           if((momval - maxval) > a_tolerance*maxval)
    96               a_bogusPowers.push_back(p);
   108   a_moments.
shift(shiftvec);
   112   for(momit.
reset(); momit.
ok(); ++momit)
   116       bool pEven = (psum % 2 == 0);
   117       Real& momval = a_moments[p];
   119       Real maxval = POW<Dim>(a_dx, p);
   122       if(pEven && (momval < zerval) && (!a_ebMoment))
   125           if(momval < -a_tolerance*maxval )
   127               a_bogusPowers.push_back(p);
   135       else if(!pEven && (momval > zerval) && (!a_ebMoment))
   138           if(momval > a_tolerance*maxval)
   140               a_bogusPowers.push_back(p);
   151   shiftvec.
setAll(0.5*a_dx);
   152   a_moments.
shift(shiftvec);
   155 template <
int Dim, 
int P>
   158     {1, 2,  3,  4,  5,  6,  7,   8,   9}, 
   159     {1, 3,  6, 10, 15, 21, 28,  36,  45}, 
   160     {1, 4, 10, 20, 35, 56, 84, 120, 165}  
   164 template <const 
int Dim, const 
int P>
   171   typename std::map<IndexTM<int, Dim>,  
Real>::const_iterator iterinator;
   172   iterinator = a_mapin.find(a_mono);
   174   Real moment = 1.23456789e10;
   176   if (iterinator != a_mapin.end())
   178       moment = iterinator->second;
   183       pout() << 
"monomial = " ;
   184       for(
int idir = 0; idir < Dim; idir++)
   186           pout() << a_mono[idir] << 
" ";
   189       MayDay::Abort(
"getMoments in IndexedMoments: moment not found in map");
   195 template <
int Dim, 
int P>
   202       (*this)[it()] *= a_factor;
   207 template <
int Dim, 
int P>
   214       (*this)[it()] += a_input[it()];
   219 template <
int Dim, 
int P>
   224   CH_TIME(
"IndexedMoment::shift");
   240               Real m0 = (*this)[q];
   242               for(
int idir = 0; idir < Dim; idir++)
   244                   xpow *=  
POW(x[idir], p[idir]);
   247               moment += pCk<Dim>(r, q) * xpow * m0;
   258 template <
int Dim, 
int P>
   267       Real moment= getMoment(iter(), a_mapin);
   268       (*this)[iter()] = moment;
   273 template <
int Dim, 
int P>
   278   pout() << 
"index \t  moment  " << endl;
   281       pout() <<  iter() << 
"\t" << (*this)[iter()] << endl;
   289   for(
int idir = 0; idir < Dim; idir++)
   291       if(a_index[idir] < 0)
   300 template <
int Dim, 
int P>
   309   int index = a_index[0];
   311   for (
int d=Dim-1; d > 0; --d)
   313       index += s_max_sizes[d][rem] - s_max_sizes[d][rem-a_index[d]];
   320 template <
int Dim, 
int P>
   331 template <
int Dim, 
int P>
   340   m_moms.resize(s_size);
   345 template <
int Dim, 
int P>
   357   for (
int ix=0; ix < mix.
size(); ++ix)
   362       for (
int d=0; (even) && (d < Dim); ++d)
   363         even = even && !(index[d] % 2);
   369           moment = 
POW(0.5 * a_dx, index.
sum()) * 
POW(a_dx, Dim);
   370           for (
int d=0; d < Dim; ++d)
   371             moment /= (
Real) (index[d]+1);
   380 template <
int Dim, 
int P>
   391   s_size = s_max_sizes[Dim-1][P];
   394 template <
int Dim, 
int P>
   399   s_multiIndicies.resize(s_size);
   402   for (
int ix=0; ix < s_size; ++ix)
   405       for (
int d=0; (index.
sum() > P) && (d < Dim-1); ++d)
   410       s_multiIndicies[ix] = index;
   415 template <
int Dim, 
int P>
   435               Real incr = a_CA[pi]*a_CB[po];
   436               (*this)[psum] += incr;
   443 template <
int Dim, 
int P>
   456 template <
int Dim, 
int P>
   469 #include "NamespaceFooter.H" std::ostream & pout()
Use this in place of std::cout for program output. 
 
bool componentwiseLE(const IndexTM &a_s)
Definition: IndexTM.H:257
 
static int indexOf(IndexTM< int, Dim > a_index)
Calculate what linear index this multi-index is. 
Definition: IndexedMomentsImplem.H:303
 
Definition: IndexedMoments.H:31
 
void setRegular(const Real a_dx)
set to a regular IndexTM 
Definition: IndexedMomentsImplem.H:348
 
#define CH_assert(cond)
Definition: CHArray.H:37
 
void setAll(T a_val)
Definition: IndexTMI.H:194
 
void shift(const IndexTM< Real, Dim > &a_distance)
shift moment by the input distance. 
Definition: IndexedMomentsImplem.H:222
 
bool allPositive(const IndexTM< int, Dim > &a_index)
Definition: IndexedMomentsImplem.H:286
 
IndexedMoments()
constructor—make statics first time called 
Definition: IndexedMomentsImplem.H:333
 
one dimensional dynamic array 
Definition: Vector.H:53
 
static const Vector< IndexTM< int, Dim > > & getMonomialPowers()
monomial powers 
Definition: IndexedMoments.H:134
 
Real pfactorial(const IndexTM< int, Dim > p)
Calculates factorials for a multinomial. 
Definition: Factorial.H:61
 
virtual void reset()
Definition: MomentIterator.H:74
 
Real POW(const Real &a_x, const int &a_p)
computes x^p 
Definition: Factorial.H:33
 
const int SpaceDim
Definition: SPACE.H:38
 
IndexedMoments< Dim, P > & operator*=(const Real &a_factor)
multiply each component by constant 
Definition: IndexedMomentsImplem.H:198
 
IndexedMoments< Dim, P > & operator=(const map< IndexTM< int, Dim >, Real > &a_mapin)
for use with irregnode 
Definition: IndexedMomentsImplem.H:261
 
static void setStatics()
Definition: IndexedMomentsImplem.H:323
 
T sum() const
Definition: IndexTMI.H:260
 
#define CH_TIME(name)
Definition: CH_Timer.H:82
 
void multiplyByFactorial()
multiply each entry by p! 
Definition: IndexedMomentsImplem.H:459
 
double Real
Definition: REAL.H:33
 
iterates through the indices of a IndexedMoment 
Definition: MomentIterator.H:56
 
void setToTruncatedMultiply(const IndexedMoments< Dim, P > &a_CA, const IndexedMoments< Dim, P > &a_CB)
Definition: IndexedMomentsImplem.H:418
 
size_t size() const
Definition: Vector.H:192
 
void spout() const
outputs the current state to pout() (a la parstream.H) 
Definition: IndexedMomentsImplem.H:276
 
static void setSize()
Definition: IndexedMomentsImplem.H:383
 
void checkMoments(IndexedMoments< Dim, ORDER > &a_moments, Vector< IndexTM< int, Dim > > &a_bogusPowers, const Real &a_dx, const Real &a_tolerance, const bool &a_ebMoment, const bool &a_bindMoments)
Definition: IndexedMomentsImplem.H:40
 
virtual bool ok()
Definition: MomentIterator.H:98
 
IndexedMoments< Dim, P > & operator+=(const IndexedMoments< Dim, P > &increment)
add compoenentwise 
Definition: IndexedMomentsImplem.H:210
 
Real factorial(const int n)
Calculates factorial for an integer. 
Definition: Factorial.H:25
 
static void setMultiIndicies()
Definition: IndexedMomentsImplem.H:397
 
void divideByFactorial()
divides each entry by p! 
Definition: IndexedMomentsImplem.H:446
 
#define CH_IM_MAX_POWER
Definition: IndexedMoments.H:23
 
Real getMoment(const IndexTM< int, Dim > &a_mono, const map< IndexTM< int, Dim >, Real > &a_mapin) const
Definition: IndexedMomentsImplem.H:167
 
static void Abort(const char *const a_msg=m_nullString)
Print out message to cerr and exit via abort() (if serial) or MPI_Abort() (if parallel).