Ejemplo n.º 1
0
//---------------------------------------------------------
void GradSimplex3DP
(
  const DVec& a,      // [in]
  const DVec& b,      // [in]
  const DVec& c,      // [in]
        int   id,     // [in]
        int   jd,     // [in]
        int   kd,     // [in]
        DVec& V3Dr,   // [out]
        DVec& V3Ds,   // [out]
        DVec& V3Dt    // [out]
)
//---------------------------------------------------------
{
  // function [V3Dr, V3Ds, V3Dt] = GradSimplex3DP(a,b,c,id,jd,kd)
  // Purpose: Return the derivatives of the modal basis (id,jd,kd) 
  //          on the 3D simplex at (a,b,c)

  DVec fa, dfa, gb, dgb, hc, dhc, tmp;


  fa = JacobiP(a,0,0,id);           dfa = GradJacobiP(a,0,0,id);
  gb = JacobiP(b,2*id+1,0,jd);      dgb = GradJacobiP(b,2*id+1,0,jd);
  hc = JacobiP(c,2*(id+jd)+2,0,kd); dhc = GradJacobiP(c,2*(id+jd)+2,0,kd);

  // r-derivative
  V3Dr = dfa.dm(gb.dm(hc));
  if (id>0)    { V3Dr *= pow(0.5*(1.0-b), double(id-1)); }
  if (id+jd>0) { V3Dr *= pow(0.5*(1.0-c), double(id+jd-1)); }

  // s-derivative 
  V3Ds = V3Dr.dm(0.5*(1.0+a));
  tmp = dgb.dm(pow(0.5*(1.0-b), double(id)));

  if (id>0)    { tmp -= (0.5*id) * gb.dm(pow(0.5*(1.0-b), (id-1.0))); }
  if (id+jd>0) { tmp *= pow(0.5*(1.0-c),(id+jd-1.0)); }
  tmp = fa.dm(tmp.dm(hc));
  V3Ds += tmp;

  // t-derivative 
  V3Dt = V3Dr.dm(0.5*(1.0+a)) + tmp.dm(0.5*(1.0+b));
  tmp = dhc.dm(pow(0.5*(1.0-c), double(id+jd)));
  if (id+jd>0) { tmp -= (0.5*(id+jd)) * hc.dm(pow(0.5*(1.0-c), (id+jd-1.0))); }
  tmp = fa.dm(gb.dm(tmp));
  tmp *= pow(0.5*(1.0-b), double(id));
  V3Dt += tmp;

  // normalize
  double fac = pow(2.0, (2.0*id + jd+1.5));
  V3Dr *= fac;  V3Ds *= fac;  V3Dt *= fac;
}
Ejemplo n.º 2
0
//---------------------------------------------------------
void Maxwell2D::SetIC()
//---------------------------------------------------------
{
  // Set initial conditions for simulation

  mmode = 1.0; nmode = 1.0;

  //Ez = sin(mmode*pi*x) .* sin(nmode*pi*y);
  DVec tsinx = apply(sin, (mmode*pi*x)),
       tsiny = apply(sin, (nmode*pi*y));
  
  Ezinit = tsinx.dm(tsiny);

  Ez = Ezinit;
  Hx = 0.0;
  Hy = 0.0;
}
Ejemplo n.º 3
0
//---------------------------------------------------------
void MaxwellCurved2D::SetIC()
//---------------------------------------------------------
{
#if (0)
  // NBN: to compare with base version
  // Maxwell2D::SetIC();
  // return;
#endif
  
  // Set initial conditions for simulation

  // First 6 modes of eigenmodes with 6 azimuthal periods
  m_alpha.resize(6);
  m_alpha(1) =  9.936109524217684;
  m_alpha(2) = 13.589290170541217;
  m_alpha(3) = 17.003819667816014;
  m_alpha(4) = 20.320789213566506;
  m_alpha(5) = 23.586084435581391;
  m_alpha(6) = 26.820151983411403;

  // this configuration has an analytic solution
  // Note: analytic sol. depends on m_Ezinit:
  m_bHasAnalyticSol = true;

  // choose radial mode
  alpha0 = m_alpha(2);
  m_theta  = atan2(y,x);
  m_rad    = sqrt(sqr(x) + sqr(y));

//Ez = besselj(6, alpha0*rad).*cos(6*theta);
  DVec tbsslj = besselj(6, alpha0 * m_rad);
  DVec tcosth = apply(cos, (6.0 * m_theta));
  Ezinit = tbsslj.dm(tcosth);

  Ez = Ezinit;
  Hx = 0.0;
  Hy = 0.0;
}
Ejemplo n.º 4
0
//---------------------------------------------------------
void CurvedINS2D::KovasznayBC2D
(
  const DVec&   xin,    // [in]
  const DVec&   yin,    // [in]
  const DVec&   nxi,    // [in]
  const DVec&   nyi,    // [in]
  const IVec&   MAPI,   // [in]
  const IVec&   MAPO,   // [in]
  const IVec&   MAPW,   // [in]
  const IVec&   MAPC,   // [in]
        double  ti,     // [in]
        double  nu,     // [in]
        DVec&   BCUX,   // [out]
        DVec&   BCUY,   // [out]
        DVec&   BCPR,   // [out]
        DVec&   BCDUNDT // [out]
)
//---------------------------------------------------------
{
  // function [bcUx, bcUy, bcPR, bcdUndt] = KovasznayBC2D(x, y, nx, ny, MAPI, MAPO, MAPW, MAPC, time, nu)
  // Purpose: evaluate boundary conditions for Kovasznay flow 

  static DVec xI("xI"), yI("yI"), xO("xO"), yO("yO");

  int len = xin.size();
  BCUX.resize(len); BCUY.resize(len);     // resize result arrays
  BCPR.resize(len); BCDUNDT.resize(len);  // and set to zero

  double lam = (0.5/nu) - sqrt( (0.25/SQ(nu)) + 4.0*SQ(pi));

  // inflow
#ifdef _MSC_VER
  xI = xin(MAPI);  yI = yin(MAPI);
#else
  int Ni=MAPI.size(), n=0; xI.resize(Ni); yI.resize(Ni);
  for (n=1;n<=Ni;++n) {xI(n)=xin(MAPI(n));}
  for (n=1;n<=Ni;++n) {yI(n)=yin(MAPI(n));}
#endif

  DVec elamXI = exp(lam*xI), twopiyI = 2.0*pi*yI;

  BCUX(MAPI) =          1.0 - elamXI.dm(cos(twopiyI));
  BCUY(MAPI) = (0.5*lam/pi) * elamXI.dm(sin(twopiyI));


  // outflow
#ifdef _MSC_VER
  xO = xin(MAPO); yO = yin(MAPO);
#else
  int No=MAPO.size(); xO.resize(No); yO.resize(No);
  for (n=1;n<=No;++n) {xO(n)=xin(MAPO(n));}
  for (n=1;n<=No;++n) {yO(n)=yin(MAPO(n));}
#endif

  DVec elamXO = exp(lam*xO), twopiyO = 2.0*pi*yO;

  BCPR   (MAPO) =  0.5*(1.0-exp(2.0*lam*xO));
//BCDUNDT(MAPO) = -lam*elamXO.dm(cos(twopiyO));

  if (0) {
    // THIS WORKED
    BCUX(MAPO) =         1.0  - elamXO.dm(cos(twopiyO));
    BCUY(MAPO) = (0.5*lam/pi) * elamXO.dm(sin(twopiyO));
  } else {
    // Neumann data for each velocity
    BCUX(MAPO) = -lam*               elamXO.dm(cos(twopiyO));
    BCUY(MAPO) =  lam*(0.5*lam/pi) * elamXO.dm(sin(twopiyO));
  }
}