void GatherCoordinateVector<PHAL::AlbanyTraits::Tangent, Traits>::
evaluateFields(typename Traits::EvalData workset)
{ 
  unsigned int numCells = workset.numCells;

  Teuchos::ArrayRCP<Teuchos::ArrayRCP<double*> > wsCoords = workset.wsCoords;
  const Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::ArrayRCP<double> > > > & ws_coord_derivs = workset.ws_coord_derivs;
  std::vector<int> *coord_deriv_indices = workset.coord_deriv_indices;
  int numShapeDerivs = ws_coord_derivs.size();
  int numParams = workset.num_cols_p;

  for (std::size_t cell=0; cell < numCells; ++cell) {
    for (std::size_t node = 0; node < numVertices; ++node) {
      for (std::size_t eq=0; eq < numDim; ++eq) { 
        coordVec(cell,node,eq) = TanFadType(numParams, wsCoords[cell][node][eq]); 
        for (int j=0; j < numShapeDerivs; ++j) { 
          coordVec(cell,node,eq).fastAccessDx((*coord_deriv_indices)[j]) 
               =  ws_coord_derivs[j][cell][node][eq];
        }
      }
    }
  }

  // Since Intrepid2 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 calculations on singular elements.
  //
  for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
    for (std::size_t node = 0; node < numVertices; ++node) {
      for (std::size_t eq=0; eq < numDim; ++eq) { 
        coordVec(cell,node,eq) = coordVec(0,node,eq); 
      }
    }
  }
}
void GatherCoordinateVector<EvalT, Traits>::evaluateFields(typename Traits::EvalData workset)
{ 
  if (memoizer_.have_stored_data(workset)) return;

  unsigned int numCells = workset.numCells;
  Teuchos::ArrayRCP<Teuchos::ArrayRCP<double*> > wsCoords = workset.wsCoords;

  for (std::size_t cell=0; cell < numCells; ++cell) {
    for (std::size_t node = 0; node < numNodes; ++node) {
      for (std::size_t i=0; i < numCoords; ++i) { 
        coordVec(cell,node,i) = wsCoords[cell][node][i]; 
      }
    }
  }

  // Since Intrepid2 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 calculations on singular elements.
  for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
    for (std::size_t node = 0; node < numNodes; ++node) {
      for (std::size_t i=0; i < numCoords; ++i) { 
        coordVec(cell,node,i) = coordVec(0,node,i); 
      }
    }
  }
}
void StokesL1L2BodyForce<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
 if (bf_type == NONE) {
   for (std::size_t cell=0; cell < workset.numCells; ++cell) 
     for (std::size_t qp=0; qp < numQPs; ++qp)       
       for (std::size_t i=0; i < vecDim; ++i) 
  	 force(cell,qp,i) = 0.0;
 }
 else if (bf_type == L1L2_SINCOS) {
   double xphase=0.0, yphase=0.0;
   double r = 3*pi;
   for (std::size_t cell=0; cell < workset.numCells; ++cell) {
     for (std::size_t qp=0; qp < numQPs; ++qp) {      
       ScalarT* f = &force(cell,qp,0);
       MeshScalarT x2pi = 2.0*pi*coordVec(cell,qp,0);
       MeshScalarT y2pi = 2.0*pi*coordVec(cell,qp,1);
       MeshScalarT muargt = 2.0*pi*cos(x2pi + xphase)*cos(y2pi + yphase) + r;  
       MeshScalarT muqp = pow(A, -1.0/n)*pow(muargt, 1.0/n - 1.0);
       MeshScalarT dmuargtdx = -4.0*pi*pi*sin(x2pi + xphase)*cos(y2pi + yphase); 
       MeshScalarT dmuargtdy = -4.0*pi*pi*cos(x2pi + xphase)*sin(y2pi + yphase); 
       MeshScalarT exx = 2.0*pi*cos(x2pi + xphase)*cos(y2pi + yphase) + r; 
       MeshScalarT eyy = -2.0*pi*cos(x2pi + xphase)*cos(y2pi + yphase) - r; 
       MeshScalarT exy = 0.0;  
       f[0] = 2.0*muqp*(-4.0*pi*pi*sin(x2pi + xphase)*cos(y2pi + yphase))  
            + 2.0*pow(A, -1.0/n)*(1.0/n - 1.0)*pow(muargt, 1.0/n - 2.0)*(dmuargtdx*(2.0*exx + eyy) + dmuargtdy*exy); 
       f[1] = 2.0*muqp*(4.0*pi*pi*cos(x2pi + xphase)*sin(y2pi + yphase)) 
            + 2.0*pow(A, -1.0/n)*(1.0/n - 1.0)*pow(muargt, 1.0/n - 2.0)*(dmuargtdx*exy + dmuargtdy*(exx + 2.0*eyy));
     }
   }
 }
}
Пример #4
0
void BiotModulus<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  int numCells = workset.numCells;

  if (is_constant) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
    	  biotModulus(cell,qp) = constant_value;
      }
    }
  }
  else {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (int i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
			biotModulus(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
  if (isPoroElastic) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
    	    // 1/M = (B-phi)/Ks + phi/Kf
    	    biotModulus(cell,qp) = 1/((biotCoefficient(cell,qp) - porosity(cell,qp))/GrainBulkModulus
    	    		                  + porosity(cell,qp)/FluidBulkModulus);

      }
    }
  }
}
Пример #5
0
void BiotCoefficient<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  int numCells = workset.numCells;

  if (is_constant) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
    	  biotCoefficient(cell,qp) = constant_value;
      }
    }
  }
  else {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (int i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
		  biotCoefficient(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
  if (isPoroElastic) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
    	  // assume that bulk modulus is linear with respect to porosity
    	  biotCoefficient(cell,qp) = 1.0 - Kskeleton_value/Kgrain_value;
      }
    }
  }
}
Пример #6
0
void Permittivity<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  if (is_constant) {
    for (std::size_t cell=0; cell < workset.numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
         permittivity(cell,qp) = constant_value;
      }
    }
  }

  else {
    for (std::size_t cell=0; cell < workset.numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
          Teuchos::Array<MeshScalarT> point(numDims);
          for (std::size_t i=0; i<numDims; i++)
              point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
          if (randField == UNIFORM)
              permittivity(cell,qp) = exp_rf_kl->evaluate(point, rv);
          else if (randField == LOGNORMAL)
              permittivity(cell,qp) = std::exp(exp_rf_kl->evaluate(point, rv));
      }
    }
  }
}
Пример #7
0
void HardeningModulus<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  int numCells = workset.numCells;

  if (is_constant) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	hardeningModulus(cell,qp) = constant_value;
      }
    }
  }
  else {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (int i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
	hardeningModulus(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
  if (isThermoElastic) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	hardeningModulus(cell,qp) -= dHdT_value * (Temperature(cell,qp) - refTemp);
      }
    }
  }
}
Пример #8
0
void RecoveryModulus<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  int numCells = workset.numCells;

  if (is_constant) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
    	  recoveryModulus(cell,qp) = constant_value;
      }
    }
  }
