Example #1
0
  void JacobiPolynomialAlpha :: Calc (int n, int alpha)
  {
    if (coefs.Size() < (n+1)*(alpha+1))
      {
        coefs.SetSize ( /* 3* */ (n+1)*(alpha+1));

        for (int a = 0; a <= alpha; a++)
          {
            for (int i = 1; i <= n; i++)
              {
                coefs[a*(n+1)+i][0] = CalcA (i, a, 0);
                coefs[a*(n+1)+i][1] = CalcB (i, a, 0);
                coefs[a*(n+1)+i][2] = CalcC (i, a, 0);
              }
            // ALWAYS_INLINE S P1(S x) const { return 0.5 * (2*(al+1)+(al+be+2)*(x-1)); }
            double al = a, be = 0;
            coefs[a*(n+1)+1][0] = 0.5 * (al+be+2);
            coefs[a*(n+1)+1][1] = 0.5 * (2*(al+1)-(al+be+2));
            coefs[a*(n+1)+1][2] = 0.0;
          }

        maxnp = n+1;
        maxalpha = alpha;
      }
  }
Example #2
0
//
// Assembling algorithm for equation solving
//
void OdeProb::Assemble()
{
size_t i, j, psiI, psiJ;
int ni; // row position in matrix S
int nj; // column position in matrix S
// const size_t M = Dim();
const size_t N = EltNo(); // Number of elements

// const double bndr[3] = {0, m_left.m_val, m_right.m_val};

	// Element loop
	for(size_t n = 0; n < N; n++)
	{
		const Element& e = Elt(n);
		const size_t DofNo = e.DofNo();

		// Loop over basis functions
		for(i = 0; i < DofNo; i++)
		{
			ni = e.m_dof[i];
			if(ni < 0)
				continue;

			psiI = e.PsiId(i);

			// Loop over basis functions
			for(j = i; j < DofNo; j++)
			{
				psiJ = e.PsiId(j);

				nj = e.m_dof[j];
				if(nj > -1)
					m_s->Set(ni, nj) += CalcS(e, psiI, psiJ);
				//else // Dirichlet boundary conditions are ZERO, hence it can be skiped
				//	m_b->Set(ni) -= bndr[-nj] * CalcS(e, psiI, psiJ);
			}

			// Contribution of the vertex basis function $v_{m_1}$ to the right hand side $b$
			m_b->Set(ni) += CalcB(e, psiI);
		}
	}
}