Пример #1
0
void NSTauT<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{ 
    for (std::size_t cell=0; cell < workset.numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {       
        TauT(cell,qp) = 0.0;
        normGc(cell,qp) = 0.0;
        for (std::size_t i=0; i < numDims; ++i) {
          for (std::size_t j=0; j < numDims; ++j) {
            TauT(cell,qp) += rho(cell,qp) * Cp(cell,qp) * rho(cell,qp) * Cp(cell,qp)* V(cell,qp,i)*Gc(cell,qp,i,j)*V(cell,qp,j);
            normGc(cell,qp) += Gc(cell,qp,i,j)*Gc(cell,qp,i,j);          
          }
        }
        TauT(cell,qp) += 12.*ThermalCond(cell,qp)*ThermalCond(cell,qp)*std::sqrt(normGc(cell,qp));
        TauT(cell,qp) = 1./std::sqrt(TauT(cell,qp));
      }
    }
  

}
void ThermoMechanicalEnergyResidual<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  bool print = false;
  //if (typeid(ScalarT) == typeid(RealType)) print = true;

  // alias the function space tools
  typedef Intrepid2::FunctionSpaceTools FST;

  // get old temperature
  Albany::MDArray Temperature_old = (*workset.stateArrayPtr)[tempName];

  // time step
  ScalarT dt = deltaTime(0);

  // compute the 'material' flux
  FST::tensorMultiplyDataData<ScalarT> (C, F, F, 'T');
  Intrepid2::RealSpaceTools<ScalarT>::inverse(Cinv, C);
  FST::tensorMultiplyDataData<ScalarT> (CinvTgrad, Cinv, TGrad);
  FST::scalarMultiplyDataData<ScalarT> (flux, ThermalCond, CinvTgrad);

   FST::integrate<ScalarT>(TResidual, flux, wGradBF, Intrepid2::COMP_CPP, false); // "false" overwrites

  if (haveSource) {
    for (int i=0; i<Source.dimension(0); i++) 
       for (int j=0; j<Source.dimension(1); j++) 
          Source(i,j) *= -1.0;
     FST::integrate<ScalarT>(TResidual, Source, wBF, Intrepid2::COMP_CPP, true); // "true" sums into
  }

 for (int i=0; i<mechSource.dimension(0); i++) 
       for (int j=0; j<mechSource.dimension(1); j++)
           mechSource(i,j) *= -1.0;
    FST::integrate<ScalarT>(TResidual, mechSource, wBF, Intrepid2::COMP_CPP, true); // "true" sums into