#ifdef ALBANY_STOKHOS
  else {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
    	  Teuchos::Array<MeshScalarT> point(numDims);
    	  for (int i=0; i<numDims; i++)
    		  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
    	  	  recoveryModulus(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
#endif
  if (isThermoElastic) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
    	  if (Temperature(cell,qp) != 0)
    		  recoveryModulus(cell,qp) = c1 * std::exp(c2 / Temperature(cell,qp));
    	  else
    		  recoveryModulus(cell,qp) = 0.0;
      }
    }
  }
}
Пример #9
0
void BulkModulus<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  if (is_constant) {
    for (unsigned int cell=0; cell < workset.numCells; ++cell) {
      for (unsigned int qp=0; qp < numQPs; ++qp) {
	bulkModulus(cell,qp) = constant_value;
      }
    }
  }
#ifdef ALBANY_STOKHOS
  else {
    for (unsigned int cell=0; cell < workset.numCells; ++cell) {
      for (unsigned int qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (unsigned int i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
	bulkModulus(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
#endif
  if (isThermoElastic) {
    for (int cell=0; cell < workset.numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	bulkModulus(cell,qp) -= dKdT_value * (Temperature(cell,qp) - refTemp);
      }
    }
  }
}
Пример #10
0
void TauContribution<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  std::size_t numCells = workset.numCells;

  if (is_constant) {
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
    	  tauFactor(cell,qp) = constant_value;
      }
    }
  }
  else {
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (std::size_t i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
		tauFactor(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
  for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
    	  tauFactor(cell,qp) = DL(cell,qp)*Clattice(cell,qp)*VmPartial/
    			               ( Rideal*temperature(cell,qp) );

      }
   }
}
Пример #11
0
void KCPermeability<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  std::size_t numCells = workset.numCells;

  if (is_constant) {
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
    	  kcPermeability(cell,qp) = constant_value;
      }
    }
  }
  else {
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (std::size_t i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
		  kcPermeability(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
  if (isPoroElastic) {
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
    	  // Cozeny Karman permeability equation
    	  kcPermeability(cell,qp) = constant_value*porosity(cell,qp)*porosity(cell,qp)*porosity(cell,qp)/
    			                    (1-porosity(cell,qp)*porosity(cell,qp));
      }
    }
  }
}
Пример #12
0
void 
Trigonometric<EvalT,Traits>::
evaluateFields(typename Traits::EvalData workset){

  // Loop over cells, quad points: compute Trigonometric Source Term
  if (m_num_dim == 2) {
    for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
      for (std::size_t iqp=0; iqp<m_num_qp; iqp++) {
        //MeshScalarT *X = &coordVec(cell,iqp,0); 
        m_source(cell, iqp) = 8.0*pi*pi*sin(2.0*pi*coordVec(cell,iqp,0))*cos(2.0*pi*coordVec(cell,iqp,1));
      }
    }
  }
  else {
    std::cout << "Trigonometric source implemented only for 2D; setting f = 1 constant source." << std::endl; 
    for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
      for (std::size_t iqp=0; iqp<m_num_qp; iqp++) {
        m_source(cell, iqp) = m_constant;
      }
    }
  }
}
void GatherCoordinateVector<EvalT, Traits>::evaluateFields(typename Traits::EvalData workset)
{ 
  unsigned int numCells = workset.numCells;
  Teuchos::ArrayRCP<Teuchos::ArrayRCP<double*> > wsCoords = workset.wsCoords;

  for (std::size_t cell=0; cell < numCells; ++cell) {
    for (std::size_t node = 0; node < numVertices; ++node) {
      for (std::size_t eq=0; eq < numDim; ++eq) { 
        coordVec(cell,node,eq) = wsCoords[cell][node][eq]; 
      }
    }
  }

  // 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 calculations on singular elements.
  for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
    for (std::size_t node = 0; node < numVertices; ++node) {
      for (std::size_t eq=0; eq < numDim; ++eq) { 
        coordVec(cell,node,eq) = coordVec(0,node,eq); 
      }
    }
  }
}
Пример #14
0
void SaturationModulus<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  bool print = false;
  //if (typeid(ScalarT) == typeid(RealType)) print = true;

  if (print)
    std::cout << " *** SaturatioModulus *** " << std::endl;

  int numCells = workset.numCells;

  if (is_constant) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	satMod(cell,qp) = constant_value;
      }
    }
  }
