示例#1
0
  void gradient_1(Teuchos::RCP<Intrepid::FieldContainer<Real> > & grad,
                  const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & u_coeff,
                  const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & z_coeff = Teuchos::null,
                  const Teuchos::RCP<const std::vector<Real> > & z_param = Teuchos::null) {
    // Get relevant dimensions
    int c = fe_->gradN()->dimension(0);
    int f = fe_->gradN()->dimension(1);
    int p = fe_->gradN()->dimension(2);
    int d = fe_->gradN()->dimension(3);
    // Initialize output grad
    std::vector<Teuchos::RCP<Intrepid::FieldContainer<Real> > > G(d);
    for (int i=0; i<d; ++i) {
      G[i] = Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, f));
    }
    // Evaluate on FE basis
    std::vector<Teuchos::RCP<Intrepid::FieldContainer<Real> > > load_eval(d);
    for (int i=0; i<d; ++i) {
      load_eval[i] = Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, p));
    }
    load_->compute(load_eval, fe_, QoI<Real>::getParameter());
    // Build local gradient of state tracking term
    for (int i=0; i<d; ++i) {
      Intrepid::FunctionSpaceTools::integrate<Real>(*G[i],
                                                    *load_eval[i],
                                                    *(fe_->NdetJ()),
                                                    Intrepid::COMP_CPP,
                                                    false);
      Intrepid::RealSpaceTools<Real>::scale(*G[i], scale_);
    }

    fieldHelper_->combineFieldCoeff(grad, G);
  }
示例#2
0
 void HessVec_11(Teuchos::RCP<Intrepid::FieldContainer<Real> > & hess,
                 const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & v_coeff,
                 const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & u_coeff,
                 const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & z_coeff = Teuchos::null,
                 const Teuchos::RCP<const std::vector<Real> > & z_param = Teuchos::null) {
   const int c = fe_->gradN()->dimension(0);
   const int f = fe_->gradN()->dimension(1);
   const int p = fe_->gradN()->dimension(2);
   Teuchos::RCP<Intrepid::FieldContainer<Real> > valV_eval =
     Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, p));
   hess = Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, f));
   fe_->evaluateValue(valV_eval, v_coeff);
   Intrepid::FunctionSpaceTools::integrate<Real>(*hess,
                                                 *valV_eval,
                                                 *(fe_->NdetJ()),
                                                 Intrepid::COMP_CPP, false);
 }
示例#3
0
 void residual(Teuchos::RCP<Intrepid::FieldContainer<Real> > & res,
               const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & u_coeff,
               const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & z_coeff = Teuchos::null,
               const Teuchos::RCP<const std::vector<Real> > & z_param = Teuchos::null) {
   // GET DIMENSIONS
   int c = u_coeff->dimension(0);
   int p = cellCub_->getNumPoints();
   int f = basisPtr_->getCardinality();
   int d = cellCub_->getDimension();
   // INITIALIZE RESIDUAL
   res = Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, f));
   // COMPUTE STIFFNESS TERM
   Teuchos::RCP<Intrepid::FieldContainer<Real> > gradU_eval =
     Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, p, d));
   fe_vol_->evaluateGradient(gradU_eval, u_coeff);
   Intrepid::FunctionSpaceTools::integrate<Real>(*res, *gradU_eval, *(fe_vol_->gradNdetJ()), Intrepid::COMP_CPP, false);
   // ADD CONTROL TERM TO RESIDUAL
   if ( z_coeff != Teuchos::null ) {
     Teuchos::RCP<Intrepid::FieldContainer<Real> > valZ_eval =
       Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, p));
     fe_vol_->evaluateValue(valZ_eval, z_coeff);
     Intrepid::FunctionSpaceTools::integrate<Real>(*res, *valZ_eval, *(fe_vol_->NdetJ()), Intrepid::COMP_CPP, true);
   }
   // APPLY DIRICHLET CONDITIONS
   int numSideSets = bdryCellLocIds_.size();
   if (numSideSets > 0) {
     for (int i = 0; i < numSideSets; ++i) {
       int numLocalSideIds = bdryCellLocIds_[i].size();
       for (int j = 0; j < numLocalSideIds; ++j) {
         int numCellsSide = bdryCellLocIds_[i][j].size();
         int numBdryDofs = fidx_[j].size();
         for (int k = 0; k < numCellsSide; ++k) {
           int cidx = bdryCellLocIds_[i][j][k];
           for (int l = 0; l < numBdryDofs; ++l) {
             //std::cout << "\n   j=" << j << "  l=" << l << "  " << fidx[j][l];
             (*res)(cidx,fidx_[j][l]) = (*u_coeff)(cidx,fidx_[j][l]) - (*bdryCellDofValues_[i][j])(k,fidx_[j][l]);
           }
         }
       }
     }
   }
 }
