Beispiel #1
0
void PhaseResidual<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
 
  typedef Intrepid::FunctionSpaceTools FST;
  FST::scalarMultiplyDataData<ScalarT> (term1_,k_,T_grad_);
  FST::integrate<ScalarT>(residual_,term1_,w_grad_bf_,Intrepid::COMP_CPP,false);
  FST::scalarMultiplyDataData<ScalarT> (term2_,rho_cp_,T_dot_);
  FST::integrate<ScalarT>(residual_,term2_,w_bf_,Intrepid::COMP_CPP,true);
  for (int i=0; i<source_.size(); ++i)
    source_[i] *= -1.0;
  FST::integrate<ScalarT>(residual_,source_,w_bf_,Intrepid::COMP_CPP,true);
  for (int i=0; i<laser_source_.size(); ++i)
    laser_source_[i] *= -1.0;
  FST::integrate<ScalarT>(residual_,laser_source_,w_bf_,Intrepid::COMP_CPP,true);  

/*
 std::cout<<"rho Cp values"<<std::endl;
 for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
    for (std::size_t qp = 0; qp < num_qps_; ++qp) {
            std::cout<<rho_cp_(cell,qp)<<" ";  
         }
     std::cout<<std::endl;
     }

  std::cout<<"Thermal cond values"<<std::endl;
   for (std::size_t cell = 0; cell < workset.numCells; ++cell) {          
      for (std::size_t qp = 0; qp < num_qps_; ++qp) {
              std::cout<<k_(cell,qp)<<" ";
          }
      std::cout<<std::endl;
      }
       
        
*/

//----------------------------
#if 0
  for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
    for (std::size_t qp = 0; qp < num_qps_; ++qp) {
      term2_(cell,qp) = rho_cp_(cell,qp)*T_dot_(cell,qp);  
    }
  }
#endif

//  no rho_cp_ term - equivalent to heat problem
//  FST::integrate<ScalarT>(residual_,T_dot_,w_bf_,Intrepid::COMP_CPP,true);
 
#if 0
  // temperature residual
  for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
    for (std::size_t node = 0; node < num_nodes_; ++node) {
      residual_(cell,node) = 0.0;
    }
    for (std::size_t qp = 0; qp < num_qps_; ++qp) {
      for (std::size_t node = 0; node < num_nodes_; ++node) {
        for (std::size_t i = 0; i < num_dims_; ++i) {
          residual_(cell,node) +=
            k_(cell,qp) * T_grad_(cell,qp,i) * w_grad_bf_(cell,node,qp,i) +
            rho_cp_(cell,qp) * T_dot_(cell,qp) * w_bf_(cell,node,qp);
        }
      }
    }
  }

  // source function
  for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
    for (std::size_t qp = 0; qp < num_qps_; ++qp) {
      for (std::size_t node = 0; node < num_nodes_; ++node) {
        residual_(cell,node) -=
         source_(cell,qp) * w_bf_(cell,node,qp);
      }
    }
  }