#ifdef ALBANY_STOKHOS
  else {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (int i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
	satMod(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
#endif
  if (isThermoElastic) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	satMod(cell,qp) -= dSdT_value * (Temperature(cell,qp) - refTemp);
        if (print)
        {
          std::cout << "    S   : " << satMod(cell,qp) << std::endl;
          std::cout << "    temp: " << Temperature(cell,qp) << std::endl;
          std::cout << "    dSdT: " << dSdT_value << std::endl;
          std::cout << "    refT: " << refTemp << std::endl;
        }

      }
    }
  }
}
void XZScalarAdvectionResid<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  // Constants 
  L = 2.5e6 // Latent Heat J/kg
  cp = 1004.64 // Specfic Heat J/kg/K
  
  std::vector<ScalarT> vel(2);
  for (std::size_t i=0; i < Residual.size(); ++i) Residual(i)=0.0;

  for (std::size_t cell=0; cell < workset.numCells; ++cell) {
    for (std::size_t qp=0; qp < numQPs; ++qp) {
  
      if (coordVec(cell,qp,1) > 5.0) vel[0] = Re;
      else                           vel[0] = 0.0;
      vel[1] = 0.0;

      for (std::size_t node=0; node < numNodes; ++node) {
          // Transient Term
          // Residual(cell,node) += rhoDot(cell,qp)*wBF(cell,node,qp);
          Residual(cell,node,0) += rhoDot(cell,qp)*wBF(cell,node,qp);
          Residual(cell,node,1) += tempDot(cell,qp)*wBF(cell,node,qp);
          Residual(cell,node,2) += qvDot(cell,qp)*wBF(cell,node,qp);
          Residual(cell,node,3) += qcDot(cell,qp)*wBF(cell,node,qp);

          // Compute saturation mixing ratio for condensation rate with Teton's formula
          // Saturation vapor pressure, temp in Celcius, equation valid over [-35,35] with a 3% error
          qvs = 3.8 / rhoDot(cell,qp) * exp(17.27 * (tempGrad(cell,qp) - 273.)/(tempGrad(cell,qp) - 36.));

          C = max( (qvDot(cell,qp) - qvs)/( 1. + qvs*((4093.*L)/(cp*tempDot(cell,qp)-36.)^2.) ) , -qcDot(cell,qp) );

 
          Tv = T * (1 + 0.6*qv);

          // Advection Term
          for (std::size_t j=0; j < numDims; ++j) {
            Residual(cell,node,0) += vel[j]*rhoGrad(cell,qp,j)*wBF(cell,node,qp);
            Residual(cell,node,1) += vel[j]*tempGrad(cell,qp,j)*wBF(cell,node,qp)+L/cp*C;
            Residual(cell,node,2) += vel[j]*qvGrad(cell,qp,j)*wBF(cell,node,qp)-C;
            Residual(cell,node,3) += vel[j]*qcGrad(cell,qp,j)*wBF(cell,node,qp)+C;
          }
      }
    }
  }
}
void PHAL::ResponseFieldIntegralT<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{   
  // Zero out local response
  for (typename PHX::MDField<ScalarT>::size_type i=0; 
       i<this->local_response.size(); i++)
    this->local_response[i] = 0.0;

  if( ebNames.size() == 0 || 
      std::find(ebNames.begin(), ebNames.end(), workset.EBName) != ebNames.end() ) {

    ScalarT s;
    for (std::size_t cell=0; cell < workset.numCells; ++cell) {

      bool cellInBox = false;
      for (std::size_t qp=0; qp < numQPs; ++qp) {
        if( (!limitX || (coordVec(cell,qp,0) >= xmin && coordVec(cell,qp,0) <= xmax)) &&
            (!limitY || (coordVec(cell,qp,1) >= ymin && coordVec(cell,qp,1) <= ymax)) &&
            (!limitZ || (coordVec(cell,qp,2) >= zmin && coordVec(cell,qp,2) <= zmax)) ) {
          cellInBox = true; break; }
      }
      if( !cellInBox ) continue;

      for (std::size_t qp=0; qp < numQPs; ++qp) {
	if (field_rank == 2) {
	  s = field(cell,qp) * weights(cell,qp) * scaling;
	  this->local_response(cell) += s;
	  this->global_response(0) += s;
	}
	else if (field_rank == 3) {
	  for (std::size_t dim=0; dim < field_components.size(); ++dim) {
	    s = field(cell,qp,field_components[dim]) * weights(cell,qp) * scaling;
	    this->local_response(cell,dim) += s;
	    this->global_response(dim) += s;
	  }
	}
	else if (field_rank == 4) {
	  for (std::size_t dim1=0; dim1 < field_dims[2]; ++dim1) {
	    for (std::size_t dim2=0; dim2 < field_dims[3]; ++dim2) {
	      s = field(cell,qp,dim1,dim2) * weights(cell,qp) * scaling;
	      this->local_response(cell,dim1,dim2) += s;
	      this->global_response(dim1,dim2) += s;
	    }
	  }
	}
      }
    }
  }

  // Do any local-scattering necessary
  PHAL::SeparableScatterScalarResponseT<EvalT,Traits>::evaluateFields(workset);
}
Пример #17
0
void PointSource<EvalT,Traits>::evaluateFields(typename Traits::EvalData workset)
{
  const RealType time  = workset.current_time;
  for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
    for (std::size_t iqp=0; iqp<m_num_qp; iqp++) {
      std::vector<MeshScalarT> coord;
      for (std::size_t i=0; i<m_num_dim; ++i) {
        const MeshScalarT  x  = coordVec(cell,iqp,i);
        coord.push_back(x);
      }
      //ScalarT &p_s = m_pressure_source(cell,iqp);
      m_pressure_source(cell,iqp) = 0;
      const RealType wavelet = m_wavelet->evaluateFields(time);
      for (std::size_t i=0; i<m_spatials.size(); ++i) {
        const MeshScalarT spatial = m_spatials[i]->evaluateFields(coord);
        m_pressure_source(cell,iqp) += wavelet*spatial;
      }
    }
  }
}
void EquivalentInclusionConductivity<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  int numCells = workset.numCells;

  if (is_constant) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
    	  effectiveK(cell,qp) = constant_value;
      }
    }
  }