示例#4
0
 void gradient_1(Teuchos::RCP<Intrepid::FieldContainer<Real> > & grad,
                 const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & u_coeff,
                 const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & z_coeff = Teuchos::null,
                 const Teuchos::RCP<const std::vector<Real> > & z_param = Teuchos::null) {
   // Get relevant dimensions
   const int c = fe_->gradN()->dimension(0);
   const int f = fe_->gradN()->dimension(1);
   const int p = fe_->gradN()->dimension(2);
   // Initialize output grad
   grad = Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, f));
   // Evaluate state on FE basis
   Teuchos::RCP<Intrepid::FieldContainer<Real> > valU_eval =
     Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, p));
   fe_->evaluateValue(valU_eval, u_coeff);
   // Compute gradient of squared L2-norm of diff
   Intrepid::FunctionSpaceTools::integrate<Real>(*grad,
                                                 *valU_eval,
                                                 *(fe_->NdetJ()),
                                                 Intrepid::COMP_CPP, false);
 }
示例#5
0
  void gradient_2(Teuchos::RCP<Intrepid::FieldContainer<Real> > & grad,
                  const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & u_coeff,
                  const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & z_coeff = Teuchos::null,
                  const Teuchos::RCP<const std::vector<Real> > & z_param = Teuchos::null) {
    // Get relevant dimensions
    int c = fe_->gradN()->dimension(0);
    int f = fe_->gradN()->dimension(1);
    int d = fe_->gradN()->dimension(3);

    // Initialize output grad
    std::vector<Teuchos::RCP<Intrepid::FieldContainer<Real> > > G(d);
    for (int i=0; i<d; ++i) {
      G[i] = Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, f));
    }

    // Compute gradient of energy
    Intrepid::FunctionSpaceTools::integrate<Real>(*G[0],
                                                  *ones_,
                                                  *(fe_->NdetJ()),
                                                  Intrepid::COMP_CPP, false);

    fieldHelper_->combineFieldCoeff(grad, G);
  }
示例#6
0
 void Jacobian_2(Teuchos::RCP<Intrepid::FieldContainer<Real> > & jac,
                 const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & u_coeff,
                 const Teuchos::RCP<const Intrepid::FieldContainer<Real> > & z_coeff = Teuchos::null,
                 const Teuchos::RCP<const std::vector<Real> > & z_param = Teuchos::null) {
   if ( z_coeff != Teuchos::null ) {
     // GET DIMENSIONS
     int c = u_coeff->dimension(0);
     int f = basisPtr_->getCardinality();
     // INITIALIZE JACOBIAN
     jac = Teuchos::rcp(new Intrepid::FieldContainer<Real>(c, f, f));
     // ADD CONTROL TERM
     Intrepid::FunctionSpaceTools::integrate<Real>(*jac, *(fe_vol_->N()), *(fe_vol_->NdetJ()), Intrepid::COMP_CPP, false);
     // APPLY DIRICHLET CONDITIONS
     int numSideSets = bdryCellLocIds_.size();
     if (numSideSets > 0) {
       for (int i = 0; i < numSideSets; ++i) {
         int numLocalSideIds = bdryCellLocIds_[i].size();
         for (int j = 0; j < numLocalSideIds; ++j) {
           int numCellsSide = bdryCellLocIds_[i][j].size();
           int numBdryDofs = fidx_[j].size();
           for (int k = 0; k < numCellsSide; ++k) {
             int cidx = bdryCellLocIds_[i][j][k];
             for (int l = 0; l < numBdryDofs; ++l) {
               //std::cout << "\n   j=" << j << "  l=" << l << "  " << fidx[j][l];
               for (int m = 0; m < f; ++m) {
                 (*jac)(cidx,fidx_[j][l],m) = static_cast<Real>(0);
               }
             }
           }
         }
       }
     }
   }
   else {
     throw Exception::Zero(">>> (PDE_Poisson::Jacobian_2): Jacobian is zero.");
   }
 }