#endif

}
Beispiel #2
0
  void PhaseResidual<EvalT, Traits>::
  evaluateFields(typename Traits::EvalData workset)
  {
    // time step
    ScalarT dt = deltaTime(0);
    typedef Intrepid2::FunctionSpaceTools<PHX::Device> FST;

    if (dt == 0.0) dt = 1.0e-15;
    //grab old temperature
    Albany::MDArray T_old = (*workset.stateArrayPtr)[Temperature_Name_];
    
    // Compute Temp rate
    for (std::size_t cell = 0; cell < workset.numCells; ++cell)
      {
        for (std::size_t qp = 0; qp < num_qps_; ++qp)
	  {
            T_dot_(cell, qp) = (T_(cell, qp) - T_old(cell, qp)) / dt;
	  }
      }

    // diffusive term
    FST::scalarMultiplyDataData<ScalarT> (term1_, k_.get_view(), T_grad_.get_view());
    // FST::integrate(residual_, term1_, w_grad_bf_, false);
    //Using for loop to calculate the residual 

    
    // zero out residual
    for (int cell = 0; cell < workset.numCells; ++cell) {
      for (int node = 0; node < num_nodes_; ++node) {
        residual_(cell,node) = 0.0;
      }
    }

    //    for (int cell = 0; cell < workset.numCells; ++cell) {
    //      for (int qp = 0; qp < num_qps_; ++qp) {
    //        for (int node = 0; node < num_nodes_; ++node) {
    //          for (int i = 0; i < num_dims_; ++i) {
    //             residual_(cell,node) += w_grad_bf_(cell,node,qp,i) * term1_(cell,qp,i);
    //          }
    //        }
    //      }
    //    }

    //THESE ARE HARD CODED NOW. NEEDS TO BE CHANGED TO USER INPUT LATER
    ScalarT Coeff_volExp = 65.2e-6; //per kelvins
    ScalarT Ini_temp = 300; //kelvins
   
    if (hasConsolidation_) {
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    //Use if consolidation and expansion is considered
	    //  porosity_function1 = pow(	((1.0 - porosity_(cell, qp)) / ((1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity))), 2);
	    //  porosity_function2 = (1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
	                    
	    //Use if only consolidation is considered
	    porosity_function1 = pow(	((1.0 - porosity_(cell, qp)) / (1.0 - Initial_porosity)), 2);
	    porosity_function2 = (1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));					
												
	    //In the model that is currently used, the Z-axis corresponds to the depth direction. Hence the term porosity
	    //function1 is multiplied with the second term. 
	    residual_(cell, node) += porosity_function2 * (
							   w_grad_bf_(cell, node, qp, 0) * term1_(cell, qp, 0)
							   + w_grad_bf_(cell, node, qp, 1) * term1_(cell, qp, 1)
							   + porosity_function1 * w_grad_bf_(cell, node, qp, 2) * term1_(cell, qp, 2));
	  }
	}
      }

      // heat source from laser 
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    //Use if consolidation and expansion is considered
	    //  porosity_function2 = (1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    //Use if only consolidation is considered
	    porosity_function2 = (1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));

	    residual_(cell, node) -= porosity_function2 * (w_bf_(cell, node, qp) * laser_source_(cell, qp));
	  }
	}
      }

      // all other problem sources
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    //Use if consolidation and expansion is considered
	    //  porosity_function2 = (1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    //Use if only consolidation is considered
	    porosity_function2 = (1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    residual_(cell, node) -= porosity_function2 * (w_bf_(cell, node, qp) * source_(cell, qp));
	  }
	}
      }

      // transient term
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    //Use if consolidation and expansion is considered
	    //  porosity_function2 = (1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    //Use if only consolidation is considered
	    porosity_function2 = (1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    residual_(cell, node) += porosity_function2 * (w_bf_(cell, node, qp) * energyDot_(cell, qp));
	  }
	}
      }
    } else { // does not have consolidation
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    residual_(cell, node) += (
				      w_grad_bf_(cell, node, qp, 0) * term1_(cell, qp, 0)
				      + w_grad_bf_(cell, node, qp, 1) * term1_(cell, qp, 1)
				      + w_grad_bf_(cell, node, qp, 2) * term1_(cell, qp, 2));
	  }
	}
      }
      // heat source from laser 
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    residual_(cell, node) -= (w_bf_(cell, node, qp) * laser_source_(cell, qp));
	  }
	}
      }
      // all other problem sources
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    residual_(cell, node) -= (w_bf_(cell, node, qp) * source_(cell, qp));
	  }
	}
      }
      // transient term
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    residual_(cell, node) += (w_bf_(cell, node, qp) * energyDot_(cell, qp));
	  }
	}
      }
    }
         
    // heat source from laser 
    //PHAL::scale(laser_source_, -1.0);
    //FST::integrate(residual_, laser_source_, w_bf_, true);

    // all other problem sources
    //PHAL::scale(source_, -1.0);
    //FST::integrate(residual_, source_, w_bf_, true);

    // transient term
    //FST::integrate(residual_, energyDot_, w_bf_, true);
  }