Esempio n. 1
0
Vector3 BezierCurve::evalBCurve(double t) {
	//Create a vector with our Bernstein coefficients
	Vector4 C(bCoef(3, 0, t),
		bCoef(3, 1, t),
		bCoef(3, 2, t),
		bCoef(3, 3, t));
	Matrix4 Mp = setMatrix(0, 1, 2, 3);
	//Calculate the final point q
	Vector4 q = Mp * C;
	Vector3 temp;
	temp.set(q.get(0), q.get(1), q.get(2));
	return temp;
}
Esempio n. 2
0
Vector4 bpatch::evalBCurve(Matrix4 Mp, double t) {
	//Create a vector with our Bernstein coefficients
		Vector4 C(bCoef(3, 0, t),
		bCoef(3, 1, t),
		bCoef(3, 2, t),
		bCoef(3, 3, t));

	//Calculate the final point q
	Vector4 q = Mp * C;

	//And make sure q is a point by setting its w-component to 1
	q.setValue(3, 1.0);
	return q;
}
Esempio n. 3
0
//-----------------------------------------------------------------------
// AMR Factory define function, with coefficient data allocated automagically
// for operators.
void
VCAMRPoissonOp2Factory::
define(const ProblemDomain& a_coarseDomain,
       const Vector<DisjointBoxLayout>& a_grids,
       const Vector<int>& a_refRatios,
       const Real& a_coarsedx,
       BCHolder a_bc,
       const IntVect& a_ghostVect)
{
  // This just allocates coefficient data, sets alpha = beta = 1, and calls
  // the other define() method.
  Vector<RefCountedPtr<LevelData<FArrayBox> > > aCoef(a_grids.size());
  Vector<RefCountedPtr<LevelData<FluxBox> > > bCoef(a_grids.size());
  for (int i = 0; i < a_grids.size(); ++i)
  {
    aCoef[i] = RefCountedPtr<LevelData<FArrayBox> >(
                 new LevelData<FArrayBox>(a_grids[i], 1, a_ghostVect));
    bCoef[i] = RefCountedPtr<LevelData<FluxBox> >(
                 new LevelData<FluxBox>(a_grids[i], 1, a_ghostVect));

    // Initialize the a and b coefficients to 1 for starters.
    for (DataIterator dit = aCoef[i]->dataIterator(); dit.ok(); ++dit)
    {
      (*aCoef[i])[dit()].setVal(1.0);
      for (int idir = 0; idir < SpaceDim; ++idir)
        (*bCoef[i])[dit()][idir].setVal(1.0);
    }
  }
  Real alpha = 1.0, beta = 1.0;
  define(a_coarseDomain, a_grids, a_refRatios, a_coarsedx, a_bc,
         alpha, aCoef, beta, bCoef);
}
Esempio n. 4
0
Vector3 BezierCurve::evalBCurve(double t) {
	//Create a vector with our Bernstein coefficients
    double C0 = bCoef(3, 0, t);
    double C1 = bCoef(3, 1, t);
    double C2 = bCoef(3, 2, t);
    double C3 = bCoef(3, 3, t);
    
    Vector4 C(C0, C1, C2, C3);

    Matrix4 Mp = Matrix4(points[0].getValue(0), points[1].getValue(0),
                         points[2].getValue(0), points[3].getValue(0),
                         points[0].getValue(1), points[1].getValue(1),
                         points[2].getValue(1), points[3].getValue(1),
                         points[0].getValue(2), points[1].getValue(2),
                         points[2].getValue(2), points[3].getValue(2),
                         0.0, 0.0, 0.0, 0.0);
    
	//Calculate the final point q
	Vector4 q = Mp.mult(C);
    Vector3 temp = Vector3(q.getValue(0), q.getValue(1), q.getValue(2));
	return temp;
}
Esempio n. 5
0
MGLevelOp<LevelData<FArrayBox> >* VCAMRPoissonOp2Factory::MGnewOp(const ProblemDomain& a_indexSpace,
                                                                  int                  a_depth,
                                                                  bool                 a_homoOnly)
{
  CH_TIME("VCAMRPoissonOp2Factory::MGnewOp");

  Real dxCrse = -1.0;

  int ref;

  for (ref = 0; ref < m_domains.size(); ref++)
    {
      if (a_indexSpace.domainBox() == m_domains[ref].domainBox())
      {
        break;
      }
    }

  CH_assert(ref !=  m_domains.size()); // didn't find domain

  if (ref > 0)
  {
    dxCrse = m_dx[ref-1];
  }

  ProblemDomain domain(m_domains[ref]);
  Real dx = m_dx[ref];
  int coarsening = 1;

  for (int i = 0; i < a_depth; i++)
    {
      coarsening *= 2;
      domain.coarsen(2);
    }

  if (coarsening > 1 && !m_boxes[ref].coarsenable(coarsening*VCAMRPoissonOp2::s_maxCoarse))
  {
    return NULL;
  }

  dx *= coarsening;

  DisjointBoxLayout layout;
  coarsen_dbl(layout, m_boxes[ref], coarsening);

  Copier ex = m_exchangeCopiers[ref];
  CFRegion cfregion = m_cfregion[ref];

  if (coarsening > 1)
  {
    ex.coarsen(coarsening);
    cfregion.coarsen(coarsening);
  }

  VCAMRPoissonOp2* newOp = new VCAMRPoissonOp2;

  newOp->define(layout, dx, domain, m_bc, ex, cfregion);

  newOp->m_alpha = m_alpha;
  newOp->m_beta  = m_beta;

  if (a_depth == 0)
    {
      // don't need to coarsen anything for this
      newOp->m_aCoef = m_aCoef[ref];
      newOp->m_bCoef = m_bCoef[ref];
    }
  else
    {
      // need to coarsen coefficients
      RefCountedPtr<LevelData<FArrayBox> > aCoef( new LevelData<FArrayBox> );
      RefCountedPtr<LevelData<FluxBox> > bCoef( new LevelData<FluxBox> );
      aCoef->define(layout, m_aCoef[ref]->nComp(), m_aCoef[ref]->ghostVect());
      bCoef->define(layout, m_bCoef[ref]->nComp(), m_bCoef[ref]->ghostVect());

      // average coefficients to coarser level
      // for now, do this with a CoarseAverage --
      // may want to switch to harmonic averaging at some point
      CoarseAverage averager(m_aCoef[ref]->getBoxes(),
                             layout, aCoef->nComp(), coarsening);

      CoarseAverageFace faceAverager(m_bCoef[ref]->getBoxes(),
                                     bCoef->nComp(), coarsening);

      if (m_coefficient_average_type == CoarseAverage::arithmetic)
        {
          averager.averageToCoarse(*aCoef, *(m_aCoef[ref]));
          faceAverager.averageToCoarse(*bCoef, *(m_bCoef[ref]));
        }
      else if (m_coefficient_average_type == CoarseAverage::harmonic)
        {
          averager.averageToCoarseHarmonic(*aCoef, *(m_aCoef[ref]));
          faceAverager.averageToCoarseHarmonic(*bCoef, *(m_bCoef[ref]));
        }
      else
        {
          MayDay::Abort("VCAMRPoissonOp2Factory::MGNewOp -- bad averagetype");
        }

      newOp->m_aCoef = aCoef;
      newOp->m_bCoef = bCoef;
    }

  newOp->computeLambda();

  newOp->m_dxCrse = dxCrse;

  return (MGLevelOp<LevelData<FArrayBox> >*)newOp;
}