#ifdef ALBANY_STOKHOS
  else {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (int i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
	effectiveK(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
#endif


  if (isPoroElastic) {
      for (int cell=0; cell < numCells; ++cell) {
        for (int qp=0; qp < numQPs; ++qp) {
        	effectiveK(cell,qp) = porosity(cell,qp)*condKf +
        			              (J(cell,qp)-porosity(cell,qp))*condKs;
       // 	effectiveK(cell,qp) = condKf
       //  	                + ( J(cell,qp) - porosity(cell,qp))*
        //			              (condKs - condKf)*condKf/
        //			              ((condKs - condKf)*porosity(cell,qp)
        //			            	+ J(cell,qp)*condKf);
        }
      }
    }

}
Пример #19
0
void ElasticModulus<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
    int numCells = workset.numCells;

    if (is_constant) {
        for (int cell=0; cell < numCells; ++cell) {
            for (int qp=0; qp < numQPs; ++qp) {
                elasticModulus(cell,qp) = constant_value;
            }
        }
    }
    else {
        for (int cell=0; cell < numCells; ++cell) {
            for (int qp=0; qp < numQPs; ++qp) {
                Teuchos::Array<MeshScalarT> point(numDims);
                for (int i=0; i<numDims; i++)
                    point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
                elasticModulus(cell,qp) = exp_rf_kl->evaluate(point, rv);
            }
        }
    }
    if (isThermoElastic) {
        for (int cell=0; cell < numCells; ++cell) {
            for (int qp=0; qp < numQPs; ++qp) {
                elasticModulus(cell,qp) += dEdT_value * (Temperature(cell,qp) - refTemp);
            }
        }
    }
    if (isPoroElastic) {
        for (int cell=0; cell < numCells; ++cell) {
            for (int qp=0; qp < numQPs; ++qp) {
                // porosity dependent Young's Modulus. It will be replaced by
                // the hyperelasticity model in (Borja, Tamagnini and Amorosi, ASCE JGGE 1997).
                elasticModulus(cell,qp) = constant_value;
// 			*sqrt(2.0 - porosity(cell,qp));
            }
        }
    }
}
Пример #20
0
bool QCAD::MeshRegion<EvalT, Traits>::
cellIsInRegion(std::size_t cell)
{
  //Check that cell lies *entirely* in box
  for (std::size_t qp=0; qp < numQPs; ++qp) {
    if( (limitX && (coordVec(cell,qp,0) < xmin || coordVec(cell,qp,0) > xmax)) ||
	(limitY && (coordVec(cell,qp,1) < ymin || coordVec(cell,qp,1) > ymax)) ||
	(limitZ && (coordVec(cell,qp,2) < zmin || coordVec(cell,qp,2) > zmax)) )
      return false;

    if(bRestrictToXYPolygon) {
      MeshScalarT pt[2]; //code below only works when MeshScalarT == double.  Need to generalize for other cases.
      pt[0] = coordVec(cell,qp,0);
      pt[1] = coordVec(cell,qp,1);
      if( !QCAD::ptInPolygon(xyPolygon, pt) ) return false;
    }
  }

  if(bRestrictToLevelSet) {
    for (std::size_t qp=0; qp < numQPs; ++qp) {

      // Get the average value for the cell (integral of field over cell divided by cell volume)
      ScalarT cellVol = 0.0, avgCellVal = 0.0;;
      for (std::size_t qp=0; qp < numQPs; ++qp) {
	avgCellVal += levelSetField(cell,qp) * weights(cell,qp);
	cellVol += weights(cell,qp);
      }
      avgCellVal /= cellVol;
      
      if( avgCellVal > levelSetFieldMax || avgCellVal < levelSetFieldMin)
	return false;
    }
  }	
	 
  return true;
}
Пример #21
0
void VanGenuchtenSaturation<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{

  ScalarT tempTerm;
  std::size_t numCells = workset.numCells;

  if (is_constant) {
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
    	  vgSaturation(cell,qp) = constant_value;
      }
    }
  }
  else {
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (std::size_t i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
		  vgSaturation(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
  if (isPoroElastic) {
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
    	  // van Genuchten equation
    	  vgSaturation(cell,qp) = 0.084 + 0.916
    			       /std::pow((1.0 + 7.0*porePressure(cell,qp)/waterUnitWeight),2.0);


      }
    }
  }
}
void XZScalarAdvectionResid<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  std::vector<ScalarT> vel(2);
  for (std::size_t i=0; i < Residual.size(); ++i) Residual(i)=0.0;

  for (std::size_t cell=0; cell < workset.numCells; ++cell) {
    for (std::size_t qp=0; qp < numQPs; ++qp) {
  
      if (coordVec(cell,qp,1) > 0.5) vel[0] = Re;
      else                           vel[0] = 0.0;
      vel[1] = 0.0;

      for (std::size_t node=0; node < numNodes; ++node) {
          // Transient Term
          Residual(cell,node) += rhoDot(cell,qp)*wBF(cell,node,qp);
          // Advection Term
          for (std::size_t j=0; j < numDims; ++j) {
            Residual(cell,node) += vel[j]*rhoGrad(cell,qp,j)*wBF(cell,node,qp);
          }
      }
    }
  }
}
void GatherCoordinateVector<EvalT, Traits>::evaluateFields(typename Traits::EvalData workset)
{ 
  unsigned int numCells = workset.numCells;
  Teuchos::ArrayRCP<Teuchos::ArrayRCP<double*> > wsCoords = workset.wsCoords;

#ifndef ALBANY_KOKKOS_UNDER_DEVELOPMENT
  if( dispVecName.is_null() ){
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t node = 0; node < numVertices; ++node) {
        for (std::size_t eq=0; eq < numDim; ++eq) { 
          coordVec(cell,node,eq) = wsCoords[cell][node][eq]; 
        }
      }
    }

    // Since Intrepid2 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 calculations on singular elements.
    for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
      for (std::size_t node = 0; node < numVertices; ++node) {
        for (std::size_t eq=0; eq < numDim; ++eq) { 
          coordVec(cell,node,eq) = coordVec(0,node,eq); 
        }
      }
    }
  } else {
    Albany::StateArray::const_iterator it;
    it = workset.stateArrayPtr->find(*dispVecName);

    TEUCHOS_TEST_FOR_EXCEPTION((it == workset.stateArrayPtr->end()), std::logic_error,
           std::endl << "Error: cannot locate " << *dispVecName << " in PHAL_GatherCoordinateVector_Def" << std::endl);

    Albany::MDArray dVec = it->second;

    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t node = 0; node < numVertices; ++node) {
        for (std::size_t eq=0; eq < numDim; ++eq) { 
          coordVec(cell,node,eq) = wsCoords[cell][node][eq] + dVec(cell,node,eq);
        }
      }
    }

    // Since Intrepid2 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 calculations on singular elements.
    for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
      for (std::size_t node = 0; node < numVertices; ++node) {
        for (std::size_t eq=0; eq < numDim; ++eq) { 
          coordVec(cell,node,eq) = coordVec(0,node,eq) + dVec(cell,node,eq);
        }
      }
    }
  }
