double calc_integral(Range* distance) { double result = 0; for(double i = distance->start; i < distance->end; i += distance->step) { result += (function_value(i) + function_value(i + distance->step))\ / 2 * distance->step; } return result; }
/** * Auxiliary Kernels override computeValue() instead of computeQpResidual(). Aux Variables * are calculated either one per elemenet or one per node depending on whether we declare * them as "Elemental (Constant Monomial)" or "Nodal (First Lagrange)". No changes to the * source are necessary to switch from one type or the other. */ Real CoolantChannelAux::computeValue() { //integral power distribution function value std::vector<Real> axial_height(_axial_layeredvalue+1); std::vector<Real> function_value(_axial_layeredvalue); std::vector<Real> integral_value(_axial_layeredvalue+1); Point p1; p1(0)=0.0; p1(1)=0.0; p1(2)=0.0; /* 0----1----2----3 axial_height 0----1---2 function_value */ axial_height[0] = 0.0; integral_value[0] = 0.0; axial_height[_axial_layeredvalue] = _total_pellet_height; double step=_total_pellet_height/_axial_layeredvalue; p1(2)=0.5*step; function_value[0]=_Axial_Power_Dis.value(_t,p1); p1(2)=0.0; function_value[0]=_Axial_Power_Dis.value(_t,p1); // for(unsigned int i=1;i<=_axial_layeredvalue-1;++i) { axial_height[i]=axial_height[i-1]+step; p1(2)=p1(2)+step; function_value[i]=_Axial_Power_Dis.value(_t,p1); integral_value[i] = integral_value[i-1]+function_value[i-1]*step; } integral_value[_axial_layeredvalue]=integral_value[_axial_layeredvalue-1]+function_value[_axial_layeredvalue-1]*step; _coolant_temp.setData(axial_height,integral_value); if (isNodal()) mooseError("error!NOT nodal,should be monomial and constant "); else if(_dimension=="2D") //2D default axial direction is Y. return _coolant_temp.sample(_q_point[_qp](1))/_coef/_coolant_heatcapacity[_qp]/_coolant_density[_qp]+_inlet_temp; else //3D default axial direction is Z. return _coolant_temp.sample(_q_point[_qp](2))/_coef/_coolant_heatcapacity[_qp]/_coolant_density[_qp]+_inlet_temp; }