Example #1
0
void PointValues_Evaluator<EvalT,TraitsT>::initialize(const Teuchos::RCP<const panzer::PointRule> & pointRule,
                                                      const Intrepid::FieldContainer<double> & userArray)
{
  TEUCHOS_ASSERT(userArray.rank()==2);

  panzer::MDFieldArrayFactory af(pointRule->getName()+"_");
       
  // copy user array data
  refPointArray = Intrepid::FieldContainer<double>(userArray.dimension(0),userArray.dimension(1));
  TEUCHOS_ASSERT(refPointArray.size()==userArray.size());
  for(int i=0;i<userArray.size();i++)
     refPointArray[i] = userArray[i]; 

  // setup all fields to be evaluated and constructed
  pointValues.setupArrays(pointRule,af);

  // the field manager will allocate all of these field
  this->addEvaluatedField(pointValues.coords_ref);
  this->addEvaluatedField(pointValues.node_coordinates);
  this->addEvaluatedField(pointValues.jac);
  this->addEvaluatedField(pointValues.jac_inv);
  this->addEvaluatedField(pointValues.jac_det);
  this->addEvaluatedField(pointValues.point_coords);

  std::string n = "PointValues_Evaluator: " + pointRule->getName();
  this->setName(n);
}
void SubBasisDofMatrixMapper::mapDataIntoGlobalContainer(const Intrepid::FieldContainer<double> &allLocalData, const vector<int> &basisOrdinalsInLocalData,
        const map<GlobalIndexType, unsigned> &globalIndexToOrdinal,
        bool fittableDofsOnly, const set<GlobalIndexType> &fittableDofIndices, Intrepid::FieldContainer<double> &globalData)
{
    const set<int>* basisOrdinalFilter = &this->basisDofOrdinalFilter();
    vector<int> dofIndices(basisOrdinalFilter->begin(),basisOrdinalFilter->end());
    FieldContainer<double> subBasisData(basisOrdinalFilter->size());
    int dofCount = basisOrdinalFilter->size();
    if (allLocalData.rank()==1)
    {
        for (int i=0; i<dofCount; i++)
        {
            subBasisData[i] = allLocalData[basisOrdinalsInLocalData[dofIndices[i]]];
        }
    }
    else
    {
        TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, "mapDataIntoGlobalContainer only supports rank 1 basis data");
    }

    // subBasisData must be rank 2, and must have the same size as FilteredLocalDofOrdinals in its first dimension
    // reshape as a rank 2 container (column vector as a matrix):
    subBasisData.resize(subBasisData.dimension(0),1);

    this->mapSubBasisDataIntoGlobalContainer(subBasisData, globalIndexToOrdinal, fittableDofsOnly, fittableDofIndices, globalData);
}
/** Get the local coordinates for this field. This is independent of element
  * locations.
  *
  * \param[in,out] coords   Coordinates associated with this field type.
  */
void IntrepidFieldPattern::getInterpolatoryCoordinates(const Intrepid::FieldContainer<double> & cellVertices,
                                                       Intrepid::FieldContainer<double> & coords) const
{
   TEUCHOS_ASSERT(cellVertices.rank()==3);

   int numCells = cellVertices.dimension(0);

   // grab the local coordinates
   Intrepid::FieldContainer<double> localCoords;
   getInterpolatoryCoordinates(localCoords);

   // resize the coordinates field container
   coords.resize(numCells,localCoords.dimension(0),getDimension());

   if(numCells>0) {
      // map to phsyical coordinates
      Intrepid::CellTools<double> cellTools;
      cellTools.mapToPhysicalFrame(coords,localCoords,cellVertices,intrepidBasis_->getBaseCellTopology());
   }
}