//Irina comment: code below was commented out
  //if (workset.transientTerms && enableTransient)
  //   FST::integrate<ScalarT>(TResidual, Tdot, wBF, Intrepid2::COMP_CPP, true); // "true" sums into
  //
  // compute factor
  ScalarT fac(0.0);
  if (dt > 0.0)
    fac = ( density * Cv ) / dt;

  for (int cell=0; cell < workset.numCells; ++cell)
    for (int qp=0; qp < numQPs; ++qp)
      Tdot(cell,qp) = fac * ( Temperature(cell,qp) - Temperature_old(cell,qp) );
   FST::integrate<ScalarT>(TResidual, Tdot, wBF, Intrepid2::COMP_CPP, true); // "true" sums into

  if (print)
  {
    std::cout << " *** ThermoMechanicalEnergyResidual *** " << std::endl;
    std::cout << "  **   dt: " << dt << std::endl;
    std::cout << "  **  rho: " << density << std::endl;
    std::cout << "  **   Cv: " << Cv << std::endl;
    for (unsigned int cell(0); cell < workset.numCells; ++cell)
    {
      std::cout << "  ** Cell: " << cell << std::endl;
      for (unsigned int qp(0); qp < numQPs; ++qp)
      {
        std::cout << "   * QP: " << std::endl;
       std::cout << "    F   : ";
       for (unsigned int i(0); i < numDims; ++i)
         for (unsigned int j(0); j < numDims; ++j)
           std::cout << F(cell,qp,i,j) << " ";
       std::cout << std::endl;

        std::cout << "    C   : ";
        for (unsigned int i(0); i < numDims; ++i)
          for (unsigned int j(0); j < numDims; ++j)
            std::cout << C(cell,qp,i,j) << " ";
        std::cout << std::endl;

        std::cout << "    T   : " << Temperature(cell,qp) << std::endl;
        std::cout << "    Told: " << Temperature(cell,qp) << std::endl;
        std::cout << "    k   : " << ThermalCond(cell,qp) << std::endl;
      }
    }
  }
}
Пример #3
0
void HeatEqResid<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{

//// workset.print(std::cout);


  typedef Intrepid::FunctionSpaceTools FST;

  // Since Intrepid will later perform calculations on the entire workset size
  // and not just the used portion, we must fill the excess with reasonable
  // values. Leaving this out leads to floating point exceptions !!!
  for (std::size_t cell=workset.numCells; cell < worksetSize; ++cell)
    for (std::size_t qp=0; qp < numQPs; ++qp){
      ThermalCond(cell,qp) = 0.0;
      for (std::size_t i=0; i < numDims; ++i){
        flux(cell,qp,i) = 0.0;
        TGrad(cell,qp,i) = 0.0;
      }
    }

  FST::scalarMultiplyDataData<ScalarT> (flux, ThermalCond, TGrad);

  FST::integrate<ScalarT>(TResidual, flux, wGradBF, Intrepid::COMP_CPP, false); // "false" overwrites

  if (haveSource) {

    for (std::size_t cell=workset.numCells; cell < worksetSize; ++cell)
      for (std::size_t qp=0; qp < numQPs; ++qp)
        Source(cell,qp) = 0.0;

    for (int i =0; i< Source.dimension(0); i++)
     for (int j =0; j< Source.dimension(1); j++)
        Source(i,j) *= -1.0;
    FST::integrate<ScalarT>(TResidual, Source, wBF, Intrepid::COMP_CPP, true); // "true" sums into
  }

  if (workset.transientTerms && enableTransient){

    for (std::size_t cell=workset.numCells; cell < worksetSize; ++cell)
      for (std::size_t qp=0; qp < numQPs; ++qp)
        Tdot(cell,qp) = 0.0;

    FST::integrate<ScalarT>(TResidual, Tdot, wBF, Intrepid::COMP_CPP, true); // "true" sums into

  }

  if (haveConvection)  {
    Intrepid::FieldContainer<ScalarT> convection(worksetSize, numQPs);

    for (std::size_t cell=workset.numCells; cell < worksetSize; ++cell)
      for (std::size_t qp=0; qp < numQPs; ++qp)
        convection(cell,qp) = 0.0;

    for (std::size_t cell=0; cell < workset.numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
        convection(cell,qp) = 0.0;
        for (std::size_t i=0; i < numDims; ++i) {
          if (haverhoCp)
            convection(cell,qp) += rhoCp(cell,qp) * convectionVels[i] * TGrad(cell,qp,i);
          else
            convection(cell,qp) += convectionVels[i] * TGrad(cell,qp,i);
        }
      }
    }

    FST::integrate<ScalarT>(TResidual, convection, wBF, Intrepid::COMP_CPP, true); // "true" sums into
  }


  if (haveAbsorption) {

    // Since Intrepid will later perform calculations on the entire workset size
    // and not just the used portion, we must fill the excess with reasonable
    // values. Leaving this out leads to floating point exceptions !!!
    for (std::size_t cell=workset.numCells; cell < worksetSize; ++cell)
      for (std::size_t qp=0; qp < numQPs; ++qp){
        aterm(cell,qp) = 0.0;
        Absorption(cell,qp) = 0.0;
        Temperature(cell,qp) = 0.0;
      }

    FST::scalarMultiplyDataData<ScalarT> (aterm, Absorption, Temperature);
    FST::integrate<ScalarT>(TResidual, aterm, wBF, Intrepid::COMP_CPP, true); 
  }

//TResidual.print(std::cout, true);

}