#else
 typedef Kokkos::View<MeshScalarT***,PHX::Device> view_type;
 typedef typename view_type::HostMirror host_view_type;
  
 host_view_type coordVecHost = Kokkos::create_mirror_view (coordVec.get_kokkos_view());

  if( dispVecName.is_null() ){
    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t node = 0; node < numVertices; ++node) {
        for (std::size_t eq=0; eq < numDim; ++eq) {
          coordVecHost(cell,node,eq) = wsCoords[cell][node][eq];
        }
      }
    }

    for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
      for (std::size_t node = 0; node < numVertices; ++node) {
        for (std::size_t eq=0; eq < numDim; ++eq) {
          coordVecHost(cell,node,eq) = coordVecHost(0,node,eq);
        }
      }
    }
  } else {
    Albany::StateArray::const_iterator it;
    it = workset.stateArrayPtr->find(*dispVecName);

    TEUCHOS_TEST_FOR_EXCEPTION((it == workset.stateArrayPtr->end()), std::logic_error,
           std::endl << "Error: cannot locate " << *dispVecName << " in PHAL_GatherCoordinateVector_Def" << std::endl);

    Albany::MDArray dVec = it->second;

    for (std::size_t cell=0; cell < numCells; ++cell) {
      for (std::size_t node = 0; node < numVertices; ++node) {
        for (std::size_t eq=0; eq < numDim; ++eq) {
          coordVecHost(cell,node,eq) = wsCoords[cell][node][eq] + dVec(cell,node,eq);
        }
      }
    }
   for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
      for (std::size_t node = 0; node < numVertices; ++node) {
        for (std::size_t eq=0; eq < numDim; ++eq) {
          coordVecHost(cell,node,eq) = coordVecHost(0,node,eq) + dVec(cell,node,eq);
        }
      }
    }
  } 
  Kokkos::deep_copy (coordVec.get_kokkos_view(), coordVecHost);

