// duct.cpp // // last-edit-by: J.A. de Jong // // Description: // ////////////////////////////////////////////////////////////////////// #include "duct.h" #include "tasystem.h" #include "tasmet_assert.h" #include "tasmet_evalscript.h" #include "perfectgas.h" Duct::Duct(const us id,const pb::Duct& ductpb): Segment(id,ductpb.name()), Geom(ductpb), _ductpb(ductpb) { TRACE(15,"Duct::Duct()"); const char* invTsfun = "Invalid solid-temperature prescribing function"; EvaluateFun Tsfun(ductpb.stempfunc(),invTsfun); Tsfun.addGlobalDef("L",ductpb.length()); _Tsprescribed = Tsfun(x); if(min(_Tsprescribed) < constants::min_T0 || max(_Tsprescribed) > constants::max_T0) { throw TaSMETError(invTsfun); } switch (ductpb.htmodel()) { case pb::Isentropic: { break; } default: tasmet_assert(false,"Invalid heat transfer model"); break; } } Duct::Duct(const Duct& other): Segment(other), Geom(other), _ductpb(other._ductpb), _Tsprescribed(other._Tsprescribed) { // Do something with the equations here TRACE(15,"Duct::~Duct"); } Duct* Duct::copy() const { return new Duct(*this); } Duct::~Duct() { TRACE(15,"Duct::~Duct"); // for(Equation* eq: _eqs){ // delete eq; // } } void Duct::residual(const TaSystem& sys,arma::subview_col && residual) const { TRACE(15,"Duct::residual()"); const arma::subview_col sol = sys.getSolution(_id); vd rho,u,T,p,Ts; // Solution at this gp vd rhop,up,Tp,pp,Tsp; // Solution at next gp // Continuity eq residual, momentum, energy, state, solid energy vd cont,mom,en,st,sen; // When we have to solve a solid heat balance bool has_solideq = _ductpb.stempmodel() == pb::HeatBalance; us number_eqs = 4; number_eqs += (has_solideq) ? 1 : 0; VARTRACE(15,number_eqs); us Ns = sys.Ns(); us eq_offset = 0; // Equation offset for current gp us res_offset = 0; // Residual offset for current gp us res_offsetp = 0; // Residual offset for next gp us gp_jump = number_eqs * Ns; // The jump per gp rhop = getvart(sys,constants::rho,0); up = getvart(sys,constants::u,0); Tp = getvart(sys,constants::T,0); pp = getvart(sys,constants::p,0); const Gas& gas = sys.gas(); for(us gp=0;gp sol = sys.getSolution(_id); us Ns = sys.Ns(); // Wraparound if(gp<0) gp+=ngp(); us vars_per_gp = 4; vars_per_gp+= (_ductpb.stempmodel() == pb::HeatBalance ? 1 : 0); return sol.subvec((gp*vars_per_gp+varnr)*Ns, (gp*vars_per_gp+varnr+1)*Ns-1); } vd Duct::getvarx(const TaSystem& sys,int varnr,int t) const { vd res(ngp()); for(us i=0;i