void 
Albany::SolutionAverageResponseFunction::
evaluateResponseImpl (
    const Thyra_Vector& x,
		Thyra_Vector& g)
{
  //IKT, 12/11/19: I had to add these conversions to TpetraVectors b/c I do 
  //not believe there is a method equivalent to getLocalLength in Thyra.
  //The checks done here with the local length are needed for problems
  //where the mesh can adapt. 
  int one_ll = 0; 
  if (!one.is_null()) {
    auto oneTpetraVector = ConverterT::getConstTpetraVector(one); 
    one_ll = oneTpetraVector->getLocalLength(); 
  }
  auto xTpetraVector = ConverterT::getConstTpetraVector(Teuchos::rcpFromRef(x)); 
  int x_ll = xTpetraVector->getLocalLength(); 
  if (one.is_null() || (x_ll != one_ll)) {
    one = Thyra::createMember(x.space());
    one->assign(1.0);
  }
  const ST mean = one->dot(x) / x.space()->dim();
  g.assign(mean);
}
Ejemplo n.º 2
0
void Coupler::copyAll(Coupler_ptr target) const
{
    const dim_t overlap = getNumOverlapValues();
    const dim_t localSize = getLocalLength()*block_size;
#pragma omp parallel
    {
#pragma omp for
        for (dim_t i=0; i < overlap; ++i) {
            target->recv_buffer[i] = recv_buffer[i];
        }
#pragma omp for
        for (dim_t i=0; i < localSize; ++i) {
            target->data[i] = data[i];
        }
    }
}
Ejemplo n.º 3
0
    //! Set multi-vector values to random numbers. XPetra implementation
    virtual void Xpetra_randomize()
    {
        typedef Teuchos::ScalarTraits<Scalar> SCT;

        const size_t numVectors = getNumVectors();
        for (size_t i = 0; i < numVectors; i++)
        {
            Teuchos::ArrayRCP< Scalar > datai = getDataNonConst(i);

            const size_t myLength = getLocalLength();
            for(size_t j=0; j<myLength; j++)
            {
                datai[j] = SCT::random();
            }
        }
    }