Logo Search packages:      
Sourcecode: necpp version File versions  Download package

void nec_context::simulate ( bool  far_field_flag = false  ) 

Start a simulation.

This function will trigger a calculation. In the traditional NEC world, This signals the end of the main input section and the beginning of the frequency do loop.

Parameters:
far_field_flag is true if last card was XQ or RP
Warning:
far_field_flag is should never be specified as true because both the xq_card() and rp_card() functions will call this function automatically.
This function will trigger a calculation. In the traditional NEC world, This signals the end of the main input section and the beginning of the frequency do loop.

Parameters:
far_field_flag is true if last card was XQ or RP
Warning:
far_field_flag is should never be specified as true because both the xq_card() and rp_card() functions will call this function automatically.

Definition at line 982 of file nec_context.cpp.

References c_geometry::frequency_scale(), ifar, iptflg, iptflq, c_geometry::m_ipsym, m_output, c_geometry::mp, c_geometry::n_plus_2m, c_geometry::np, and safe_array< T >::resize().

Referenced by ne_nh_card(), rp_card(), and xq_card().

{
      DEBUG_TRACE("simulate(" << far_field_flag << ")");
      /* Allocate the normalization buffer */
      {
            int mreq1 = 0;
            int mreq2 = 0;
      
            if ( iped )
                  mreq1 = 4*nfrq;
            if ( iptflg >= 2 )
                  mreq2 = nthi*nphi;
      
            int newsize = std::max(mreq1,mreq2);
            fnorm.resize(newsize);
      }

      /* igox is a state variable that is used to change from
            one processing mode to another. The processing to be 
            performed are as follows:
                  
            1: Memory allocation & Initialization
            2: Structure segment loading
            3: Excitation set up (right hand side, -e inc.)
            4: ?
            5: Near field calculation
            6: standard far field calculation
      */
      int igox;
      int mhz = 0;
      
      if ( (far_field_flag == true)
            && (processing_state == 5) )
            igox = 6;
      else
            igox = processing_state;
      
      
      try
      {
      int iresrv = 0;
      bool in_freq_loop = false;
      
      do
      {     
            switch( igox )
            {
            case 1: /* Memory allocation for primary interacton matrix. */

                  if (false == in_freq_loop)
                  {
                        iresrv = m_geometry->n_plus_2m * (m_geometry->np+2*m_geometry->mp);
                        cm.resize(iresrv);
                  
                        /* Memory allocation for symmetry array */
                        nop = neq/npeq;
                        symmetry_array.resize(nop*nop);     
                        mhz = 1;
                        
                        /* irngf is not used (NGF function not implemented) */
                        if ( imat == 0)
                              fblock( npeq, neq, iresrv, m_geometry->m_ipsym);
                        
                        in_freq_loop = true;
                  }
                  
                  if ( mhz != 1)
                  {
                        if ( ifrq == 1)
                              freq_mhz *= delfrq;
                        else
                              freq_mhz += delfrq;
                  }

                  wavelength = em::speed_of_light() / (1.0e6 * freq_mhz);

                  print_freq_int_krnl(freq_mhz, wavelength, rkh, m_use_exk);
                        
                  m_geometry->frequency_scale(freq_mhz);
                  processing_state = 2;

            case 2: /* structure segment loading */
                  structure_segment_loading();

                  processing_state=3;
                  ntsol=0;
            
            case 3: /* excitation set up (right hand side, -e inc.) */
                  nthic=1;
                  nphic=1;
                  inc=1;
                  nprint=0;

            default:
                  enum excitation_return ret = excitation_loop(igox, mhz, 
                        iptflg, iptflq, 
                        iptag, iptagf, iptagt, 
                        iptaq, iptaqf, iptaqt, 
                        thetis, nfrq, iflow, 
                        nthi, nphi, iped);
            
                  if (FREQ_LOOP_CONTINUE == ret)
                  {
                        continue; // Continue frequency loop
                  }
                  if (FREQ_LOOP_CARD_CONTINUE == ret)
                  {
                        throw 1; // Continue card input
                  }
            
                  nphic = 1;
      
                  /* normalized receiving pattern printed */
                  print_norm_rx_pattern(iptflg, nthi, nphi, thetis, phiss);
                  
                  xpr2  = phiss;
      
                  if ( mhz == nfrq)
                        ifar=-1;
      
                  if ( nfrq == 1)
                  {
                        m_output.end_section();
                        throw 1; // Continue card input
                  }
            
                  print_input_impedance(iped, ifrq, nfrq, delfrq);
            
                  nfrq=1;
                  mhz=1;    
            } /* switch( igox ) */
      }
      while( (++mhz <= nfrq) );
      } /* try */
      catch (int excep)
      {
            ASSERT(excep == 1);
            // keep going on the card input. The exception
            // is thrown in order to continue card input.
      }
}


Generated by  Doxygen 1.6.0   Back to index