#endif
}
void ViscosityL1L2<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  if (visc_type == CONSTANT){
    for (std::size_t cell=0; cell < workset.numCells; ++cell) {
      for (std::size_t qp=0; qp < numQPs; ++qp) {
        mu(cell,qp) = 1.0; 
      }
    }
  }
  else if (visc_type == GLENSLAW) {
    if (n == 1.0) {
      for (std::size_t cell=0; cell < workset.numCells; ++cell) {
        for (std::size_t qp=0; qp < numQPs; ++qp) {
          mu(cell,qp) = 1.0/A; 
        }
      }
    }
    else if (n == 3.0) {
      if (surf_type == BOX) {
        if (homotopyParam == 0.0) {
          for (std::size_t cell=0; cell < workset.numCells; ++cell) {
            for (std::size_t qp=0; qp < numQPs; ++qp) {
              mu(cell,qp) = pow(A, -1.0/3.0);
           }
         }
       }
        else {
          ScalarT ff = pow(10.0, -10.0*homotopyParam);
          for (std::size_t cell=0; cell < workset.numCells; ++cell) {
            for (std::size_t qp=0; qp < numQPs; ++qp) {
               mu(cell,qp) = epsilonB(cell,qp) + ff; 
               mu(cell,qp) = sqrt(mu(cell,qp)); 
               mu(cell,qp) = pow(A, -1.0/3.0)*pow(mu(cell,qp), -2.0/3.0); 
            }
          }
        }
      }
      else if (surf_type == TESTA) { //ISMIP-HOM Test A
        PHX::MDField<ScalarT,Cell,QuadPoint> q;
        PHX::MDField<ScalarT,Cell,QuadPoint> w;
        PHX::MDField<ScalarT,Cell,QuadPoint> tauPar2;
        PHX::MDField<ScalarT,Cell,QuadPoint> Int;
        for (std::size_t cell=0; cell < workset.numCells; ++cell) {
          for (std::size_t qp=0; qp < numQPs; ++qp) {
             MeshScalarT x = coordVec(cell,qp,0);
             MeshScalarT y = coordVec(cell,qp,1);
             MeshScalarT s = -x*tan(alpha);
             MeshScalarT b = s - 1.0 + 0.5*sin(2.0*pi*x/L)*sin(2.0*pi*y/L);
             MeshScalarT dsdx = -tan(alpha);
             MeshScalarT dsdy = 0.0; 
             Int(cell,qp) = 0.0; 
             q(cell,qp) = 1.0/(2.0*A)*sqrt(epsilonB(cell,qp)); //TO DO: need to put in continuation here 
             for (std::size_t qpZ = 0; qp<numQPsZ; ++qpZ) { //apply Trapezoidal rule to compute integral in z
                MeshScalarT zQP = qpZ*(s-b)/(2.0*numQPsZ); 
                MeshScalarT tauPerp2 = rho*rho*g*g*(s-zQP)*(s-zQP)*(dsdx*dsdx + dsdy*dsdy); 
                MeshScalarT p = 1.0/3.0*tauPerp2;
                w(cell,qp) = pow(q(cell,qp) + sqrt(q(cell,qp)*q(cell,qp) + p*p*p), 1.0/3.0); 
                tauPar2(cell,qp) = (w(cell,qp)-p/(3.0*w(cell,qp)))*(w(cell,qp)-p/(3.0*w(cell,qp))); 
                Int(cell,qp) += 1.0/(tauPerp2 + tauPar2(cell,qp));  
             }
            mu(cell,qp) = 1.0/A*Int(cell,qp); 
          }
        }
      }
    }
  }
}
Пример #25
0
void QCAD::SchrodingerResid<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  typedef Intrepid::FunctionSpaceTools FST;
  bool bValidRegion = true;
  double invEffMass = 1.0; 

  if(bOnlyInQuantumBlocks)
    bValidRegion = materialDB->getElementBlockParam<bool>(workset.EBName,"quantum",false);
  
  // Put loops inside the if branches for speed
  if(bValidRegion)
  {
    if ( potentialType == "From State" || potentialType == "String Formula" || potentialType == "From Aux Data Vector")
    {
      if ( (numDims == 1) && (oxideWidth > 0.0) )   // 1D MOSCapacitor 
      {
        for (std::size_t cell = 0; cell < workset.numCells; ++cell) 
        { 
          for (std::size_t qp = 0; qp < numQPs; ++qp) 
          {
            invEffMass = hbar2_over_2m0 * getInvEffMass1DMosCap(&coordVec(cell,qp,0));
            for (std::size_t dim = 0; dim < numDims; ++dim)
              psiGradWithMass(cell,qp,dim) = invEffMass * psiGrad(cell,qp,dim);
          }  
        }    
      }
      
      // Effective mass depends on the wafer orientation and growth direction.
      // Assume SiO2/Si interface is parallel to the [100] plane and consider only the 
      // Delta2 Valleys whose principal axis is perpendicular to the SiO2/Si interface. 
      // (need to include Delta4-band for high temperatures > 50 K).

      else  // General case
      {
        double ml, mt;
        
        const std::string& matrlCategory = materialDB->getElementBlockParam<std::string>(workset.EBName,"Category","");

        // obtain ml and mt
        if (matrlCategory == "Semiconductor") 
        {
          const std::string& condBandMinVal = materialDB->getElementBlockParam<std::string>(workset.EBName,"Conduction Band Minimum");
          ml = materialDB->getElementBlockParam<double>(workset.EBName,"Longitudinal Electron Effective Mass");
          mt = materialDB->getElementBlockParam<double>(workset.EBName,"Transverse Electron Effective Mass");
    
          if ((condBandMinVal == "Gamma Valley") && (fabs(ml-mt) > 1e-10))
          {
            TEUCHOS_TEST_FOR_EXCEPTION (true, std::logic_error, "Gamma Valley's longitudinal and "
              << "transverse electron effective mass must be equal ! "
              << "Please check the values in materials.xml" << std::endl);
          }
        }      

        else if (matrlCategory == "Insulator")
        {
          ml = materialDB->getElementBlockParam<double>(workset.EBName,"Longitudinal Electron Effective Mass");
          mt = materialDB->getElementBlockParam<double>(workset.EBName,"Transverse Electron Effective Mass");
          if (fabs(ml-mt) > 1e-10) 
          {
            TEUCHOS_TEST_FOR_EXCEPTION (true, std::logic_error, "Insulator's longitudinal and "
              << "transverse electron effective mass must be equal ! "
              << "Please check the values in materials.xml" << std::endl);
	  }
	}

	else {
	  // Default releative effective masses == 1.0 if matrl category is not recognized.
	  // Perhaps we should throw an error here instead?
	  ml = mt = 1.0;
	}
	      
        // calculate psiGradWithMass (good for diagonal effective mass tensor !)
        for (std::size_t cell = 0; cell < workset.numCells; ++cell) 
        { 
          for (std::size_t qp = 0; qp < numQPs; ++qp) 
          {
            for (std::size_t dim = 0; dim < numDims; ++dim)
            {
              if (dim == numDims-1)
                invEffMass = hbar2_over_2m0 / ml;
              else
                invEffMass = hbar2_over_2m0 / mt;
              psiGradWithMass(cell,qp,dim) = invEffMass * psiGrad(cell,qp,dim);
            }  
          }  
        }    
	             
      }  // end of General case
      
    }  // end of if ( potentialType == "From State" || ... )


    // For potentialType == Finite Wall 
    else if ( potentialType == "Finite Wall" ) 
    {
      for (std::size_t cell = 0; cell < workset.numCells; ++cell) 
      { 
        for (std::size_t qp = 0; qp < numQPs; ++qp) 
        {
          invEffMass = hbar2_over_2m0 * getInvEffMassFiniteWall(&coordVec(cell,qp,0));
          for (std::size_t dim = 0; dim < numDims; ++dim)
            psiGradWithMass(cell,qp,dim) = invEffMass * psiGrad(cell,qp,dim);
        }  
      }    
    }  
    
    // For other potentialType
    else
    {
      for (std::size_t cell = 0; cell < workset.numCells; ++cell) 
        for (std::size_t qp = 0; qp < numQPs; ++qp) 
          for (std::size_t dim = 0; dim < numDims; ++dim)
            psiGradWithMass(cell,qp,dim) = hbar2_over_2m0 * psiGrad(cell,qp,dim);
    }    

    //Kinetic term: add integral( hbar^2/2m * Grad(psi) * Grad(BF)dV ) to residual
    FST::integrate<ScalarT>(psiResidual, psiGradWithMass, wGradBF, Intrepid::COMP_CPP, false); // "false" overwrites
  
    //Potential term: add integral( psi * V * BF dV ) to residual
    if (havePotential) {
      FST::scalarMultiplyDataData<ScalarT> (psiV, V, psi);
      FST::integrate<ScalarT>(psiResidual, psiV, wBF, Intrepid::COMP_CPP, true); // "true" sums into
    }

    //**Note: I think this should always be used with enableTransient = True
    //psiDot term (to use loca): add integral( psi_dot * BF dV ) to residual
    if (workset.transientTerms && enableTransient) 
      FST::integrate<ScalarT>(psiResidual, psiDot, wBF, Intrepid::COMP_CPP, true); // "true" sums into
      
  }  // end of if(bValidRegion)
  
  else 
  { 
    // Invalid region (don't perform calc here - evectors should all be zero)
    // So, set psiDot term to zero and set psi term (H) = Identity

    //This doesn't work - results in NaN error
    /*for (std::size_t cell=0; cell < workset.numCells; ++cell) 
    {
      for (std::size_t qp=0; qp < numQPs; ++qp)
        psiResidual(cell, qp) = 1.0*psi(cell,qp);
    }*/

    //Potential term: add integral( psi * V * BF dV ) to residual
    if (havePotential) 
    {
      for (std::size_t cell = 0; cell < workset.numCells; ++cell)
        for (std::size_t qp = 0; qp < numQPs; ++qp)
          V_barrier(cell,qp) = 100.0;
          
      FST::scalarMultiplyDataData<ScalarT> (psiV, V_barrier, psi);
      // FST::scalarMultiplyDataData<ScalarT> (psiV, V, psi);
      FST::integrate<ScalarT>(psiResidual, psiV, wBF, Intrepid::COMP_CPP, false); // "false" overwrites
    }


    //POSSIBLE NEW - same as valid region but use a very large potential...
    /*for (std::size_t cell = 0; cell < workset.numCells; ++cell)  {
      for (std::size_t qp = 0; qp < numQPs; ++qp) {

	V_barrier(cell,qp) = 1e+10;

	for (std::size_t dim = 0; dim < numDims; ++dim)
	  psiGradWithMass(cell,qp,dim) = hbar2_over_2m0 * psiGrad(cell,qp,dim);
      }
    }

    //Kinetic term: add integral( hbar^2/2m * Grad(psi) * Grad(BF)dV ) to residual
    FST::integrate<ScalarT>(psiResidual, psiGradWithMass, wGradBF, Intrepid::COMP_CPP, false); // "false" overwrites
  
    //Potential term: add integral( psi * V * BF dV ) to residual
    FST::scalarMultiplyDataData<ScalarT> (psiV, V_barrier, psi);
    //FST::scalarMultiplyDataData<ScalarT> (psiV, V, psi);
    FST::integrate<ScalarT>(psiResidual, psiV, wBF, Intrepid::COMP_CPP, true); // "true" sums into

    // **Note: I think this should always be used with enableTransient = True
    //psiDot term (to use loca): add integral( psi_dot * BF dV ) to residual
    if (workset.transientTerms && enableTransient) 
      FST::integrate<ScalarT>(psiResidual, psiDot, wBF, Intrepid::COMP_CPP, true); // "true" sums into
    */
  }
}
Пример #26
0
void QCAD::ResponseFieldValue<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  ScalarT opVal, qpVal, cellVol;

  if(!opRegion->elementBlockIsInRegion(workset.EBName))
    return;

  for (std::size_t cell=0; cell < workset.numCells; ++cell)
  {
    if(!opRegion->cellIsInRegion(cell)) continue;

    // Get the cell volume, used for averaging over a cell
    cellVol = 0.0;
    for (std::size_t qp=0; qp < numQPs; ++qp)
      cellVol += weights(cell,qp);

    // Get the scalar value of the field being operated on which will be used
    //  in the operation (all operations just deal with scalar data so far)
    opVal = 0.0;
    for (std::size_t qp=0; qp < numQPs; ++qp) {
      qpVal = 0.0;
      if(bOpFieldIsVector) {
        if(opX) qpVal += opField(cell,qp,0) * opField(cell,qp,0);
        if(opY) qpVal += opField(cell,qp,1) * opField(cell,qp,1);
        if(opZ) qpVal += opField(cell,qp,2) * opField(cell,qp,2);
      }
      else qpVal = opField(cell,qp);
      opVal += qpVal * weights(cell,qp);
    }
    opVal /= cellVol;
    // opVal = the average value of the field operated on over the current cell


    // Check if the currently stored min/max value needs to be updated
    if( (operation == "Maximize" && opVal > this->global_response[1]) ||
        (operation == "Minimize" && opVal < this->global_response[1]) ) {
      max_nodeID = workset.wsElNodeEqID[cell];

      // set g[0] = value of return field at the current cell (avg)
      this->global_response[0]=0.0;
      if(bReturnOpField) {
        for (std::size_t qp=0; qp < numQPs; ++qp) {
          qpVal = 0.0;
          if(bOpFieldIsVector) {
            for(std::size_t i=0; i<numDims; i++) {
              qpVal += opField(cell,qp,i)*opField(cell,qp,i);
            }
          }
          else qpVal = opField(cell,qp);
          this->global_response[0] += qpVal * weights(cell,qp);
        }
      }
      else {
        for (std::size_t qp=0; qp < numQPs; ++qp) {
          qpVal = 0.0;
          if(bRetFieldIsVector) {
            for(std::size_t i=0; i<numDims; i++) {
              qpVal += retField(cell,qp,i)*retField(cell,qp,i);
            }
          }
          else qpVal = retField(cell,qp);
          this->global_response[0] += qpVal * weights(cell,qp);
        }
      }
      this->global_response[0] /= cellVol;

      // set g[1] = value of the field operated on at the current cell (avg)
      this->global_response[1] = opVal;

      // set g[2+] = average qp coordinate values of the current cell
      for(std::size_t i=0; i<numDims; i++) {
        this->global_response[i+2] = 0.0;
        for (std::size_t qp=0; qp < numQPs; ++qp)
          this->global_response[i+2] += coordVec(cell,qp,i);
        this->global_response[i+2] /= numQPs;
      }
    }

  } // end of loop over cells

  // No local scattering
}
Пример #27
0
void YieldStrength<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  bool print = false;
  //if (typeid(ScalarT) == typeid(RealType)) print = true;

  if (print)
    std::cout << " *** YieldStrength *** " << std::endl;

  int numCells = workset.numCells;

  if (is_constant) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	yieldStrength(cell,qp) = constant_value;
      }
    }
  }
  else {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	Teuchos::Array<MeshScalarT> point(numDims);
	for (int i=0; i<numDims; i++)
	  point[i] = Sacado::ScalarValue<MeshScalarT>::eval(coordVec(cell,qp,i));
	yieldStrength(cell,qp) = exp_rf_kl->evaluate(point, rv);
      }
    }
  }
  if (isThermoElastic) {
    for (int cell=0; cell < numCells; ++cell) {
      for (int qp=0; qp < numQPs; ++qp) {
	yieldStrength(cell,qp) -= dYdT_value * (Temperature(cell,qp) - refTemp);

        if (print)
        {
          std::cout << "    Y   : " << yieldStrength(cell,qp) << std::endl;
          std::cout << "    temp: " << Temperature(cell,qp) << std::endl;
          std::cout << "    dYdT: " << dYdT_value << std::endl;
          std::cout << "    refT: " << refTemp << std::endl;
        }
      }
    }
  }
  if (isDiffuseDeformation) {

	  Albany::MDArray CLold   = (*workset.stateArrayPtr)[CLname];

      for (int cell=0; cell < numCells; ++cell) {
        for (int qp=0; qp < numQPs; ++qp) {
 //       	yieldStrength(cell,qp) = constant_value*( 1.0 + (zeta-1.0)*CL(cell,qp)   );
        	yieldStrength(cell,qp) -= constant_value*(zeta-1.0)*(CL(cell,qp) -CLold(cell,qp)  );

          if (print)
          {
            std::cout << "    Y   : " << yieldStrength(cell,qp) << std::endl;
            std::cout << "    CT  : " << CT(cell,qp) << std::endl;
            std::cout << "   zeta : " << zeta << std::endl;
          }
        }
      }
    }
}
Пример #28
0
void ViscosityFO<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  double a = 1.0;  
  switch (visc_type) {
    case CONSTANT: 
      for (std::size_t cell=0; cell < workset.numCells; ++cell) {
        for (std::size_t qp=0; qp < numQPs; ++qp) 
          mu(cell,qp) = 1.0; 
      }
      break; 
    case EXPTRIG:  
      for (std::size_t cell=0; cell < workset.numCells; ++cell) {
        for (std::size_t qp=0; qp < numQPs; ++qp) {
          MeshScalarT x = coordVec(cell,qp,0);
          MeshScalarT y2pi = 2.0*pi*coordVec(cell,qp,1);
          MeshScalarT muargt = (a*a + 4.0*pi*pi - 2.0*pi*a)*sin(y2pi)*sin(y2pi) + 1.0/4.0*(2.0*pi+a)*(2.0*pi+a)*cos(y2pi)*cos(y2pi); 
          muargt = sqrt(muargt)*exp(a*x);  
          mu(cell,qp) = 1.0/2.0*pow(A, -1.0/n)*pow(muargt, 1.0/n - 1.0); 
        }
      }
      break; 
    case GLENSLAW: 
      std::vector<ScalarT> flowFactorVec; //create vector of the flow factor A at each cell 
      flowFactorVec.resize(workset.numCells);
      switch (flowRate_type) {
        case UNIFORM: 
          for (std::size_t cell=0; cell < workset.numCells; ++cell) 
            flowFactorVec[cell] = 1.0/2.0*pow(A, -1.0/n);
          break; 
        case TEMPERATUREBASED:
          for (std::size_t cell=0; cell < workset.numCells; ++cell) 
	    flowFactorVec[cell] = 1.0/2.0*pow(flowRate(temperature(cell)), -1.0/n);
          break;
        case FROMFILE:
        case FROMCISM: 
          for (std::size_t cell=0; cell < workset.numCells; ++cell)  
	    flowFactorVec[cell] = 1.0/2.0*pow(flowFactorA(cell), -1.0/n);
          break;
      }
      double power = 0.5*(1.0/n - 1.0);
      if (homotopyParam == 0.0) { //set constant viscosity
        for (std::size_t cell=0; cell < workset.numCells; ++cell) {
          for (std::size_t qp=0; qp < numQPs; ++qp) {
            mu(cell,qp) = flowFactorVec[cell]; 
          }
        }
      }
      else { //set Glen's law viscosity with regularization specified by homotopyParam
        ScalarT ff = pow(10.0, -10.0*homotopyParam);
        ScalarT epsilonEqpSq = 0.0; //used to define the viscosity in non-linear Stokes 
        for (std::size_t cell=0; cell < workset.numCells; ++cell) {
          for (std::size_t qp=0; qp < numQPs; ++qp) {
            //evaluate non-linear viscosity, given by Glen's law, at quadrature points
            ScalarT& u00 = Ugrad(cell,qp,0,0); //epsilon_xx
            ScalarT& u11 = Ugrad(cell,qp,1,1); //epsilon_yy
            epsilonEqpSq = u00*u00 + u11*u11 + u00*u11; //epsilon_xx^2 + epsilon_yy^2 + epsilon_xx*epsilon_yy
            epsilonEqpSq += 0.25*(Ugrad(cell,qp,0,1) + Ugrad(cell,qp,1,0))*(Ugrad(cell,qp,0,1) + Ugrad(cell,qp,1,0)); //+0.25*epsilon_xy^2
            for (int dim = 2; dim < numDims; ++dim) //3D case
               epsilonEqpSq += 0.25*(Ugrad(cell,qp,0,dim)*Ugrad(cell,qp,0,dim) + Ugrad(cell,qp,1,dim)*Ugrad(cell,qp,1,dim) ); // + 0.25*epsilon_xz^2 + 0.25*epsilon_yz^2
            epsilonEqpSq += ff; //add regularization "fudge factor" 
            mu(cell,qp) = flowFactorVec[cell]*pow(epsilonEqpSq,  power); //non-linear viscosity, given by Glen's law  
           }
         }
      }
      break;
}
}