示例#1
0
int reversibly_expand_q_and_rho_to_given_P(np_t np, gl_t *gl, double Pstarc, double *qc, double *rhoc,
           long numsteps, double q_min){
  argfpot_t arg;
  double Tc;
  long error;
  int retval;

  find_w(np,arg.w1);
  arg.R=_R(arg.w1);
  arg.q1=_q(np);
  arg.k1=_k(np);
  arg.h1=_h_from_w_T(arg.w1,_T(np,gl));
  /* if the desired back pressure is more than the flow stagnation pressure,
     it is not possible to integrate; for robustness, first check
     if the stagnation pressure of the flow is greater than the back
     pressure. If not, then neglect this streamline. */
  if (_Pstag(np,gl,numsteps)>Pstarc) {
    *qc=EXM_numerical_differentiation(&_qcnew_funct, &arg, EXM_NUMDIFF_MODIFIEDEULER,
                  numsteps, max(q_min,_q(np)), _Pstar(np,gl), Pstarc, &error);
    Tc=_T_from_w_h(arg.w1, -sqr(*qc)/2.0+arg.h1+sqr(arg.q1)/2.0);
    if (Tc<1.0 || Tc>60000.0) wfprintf(stderr,"big problem here..Tc=%E\n",Tc);
    *rhoc=Pstarc/(arg.R*Tc+2.0/3.0*arg.k1);
    retval=0;
  } else {
    retval=1;
  }
  return(retval);
}
示例#2
0
static double _Pstag_funct(void *arg, double q){
  double ret,h,T;
  h=(-sqr(q)/2.0+((argpstag_t *)arg)->h1+sqr(((argpstag_t *)arg)->q1)/2.0);
  T=_T_from_w_h(((argpstag_t *)arg)->w1, h);
  if (T>6000.0)
    wfprintf(stderr,"T=%E (above high T polynomials limit) along integration path of _Pstag\n",T);
  ret=q/(((argpstag_t *)arg)->R*T+2.0/3.0*((argpstag_t *)arg)->k1);
  return(ret);
}
示例#3
0
文件: resconv.c 项目: cescjf/CFDWARP
void write_disc_resconv_template(FILE **controlfile){
  wfprintf(*controlfile,
    "  %s(\n"
    "    AOWENO_TYPE=AOWENO_TYPE_DIFFUSIVE;\n"
    "    AOWENO_gammalo=0.85;\n"
    "    AOWENO_gammahi=0.85;\n"
    "    INTERPOL=INTERPOL_AOWENO5;\n"
    "    EIGENVALCOND=EIGENVALCOND_GNOFFO;\n"
    "  );\n"
  ,_RESCONV_ACTIONNAME);

}
示例#4
0
static double _qcnew_funct(void *arg, double q, double Pstar){
  double ret,h,T;
  h=-sqr(q)/2.0+((argfpot_t *)arg)->h1+sqr(((argfpot_t *)arg)->q1)/2.0;
  T=_T_from_w_h(((argfpot_t *)arg)->w1, h);
  if (T>60000.0) {
    wfprintf(stderr,"T=%E along numerical differentiation of qc\n",T);
  }
  if (!finite(T))
    fatal_error("T not finite in functqc.");
  ret=-(((argfpot_t *)arg)->R*T+2.0/3.0*((argfpot_t *)arg)->k1)/(Pstar*q);
  return(ret);
}
示例#5
0
void write_bdry_fluid_template(FILE **controlfile){
  wfprintf(*controlfile,
  "  %s(\n",_FLUID_ACTIONNAME);
  wfprintf(*controlfile,
    "    {\n"
    "    _________________________________________________________________________________________\n"
    "\n" 
    "    Boundary Condition Type           ID  Description\n"
    "    _________________________________________________________________________________________\n"
    "\n" 
    "    BDRY_INFLOWSUPERSONIC             %c   Inflow, supersonic\n"
    "    BDRY_INFLOWSUBSONIC1              %c   Inflow, subsonic, Tstag, Pstag fixed, 1o\n"
    "    BDRY_INFLOWSUBSONICMASSFLOWFIXED1 %c   Inflow, subsonic, Pstag, Massflow/Area fixed, 1o\n"
    "    BDRY_OUTFLOWSUPERSONIC1           %c   Outflow, supersonic, 1o\n"
    "    BDRY_OUTFLOWSUBSONIC1             %c   Outflow, subsonic, P fixed, 1o\n"
    "    BDRY_OUTFLOWSUBSONICMFIXED1       %c   Outflow, subsonic, M fixed, 1o\n"
    "    BDRY_SYMMETRICAL2                 %c   Symmetrical, 2o\n"
    "    BDRY_SYMMETRICAL1                 %c   Symmetrical, 1o\n"
    "    BDRY_WALLTFIXED1                  %c   Wall, T specified\n"
    "    BDRY_WALLADIABATIC1               %c   Wall, Adiabatic\n"
    "    BDRY_SLIPWALL1                    %c   Slip wall, Adiabatic, 1o\n"
    "    BDRY_FREESTREAM1                  %c   Freestream, 1o, params Vx,Vy,"if3DL("Vz,")" P, T\n"
    "    _________________________________________________________________________________________\n"
    "    }\n"
    "    All(BDRY_WALLTFIXED1);\n"
    "    Faces(BDRY_INFLOWSUPERSONIC,BDRY_OUTFLOWSUPERSONIC1"     if2DL(",  BDRY_SLIPWALL1,BDRY_SLIPWALL1")   if3DL(",  BDRY_SYMMETRICAL2,BDRY_SYMMETRICAL2")  ");\n"
    "    {\n"
    "    Cut(is" if2DL(",js") if3DL(",ks") ",  ie" if2DL(",je") if3DL(",ke") ");\n"
    "    Region(is" if2DL(",js") if3DL(",ks") ",  ie" if2DL(",je") if3DL(",ke") ",  BDRY_INFLOWSUPERSONIC);\n"
    "    Link(i1" if2DL(",j1") if3DL(",k1") ",  i2" if2DL(",j2") if3DL(",k2") ");\n"
    "    Param(is" if2DL(",js") if3DL(",ks") ",  ie" if2DL(",je") if3DL(",ke") ",  BDRY_FREESTREAM1, Vx,Vy,"if3DL("Vz,")"P,T);\n"
    "    }\n"
    "  );\n",_bdry_ID(BDRY_INFLOWSUPERSONIC),_bdry_ID(BDRY_INFLOWSUBSONIC1),_bdry_ID(BDRY_INFLOWSUBSONICMASSFLOWFIXED1),
             _bdry_ID(BDRY_OUTFLOWSUPERSONIC1),_bdry_ID(BDRY_OUTFLOWSUBSONIC1),_bdry_ID(BDRY_OUTFLOWSUBSONICMFIXED1),_bdry_ID(BDRY_SYMMETRICAL2),
             _bdry_ID(BDRY_SYMMETRICAL1),_bdry_ID(BDRY_WALLTFIXED1),_bdry_ID(BDRY_WALLADIABATIC1),_bdry_ID(BDRY_SLIPWALL1),_bdry_ID(BDRY_FREESTREAM1)
  );
}
示例#6
0
文件: resconv.c 项目: cescjf/CFDWARP
void read_disc_resconv_actions(char *actionname, char **argum, SOAP_codex_t *codex){

  long numvarsinit;
  void (*action_original) (char *, char **, struct SOAP_codex_t *);
  gl_t *gl=((readcontrolarg_t *)codex->action_args)->gl;
  if (strcmp(actionname,_RESCONV_ACTIONNAME)==0) {
    SOAP_count_all_vars(codex, &numvarsinit);
    if (((readcontrolarg_t *)codex->action_args)->VERBOSE) wfprintf(stdout,"%s..",_RESCONV_ACTIONNAME);

    SOAP_add_int_to_vars(codex,"EIGENVALCOND_HARTEN",EIGENVALCOND_HARTEN); 
    SOAP_add_int_to_vars(codex,"EIGENVALCOND_PECLET",EIGENVALCOND_PECLET);
    SOAP_add_int_to_vars(codex,"EIGENVALCOND_GNOFFO",EIGENVALCOND_GNOFFO);
    SOAP_add_int_to_vars(codex,"INTERPOL_FIRSTORDER",INTERPOL_FIRSTORDER);
    SOAP_add_int_to_vars(codex,"INTERPOL_BDF2",INTERPOL_BDF2);
    SOAP_add_int_to_vars(codex,"INTERPOL_TVD2_MINMOD",INTERPOL_TVD2_MINMOD); 
    SOAP_add_int_to_vars(codex,"INTERPOL_TVD2_VANLEER",INTERPOL_TVD2_VANLEER); 
    SOAP_add_int_to_vars(codex,"INTERPOL_TVD2_SUPERBEE",INTERPOL_TVD2_SUPERBEE); 
    SOAP_add_int_to_vars(codex,"INTERPOL_TVD5",INTERPOL_TVD5); 
    SOAP_add_int_to_vars(codex,"INTERPOL_AOWENO5",INTERPOL_AOWENO5); 
    SOAP_add_int_to_vars(codex,"INTERPOL_AOWENO7",INTERPOL_AOWENO7); 
    SOAP_add_int_to_vars(codex,"INTERPOL_WENO3",INTERPOL_WENO3); 
    SOAP_add_int_to_vars(codex,"INTERPOL_WENO5",INTERPOL_WENO5); 
    SOAP_add_int_to_vars(codex,"INTERPOL_WENO7",INTERPOL_WENO7); 
    SOAP_add_int_to_vars(codex,"INTERPOL_CWENO3",INTERPOL_CWENO3); 

    SOAP_add_int_to_vars(codex,"AOWENO_TYPE_COMPRESSIVE",AOWENO_TYPE_COMPRESSIVE); 
    SOAP_add_int_to_vars(codex,"AOWENO_TYPE_DIFFUSIVE",AOWENO_TYPE_DIFFUSIVE); 

    gl->DISC_RESCONV_READ=TRUE;
 
    action_original=codex->action;
    codex->action=&read_disc_resconv_actions_2;
    SOAP_process_code(*argum, codex, SOAP_VARS_KEEP_ALL);
    codex->action=action_original;

    find_int_var_from_codex(codex,"EIGENVALCOND",&gl->cycle.resconv.EIGENVALCOND);
    if (gl->cycle.resconv.EIGENVALCOND!=EIGENVALCOND_PECLET && gl->cycle.resconv.EIGENVALCOND!=EIGENVALCOND_HARTEN && gl->cycle.resconv.EIGENVALCOND!=EIGENVALCOND_GNOFFO)
      SOAP_fatal_error(codex,"EIGENVALCOND must be set to either EIGENVALCOND_PECLET, EIGENVALCOND_HARTEN, EIGENVALCOND_GNOFFO.");

    find_int_var_from_codex(codex,"INTERPOL",&gl->cycle.resconv.INTERPOL);
    if (
        gl->cycle.resconv.INTERPOL!=INTERPOL_FIRSTORDER  
#if (hbw_resconv_fluid>=2)
     && gl->cycle.resconv.INTERPOL!=INTERPOL_BDF2  
     && gl->cycle.resconv.INTERPOL!=INTERPOL_TVD2_MINMOD && gl->cycle.resconv.INTERPOL!=INTERPOL_TVD2_VANLEER 
     && gl->cycle.resconv.INTERPOL!=INTERPOL_TVD2_SUPERBEE && gl->cycle.resconv.INTERPOL!=INTERPOL_WENO3
#endif
#if (hbw_resconv_fluid>=3)
     && gl->cycle.resconv.INTERPOL!=INTERPOL_TVD5 && gl->cycle.resconv.INTERPOL!=INTERPOL_AOWENO5 
     && gl->cycle.resconv.INTERPOL!=INTERPOL_WENO5 && gl->cycle.resconv.INTERPOL!=INTERPOL_CWENO3
#endif
#if (hbw_resconv_fluid>=4)
     && gl->cycle.resconv.INTERPOL!=INTERPOL_WENO7 && gl->cycle.resconv.INTERPOL!=INTERPOL_AOWENO7
#endif
     )
      SOAP_fatal_error(codex,"INTERPOL must be set to either "
        "INTERPOL_FIRSTORDER, "
#if (hbw_resconv_fluid>=2)      
        "INTERPOL_BDF2, INTERPOL_TVD2_MINMOD, INTERPOL_TVD2_VANLEER, INTERPOL_TVD2_SUPERBEE, INTERPOL_WENO3, "
#endif
#if (hbw_resconv_fluid>=3)      
        "INTERPOL_AOWENO5, INTERPOL_WENO5, INTERPOL_CWENO3, INTERPOL_TVD5,"
#endif
#if (hbw_resconv_fluid>=4)      
        "INTERPOL_AOWENO7, INTERPOL_WENO7,"
#endif
      );
    find_int_var_from_codex(codex,"AOWENO_TYPE",&gl->cycle.resconv.AOWENO_TYPE);
    if (gl->cycle.resconv.AOWENO_TYPE!=AOWENO_TYPE_COMPRESSIVE && gl->cycle.resconv.AOWENO_TYPE!=AOWENO_TYPE_DIFFUSIVE)
      SOAP_fatal_error(codex,"AOWENO_TYPE must be set to either AOWENO_TYPE_COMPRESSIVE or AOWENO_TYPE_DIFFUSIVE.");

    find_double_var_from_codex(codex,"AOWENO_gammalo",&gl->cycle.resconv.AOWENO_gammalo);
    find_double_var_from_codex(codex,"AOWENO_gammahi",&gl->cycle.resconv.AOWENO_gammahi);

    gl->cycle.resconv.CONVJACOBIAN=CONVJACOBIAN_FVS;

    SOAP_clean_added_vars(codex,numvarsinit);
    codex->ACTIONPROCESSED=TRUE;
  }

}
示例#7
0
void
rules_test (tcb * thisdir, segment * pseg, seglen len, quadrant * pquad,
            u_short this_ip_id, Bool pkt_already_seen, double recovery_time)
{
  double DeltaT2, RTO, Mean_RTT, RTT_min;
  char type_of_segment =
    real_rules_test (thisdir, pseg, len, pquad, this_ip_id, pkt_already_seen,
                     &recovery_time);
  tcb *otherdir;
  int dir, num_acked;
#ifdef LOG_OOO
  extern FILE *fp_dup_ooo_log;
#endif

  if (pkt_already_seen)
    {
      pseg->type_of_segment = type_of_segment;
      num_acked = (pseg->prev != NULL) ? pseg->prev->acked : 0;
    }
  else
    {
      pseg->prev->type_of_segment = type_of_segment;
      num_acked = (pseg->prev->prev != NULL) ? pseg->prev->prev->acked : 0;
    }
  /* LM added */

  dir = (&(thisdir->ptp->c2s)) == thisdir;
  otherdir = (dir == C2S) ? &(thisdir->ptp->s2c) : &(thisdir->ptp->c2s);

  DeltaT2 =
    time2double (current_time) - time2double (pquad->seglist_tail->time);

  Mean_RTT =
    Average (thisdir->rtt_sum,
             thisdir->rtt_count) + Average (otherdir->rtt_sum,
                                            otherdir->rtt_count);
  RTO =
    Mean_RTT +
    4 *
    (Stdev
     (thisdir->rtt_sum + otherdir->rtt_sum,
      thisdir->rtt_sum2 + otherdir->rtt_sum2,
      thisdir->rtt_count + otherdir->rtt_count));

  RTT_min = (double) (thisdir->rtt_min + otherdir->rtt_min);

#ifdef LOG_OOO
  if (type_of_segment != 0)
    {
      wfprintf (fp_dup_ooo_log, "T: %f ",
               (elapsed (first_packet, current_time) / 1000.0));
      if (dir == C2S)
        {
          wfprintf (fp_dup_ooo_log, "%s %s ",
                   HostName (thisdir->ptp->addr_pair.a_address),
                   ServiceName (thisdir->ptp->addr_pair.a_port));
          wfprintf (fp_dup_ooo_log, "%s %s ",
                   HostName (thisdir->ptp->addr_pair.b_address),
                   ServiceName (thisdir->ptp->addr_pair.b_port));
        }
      else
        {
          wfprintf (fp_dup_ooo_log, "%s %s ",
                   HostName (thisdir->ptp->addr_pair.b_address),
                   ServiceName (thisdir->ptp->addr_pair.b_port));
          wfprintf (fp_dup_ooo_log, "%s %s ",
                   HostName (thisdir->ptp->addr_pair.a_address),
                   ServiceName (thisdir->ptp->addr_pair.a_port));
        }

      wfprintf (fp_dup_ooo_log,
               "%lu %lu %d %d %u %d %u %d %lf %lf %lu %lf %lf %lf %d",
               thisdir->data_pkts,
               thisdir->data_bytes,
               (type_of_segment & 15),
               thisdir->fsack_req && otherdir->fsack_req,
               thisdir->mss,
               (dir == C2S),
               (internal_dst),
               thisdir->initialwin_bytes,
               recovery_time / 1000.0,
               DeltaT2 / 1000.0,
               len, RTO / 1000.0, RTT_min / 1000.0, Mean_RTT / 1000.0,
               num_acked);
      wfprintf (fp_dup_ooo_log, " %f %f %f %f\n", thisdir->srtt / 1000.0,
               thisdir->rttvar / 1000.0, otherdir->srtt / 1000.0,
               otherdir->rttvar / 1000.0);
    }

#endif

  if (internal_src && !internal_dst)
    {
      add_histo (tcp_anomalies_out, aggregateType (type_of_segment));
    }
  else if (!internal_src && internal_dst)
    {
      add_histo (tcp_anomalies_in, aggregateType (type_of_segment));
    }
#ifndef LOG_UNKNOWN
  else if (internal_src && internal_dst)
#else
  else
#endif
    {
      add_histo (tcp_anomalies_loc, aggregateType (type_of_segment));
    }
  if (dir == C2S)
    {
      add_histo (tcp_anomalies_c2s, aggregateType (type_of_segment));
    }
  else
    {
      add_histo (tcp_anomalies_s2c, aggregateType (type_of_segment));
    }

/* just keep the main classification  and discard bit larger than
   BATCH_CLASSIFICATION*/
  switch (type_of_segment & (BATCH_CLASSIFICATION - 1))
    {
    case IN_SEQUENCE:
      /* just ignore them */
      break;
    case RETRANSMISSION_RTO:
      thisdir->rtx_RTO++;
      break;
    case RETRANSMISSION_FR:
      thisdir->rtx_FR++;
      break;
    case REORDERING:
      thisdir->reordering++;
      break;
    case NETWORK_DUPLICATE:
      thisdir->net_dup++;
      break;
    case FLOW_CONTROL:
      thisdir->flow_control++;
      break;
    case UNNECESSARY_RETRANSMISSION_FR:
      thisdir->unnecessary_rtx_FR++;
      break;
    case UNNECESSARY_RETRANSMISSION_RTO:
      thisdir->unnecessary_rtx_RTO++;
      break;
    default:
      thisdir->unknown++;
    }
}