Beispiel #1
0
 void PMap(const CellMap& m)
 {
   // print out map
   CellMap::const_iterator it;
   pout() << "Cell Map has " << m.size() << " cells\n";
   for ( it = m.begin(); it != m.end(); it++)
   {
     pout() << "cell "; PIV(it->first); pout() << "\n";
     pout() << " verts: "; PVec(it->second.vertices); pout() << "\n";
     pout() << " tris : "; PVec(it->second.triangles); pout() << "\n";
   }
 }
Beispiel #2
0
void tool_app_t::mac(const netlist::factory::element_t *e)
{
	auto v = plib::psplit(e->param_desc(), ",");
	pstring vs;
	for (auto s : v)
	{
		vs += ", " + s.replace_all("+", "").replace_all(".", "_");
	}
	pout("{1}(name{2})\n", e->name(), vs);
	if (v.size() > 0)
	{
		pout("/*\n");
		for (auto s : v)
		{
			pstring r(s.replace_all("+", "").replace_all(".", "_"));
			if (s.startsWith("+"))
				pout("{1:10}: Terminal\n",r);
			else
				pout("{1:10}: Parameter\n", r);
		}
		pout("*/\n");
	}
}
// Read drive database from file.
bool read_drive_database(const char * path)
{
  stdio_file f(path, "r"
#ifdef __CYGWIN__ // Allow files with '\r\n'.
                      "t"
#endif
                         );
  if (!f) {
    pout("%s: cannot open drive database file\n", path);
    return false;
  }

  return parse_drive_database(parse_ptr(f), knowndrives, path);
}
// Define new AMR level
void AMRLevelPluto::define(AMRLevel*            a_coarserLevelPtr,
                           const ProblemDomain& a_problemDomain,
                           int                  a_level,
                           int                  a_refRatio)
{
  if (s_verbosity >= 3)
  {
    pout() << "AMRLevelPluto::define " << a_level << endl;
  }

  // Call inherited define
  AMRLevel::define(a_coarserLevelPtr,
                   a_problemDomain,
                   a_level,
                   a_refRatio);

  // Get setup information from the next coarser level
  if (a_coarserLevelPtr != NULL)
  {
    AMRLevelPluto* amrGodPtr = dynamic_cast<AMRLevelPluto*>(a_coarserLevelPtr);

    if (amrGodPtr != NULL)
    {
      m_cfl = amrGodPtr->m_cfl;
      m_domainLength = amrGodPtr->m_domainLength;
      m_refineThresh = amrGodPtr->m_refineThresh;
      m_tagBufferSize = amrGodPtr->m_tagBufferSize;
    }
    else
    {
      MayDay::Error("AMRLevelPluto::define: a_coarserLevelPtr is not castable to AMRLevelPluto*");
    }
  }

  // Compute the grid spacing
  m_dx = m_domainLength / (a_problemDomain.domainBox().bigEnd(0)-a_problemDomain.domainBox().smallEnd(0)+1.);

  // Nominally, one layer of ghost cells is maintained permanently and
  // individual computations may create local data with more
  m_numGhost = 1;

  CH_assert(m_patchPluto != NULL);
  CH_assert(isDefined());
  m_patchPluto->define(m_problem_domain,m_dx,m_level,m_numGhost);

  // Get additional information from the patch integrator
  m_numStates      = m_patchPluto->numConserved();
  m_ConsStateNames = m_patchPluto->ConsStateNames();
  m_PrimStateNames = m_patchPluto->PrimStateNames();
}
Beispiel #5
0
// ---------------------------------------------------------------
void
AMRNavierStokes::writeCheckpointHeader(HDF5Handle& a_handle) const
{
  if (s_verbosity >= 3)
    {
      pout() << "AMRNavierStokes::writeCheckpointHeader" << endl;
    }

  HDF5HeaderData header;
  // since number of velocity components is obviously SpaceDim,
  // only need to do number of scalar components here
  CH_assert (s_num_vel_comps == SpaceDim);
  header.m_int["num_components"] = s_num_scal_comps;
  char comp_str[30];
  for (int comp=0; comp<s_num_scal_comps; ++comp)
    {
      sprintf (comp_str, "component_%d", comp);
      header.m_string[comp_str] = s_scal_names[comp];
    }

  // now write lambda name
  header.m_string["lambda_component"] = "lambda";

  // now write velocity names..
  for (int comp=0; comp<s_num_vel_comps; ++comp)
    {
      sprintf (comp_str, "vel_component_%d", comp);
      header.m_string[comp_str] = s_vel_names[comp];
    }

  header.writeToFile(a_handle);

  if (s_verbosity >= 3)
    {
      pout () << header << endl;
    }
}
Beispiel #6
0
int
main(void)
{
	static const char *pcap_files[] = {
		"../../sample/icmp.pcap",
		"../../sample/tcp.pcap",
		"../../sample/udp.pcap",
		"../../sample/tcp6.pcap",
		"../../sample/udp6.pcap",
	};

	pout("peak packet test suite... ");

	/* make sure this is always aligned to 8 bytes */
	assert(!(sizeof(struct peak_packet) % sizeof(uint64_t)));

	memset(&net_saddr4, 0, sizeof(net_saddr4));
	memset(&net_daddr4, 0, sizeof(net_daddr4));
	memset(&net_saddr6, 0, sizeof(net_saddr6));
	memset(&net_daddr6, 0, sizeof(net_daddr6));

	netaddr4(&net_saddr4, be32dec(&src_ip4));
	netaddr4(&net_daddr4, be32dec(&dst_ip4));
	netaddr6(&net_saddr6, src_ip6);
	netaddr6(&net_daddr6, dst_ip6);

	test_icmp(pcap_files[0]);
	test_transport_ip4(pcap_files[1]); /* TCP over IPv4 */
	test_transport_ip4(pcap_files[2]); /* UDP over IPv4 */
	test_transport_ip6(pcap_files[3]); /* TCP over IPv6 */
	test_transport_ip6(pcap_files[4]); /* UDP over IPv6 */

	pout("ok\n");

	return (0);
}
Beispiel #7
0
// Maintain backward compatibility in code.
// Can now use reduce_print_avg_min_max("label", value);
void gather_memory_from_procs(Real end_memory,
                              Real &avg_memory,
                              Real &min_memory,
                              Real &max_memory)
{
  reduce_avg_min_max(end_memory, avg_memory, min_memory, max_memory);

  // results only need to be on rank0 (and are)
  if (procID() == 0)
    {
      pout() << "Gather end memory from procs:  avg: " << avg_memory
             << "  min: " << min_memory
             << "  max: " << max_memory << " (MB)\n";
    }
}
Beispiel #8
0
void QuickScan_Email(void)
{
    int     FoundMsg  = FALSE;
    int	    i;
    char    temp[81];

    iLineCount = 2;
    WhosDoingWhat(READ_POST, NULL);

    if (EmailBase.Total == 0) {
	Enter(1);
	/* There are no messages in this area. */
	pout(WHITE, BLACK, (char *) Language(205));
	Enter(2);
	sleep(3);
	return;
    }

    clear(); 
    /* #    From                  To                       Subject */
    poutCR(YELLOW, BLUE, (char *) Language(220));

    if (Msg_Open(sMailpath)) {
	for (i = EmailBase.Lowest; i <= EmailBase.Highest; i++) {
	    if (Msg_ReadHeader(i)) {
                                
		snprintf(temp, 81, "%-6u", Msg.Id);
		pout(WHITE, BLACK, temp);
		snprintf(temp, 81, "%s ", padleft(Msg.From, 20, ' '));
		pout(CYAN, BLACK, temp);

		snprintf(temp, 81, "%s ", padleft(Msg.To, 20, ' '));
		pout(GREEN, BLACK, temp);
		snprintf(temp, 81, "%s", padleft(Msg.Subject, 31, ' '));
		pout(MAGENTA, BLACK, temp);
		Enter(1);
		FoundMsg = TRUE;
		if (LC(1))
		    break;
	    }
	}
	Msg_Close();
    }

    if(!FoundMsg) {
	Enter(1);
	/* There are no messages in this area. */
	pout(LIGHTGREEN, BLACK, (char *) Language(205));
	Enter(2);
	sleep(3);
    }

    iLineCount = 2;
    Pause();
}
Beispiel #9
0
//-----------------------------------------------------------------------------
// Function      : safeBarrier
// Purpose       : This barrier will exit cleanly in parallel if one PE exits
//                 with an error.  The region covered is that following a
//                 previous call to startSafeBarrier
// Special Notes :
// Scope         : Public
// Creator       : Dave Shirley, PSSi
// Creation Date : 07/18/05
//-----------------------------------------------------------------------------
void safeBarrier(Parallel::Machine comm)
{
  // Collect all pending message to the log file.
  pout(comm);

  unsigned count = get_message_count(MSG_FATAL) + get_message_count(MSG_ERROR);

  if (Parallel::is_parallel_run(comm))
    Parallel::AllReduce(comm, MPI_SUM, &count, 1);

  if (count > 0) {
    UserFatal0().die() << "Simulation aborted due to error";

    Xyce_exit(-1);
  }
}
Beispiel #10
0
void
GUIManager::update(const Input::Event& event)
{
  switch (event.type)
  {
    case Input::POINTER_EVENT_TYPE:
      mouse_pos.x = int(event.pointer.x);
      mouse_pos.y = int(event.pointer.y);
      on_pointer_move(mouse_pos.x, mouse_pos.y);
      break;

    case Input::BUTTON_EVENT_TYPE:
      if (event.button.name == PRIMARY_BUTTON)
      {
        if (event.button.state == Input::BUTTON_PRESSED)
          on_primary_button_press(mouse_pos.x, mouse_pos.y);
        else if (event.button.state == Input::BUTTON_RELEASED)
          on_primary_button_release(mouse_pos.x, mouse_pos.y);
      }
      else if (event.button.name == SECONDARY_BUTTON)
      {
        if (event.button.state == Input::BUTTON_PRESSED)
          on_secondary_button_press(mouse_pos.x, mouse_pos.y);
        else if (event.button.state == Input::BUTTON_RELEASED)
          on_secondary_button_release(mouse_pos.x, mouse_pos.y);
      }
      break;

    case Input::AXIS_EVENT_TYPE:
      // AxisEvents can be ignored in the GUI, they are handled elsewhere
      pout(PINGUS_DEBUG_GUI) << "GUIManager: AxisEvent: " << event.axis.dir << std::endl;
      break;
        
    case Input::KEYBOARD_EVENT_TYPE:
      on_key_pressed(event.keyboard.key);
      break;

    case Input::SCROLLER_EVENT_TYPE:
      on_scroller_move(event.scroll.x_delta, event.scroll.y_delta);
      break;

    default:
      pwarn (PINGUS_DEBUG_GUI) << "GUIManager: unhandled event type " << event.type << std::endl;
      break;
  }
}
Beispiel #11
0
int
testEBFluxFAB(const EBISBox& a_ebisBox, const Box& a_box)
{
  Interval comps(0,0);
  IntVectSet ivs(a_box);
  EBFluxFAB srcFab( a_ebisBox, a_box, 1);
  EBFluxFAB dstFab( a_ebisBox, a_box, 1);
  for (int idir = 0; idir < SpaceDim; idir++)
    {
      //set source fab to right ans
      for (FaceIterator faceit(ivs, a_ebisBox.getEBGraph(), idir, FaceStop::SurroundingWithBoundary);
          faceit.ok(); ++faceit)
        {
          srcFab[idir](faceit(), 0) = rightAns(faceit());
        }
    }

  //linearize the data to dst
  int sizeFab = srcFab.size(a_box, comps);
  unsigned char* buf = new unsigned char[sizeFab];
  srcFab.linearOut(buf, a_box, comps);
  dstFab.linearIn( buf, a_box, comps);
  delete[] buf;

  //check the answer
  int eekflag = 0;
  for (int idir = 0; idir < SpaceDim; idir++)
    {
      Real tolerance = 0.001;
      for (FaceIterator faceit(ivs, a_ebisBox.getEBGraph(), idir, FaceStop::SurroundingWithBoundary);
          faceit.ok(); ++faceit)
        {
          Real correct  = rightAns(faceit());
          if (Abs(dstFab[idir](faceit(), 0) - correct) > tolerance)
            {
              pout() << "ivfab test failed at face "
                     << faceit().gridIndex(Side::Lo)
                     << faceit().gridIndex(Side::Hi) << endl;

              eekflag = -4;
              return eekflag;
            }
        }
    }
  return 0;
}
Beispiel #12
0
void
divergenceTest()
{
    int maxsize;
    ParmParse pp;
    pp.get("max_grid_size", maxsize);

    //make layouts == domain
    Box domainBoxFine, domainBoxCoar;
    Real dxFine, dxCoar;
    sphereGeometry(domainBoxFine, dxFine);
    domainBoxCoar = coarsen(domainBoxFine, 2);

    //debug
    dxFine = 1.0;
    dxCoar = 2.*dxFine;
    Vector<Box> boxFine;
    domainSplit(domainBoxFine, boxFine, maxsize);

    Vector<int> proc(boxFine.size(), 0);
    DisjointBoxLayout dblFine(boxFine, proc);
    DisjointBoxLayout dblCoar;
    coarsen(dblCoar, dblFine, 2);
    LevelData<EBCellFAB> errorFine, errorCoar;

    EBISLayout ebislFine, ebislCoar;
    const EBIndexSpace* const ebisPtr = Chombo_EBIS::instance();
    ebisPtr->fillEBISLayout(ebislFine, dblFine, domainBoxFine, 2);
    ebisPtr->fillEBISLayout(ebislCoar, dblCoar, domainBoxCoar, 2);

    getError(errorFine, ebislFine, dblFine, dxFine);
    getError(errorCoar, ebislCoar, dblCoar, dxCoar);

    for (DataIterator dit= dblFine.dataIterator(); dit.ok(); ++dit)
    {
        const EBCellFAB& errorFineFAB = errorFine[dit()];
        const EBCellFAB& errorCoarFAB = errorCoar[dit()];
        int i1 = errorFineFAB.getMultiCells().numPts();
        int i2 = errorCoarFAB.getMultiCells().numPts();
        pout() << i1 << i2 << endl;
    }

    compareError(errorFine, ebislFine, dblFine, domainBoxFine,
                 errorCoar, ebislCoar, dblCoar, domainBoxCoar);

}
Beispiel #13
0
/*
 * Edit signature file, called by menu 319
 */
void signature(void)
{
    memset(&sLiNE, 0, sizeof(sLiNE));

    if (loadsignature()) {
	while (TRUE) {
	    if (editsignature() == TRUE)
		break;
	}
    }

    Enter(2);
    /* Returning to */
    pout(CFG.MoreF, CFG.MoreB, (char *) Language(117));
    poutCR(CFG.MoreF, CFG.MoreB, CFG.bbs_name);
    sleep(2);
}
void intlog_binning(deque<int> c, int number_of_bins, string file) {
	
	
	DD Xs;
	DD Ys;
	DD var;
	
	char b[file.size()+1];
	cast_string_to_char(file, b);
	ofstream pout(b);
	
	
	intlog_binning(c, number_of_bins, Xs, Ys, var);
	RANGE_loop(i, Xs) {
		pout<<Xs[i]<<" "<<Ys[i]<<" "<<var[i]<<endl;
	}
	
}
// Skip whitespace and comments.
static parse_ptr skip_white(parse_ptr src, const char * path, int & line)
{
  for ( ; ; ++src) switch (*src) {
    case ' ': case '\t':
      continue;

    case '\n':
      ++line;
      continue;

    case '/':
      switch (src[1]) {
        case '/':
          // skip '// comment'
          ++src; ++src;
          while (*src && *src != '\n')
            ++src;
          if (*src)
            ++line;
          break;
        case '*':
          // skip '/* comment */'
          ++src; ++src;
          for (;;) {
            if (!*src) {
              pout("%s(%d): Missing '*/'\n", path, line);
              return src;
            }
            char c = *src; ++src;
            if (c == '\n')
              ++line;
            else if (c == '*' && *src == '/')
              break;
          }
          break;
        default:
          return src;
      }
      continue;

    default:
      return src;
  }
}
// Things to do after initialization
void AMRLevelPluto::postInitialize()
{
  CH_assert(allDefined());

  if (s_verbosity >= 3)
  {
    pout() << "AMRLevelPluto::postInitialize " << m_level << endl;
  }

  if (m_hasFiner)
  {
    // Volume weighted average from finer level data
    AMRLevelPluto* amrGodFinerPtr = getFinerLevel();

    amrGodFinerPtr->m_coarseAverage.averageToCoarse(m_UNew,
                                                    amrGodFinerPtr->m_UNew);
  }

}
Beispiel #17
0
static void
peek_report(const struct peak_packet *packet, const struct peak_track *flow,
    const timeslice_t *timer)
{
	unsigned int i;

	for (i = 0; i < use_count; ++i) {
		if (i) {
			pout(", ");
		}

		switch (use_print[i]) {
		case USE_APP:
			pout("app: %s", peak_li_name(peak_li_merge(flow->li)));
			break;
		case USE_APP_LEN:
			pout("app_len: %hu", packet->app_len);
			break;
		case USE_FLOW:
			pout("flow: %llu", (unsigned long long)flow->id);
			break;
		case USE_IP_LEN:
			pout("ip_len: %hu", packet->net_len);
			break;
		case USE_IP_TYPE:
			pout("ip_type: %hhu", packet->net_type);
			break;
		case USE_TIME: {
			char tsbuf[40];
			pout("time: %s", strftime(tsbuf, sizeof(tsbuf),
			    "%a %F %T", &timer->gmt) ? tsbuf : "???");
			break;
		}
		default:
			break;
		}
	}

	pout("\n");
}
Beispiel #18
0
/*
 * Choose Message Editor
 */
void Chg_FsMsged()
{
    int	    z;
    char    temp[81];

    ReadExitinfo();
    Enter(2);

    /*                               Now using the */
    pout(LIGHTMAGENTA, BLACK, (char *)Language(372));
    /*                 Line/Fullscreen/External    */
    colour(LIGHTCYAN, BLACK);
    snprintf(temp, 81, " %s ", Language(387 + (exitinfo.MsgEditor & 3)));
    PUTSTR(temp);
    /*                                      Editor */
    pout(LIGHTMAGENTA, BLACK, (char *)Language(390));
    Enter(1);

    if (strlen(CFG.externaleditor))
	/* Select: 1) Fullscreen editor, 2) External editor */
	pout(WHITE, BLACK, (char *)Language(373));
    else
	/* Select: 1) Fullscreen editor */
	pout(WHITE, BLACK, (char *)Language(438));
    alarm_on();
    z = toupper(Readkey());

    if (z == Keystroke(373, 0)) {
	exitinfo.MsgEditor = FSEDIT;
	Syslog('+', "User selected fullscreen editor");
    } else if ((z == Keystroke(373, 1) && strlen(CFG.externaleditor))) {
	exitinfo.MsgEditor = EXTEDIT;
	Syslog('+', "User selected external editor");
    }

    Enter(2);

    /*                               Now using the */
    pout(LIGHTMAGENTA, BLACK, (char *)Language(372));
    /*                 Line/Fullscreen/External    */
    colour(LIGHTCYAN, BLACK);
    snprintf(temp, 81, " %s ", Language(387 + (exitinfo.MsgEditor & 3)));
    PUTSTR(temp);
    /*                                      Editor */
    pout(LIGHTMAGENTA, BLACK, (char *)Language(390));

    Enter(2);
    sleep(2);
    WriteExitinfo();
}
Beispiel #19
0
// ---------------------------------------------------------------
void
AMRNavierStokes::writeCheckpointLevel(HDF5Handle& a_handle) const
{
  if (s_verbosity >= 3)
    {
      pout () << "AMRNavierStokes::writeCheckpointLevel" << endl;
    }

  char level_str[20];
  sprintf (level_str, "%d", m_level);
  const std::string label = std::string("level_") + level_str;

  a_handle.setGroup(label);

  HDF5HeaderData header;

  header.m_int ["ref_ratio"] = m_ref_ratio;
  header.m_real["dx"]        = m_dx;
  header.m_real["dt"]        = m_dt;
  header.m_real["time"]      = m_time;
  header.m_real["cfl"]       = m_cfl;

  header.m_int["finest_level"] = m_finest_level;
  header.m_int["is_empty"] = m_is_empty;

  // don't write out static variables -- get them from inputs files?
  // or should we checkpoint those?

  header.m_box["prob_domain"] = m_problem_domain.domainBox();

  // write out periodicity info
  D_TERM(
         if (m_problem_domain.isPeriodic(0))
         {
           header.m_int ["is_periodic_0"] = 1;
         }
         else
         {
           header.m_int ["is_periodic_0"] = 0;
         }
  ,
         if (m_problem_domain.isPeriodic(1))
// Destructor
AMRLevelPluto::~AMRLevelPluto()
{
  if (s_verbosity >= 3)
  {
    pout() << "AMRLevelPluto destructor" << endl;
  }

  // Get rid of the patch integrator and its factory
  if (m_patchPluto != NULL)
  {
    delete m_patchPluto;
  }
  
  if (m_patchPlutoFactory != NULL)
  {
    delete m_patchPlutoFactory;
  }

  m_paramsDefined = false;
}
// Searches drive database and sets preset vendor attribute
// options in defs and firmwarebugs.
// Values that have already been set will not be changed.
// Returns pointer to database entry or nullptr if none found
const drive_settings * lookup_drive_apply_presets(
  const ata_identify_device * drive, ata_vendor_attr_defs & defs,
  firmwarebug_defs & firmwarebugs)
{
  // get the drive's model/firmware strings
  char model[MODEL_STRING_LENGTH+1], firmware[FIRMWARE_STRING_LENGTH+1];
  ata_format_id_string(model, drive->model, sizeof(model)-1);
  ata_format_id_string(firmware, drive->fw_rev, sizeof(firmware)-1);

  // Look up the drive in knowndrives[].
  const drive_settings * dbentry = lookup_drive(model, firmware);
  if (!dbentry)
    return 0;

  if (*dbentry->presets) {
    // Apply presets
    if (!parse_presets(dbentry->presets, defs, firmwarebugs))
      pout("Syntax error in preset option string \"%s\"\n", dbentry->presets);
  }
  return dbentry;
}
int main(int argc, char** argv) {
  double genotype[] = {0, 2, -9, 2, 2, 2, 2,  -9, 1,
                       2, 2, 2,  2, 1, 1, -9, -9, 0};

  SimpleMatrix m;  // marker by sample matrix
  m.resize(3, 6);
  int offset = 0;
  for (int i = 0; i < m.nrow(); ++i) {
    for (int j = 0; j < m.ncol(); ++j) {
      m[i][j] = genotype[offset];
      ++offset;
    }
  }

  std::vector<std::string> iid;
  char buf[128];
  for (int i = 0; i < m.ncol(); ++i) {
    sprintf(buf, "%d", i + 1);
    iid.push_back(buf);
  }

  std::vector<double> pheno;
  pheno.push_back(-9);
  pheno.push_back(-9);
  pheno.push_back(2);
  pheno.push_back(-9);
  pheno.push_back(2);
  pheno.push_back(2);

  PlinkOutputFile pout("testPlinkOutputFile.output");
  pout.writeFAM(iid, iid, pheno);
  pout.writeBIM("1", "snp1", 0, 1, "G", "A");
  pout.writeBIM("1", "snp2", 0, 2, "1", "2");
  pout.writeBIM("1", "snp3", 0, 3, "A", "C");
  pout.writeBED(&m, m.ncol(), m.nrow());

  fprintf(stderr, "Done\n");

  return 0;
}
Beispiel #23
0
bool GetItemsSubChunk(WDL_FastString* _in, WDL_FastString* _out, int _tmpltIdx)
{
	if (_in && _in->GetLength() && _out && _in!=_out)
	{
		_out->Set("");

		// truncate to the track #_tmpltIdx found in the template
		SNM_ChunkParserPatcher p(_in);
		if (p.GetSubChunk("TRACK", 1, _tmpltIdx, _out) >= 0)
		{
//JFB!! to update with SNM_ChunkParserPatcher v2
//		ex: return (p->GetSubChunk("ITEM", 2, -1, _outSubChunk) >= 0); // -1 to get all items in one go
			SNM_ChunkParserPatcher pout(_out);
			int posItems = pout.GetSubChunk("ITEM", 2, 0); // no breakKeyword possible here: chunk ends with items
			if (posItems >= 0) {
				_out->Set((const char*)(pout.GetChunk()->Get()+posItems), pout.GetChunk()->GetLength()-posItems-2);  // -2: ">\n"
				return true;
			}
		}
	}
	return false;
}
Beispiel #24
0
void Set_Protocol(char *Protocol)
{
    FILE    *pProtConfig;
    int	    precno = 0;
    char    *temp;

    memset(&sProtName, 0, sizeof(sProtName));
    temp = calloc(PATH_MAX, sizeof(char));

    snprintf(temp, PATH_MAX, "%s/etc/protocol.data", getenv("FTND_ROOT"));

    if (( pProtConfig = fopen(temp, "rb")) == NULL) {
	WriteError("$Can't open %s", temp);
        Enter(1);
        /* Protocol: Can't open protocol file. */
        pout(LIGHTRED, BLACK, (char *) Language(262));
        Enter(2);
        Pause();
        free(temp);
        return;
    }

    fread(&PROThdr, sizeof(PROThdr), 1, pProtConfig);

    while (fread(&PROT, PROThdr.recsize, 1, pProtConfig) == 1) {
	if (((strcmp(PROT.ProtName, Protocol)) == 0) && PROT.Available) {
	    strcpy(sProtName, PROT.ProtName);
	    strcpy(sProtUp, PROT.ProtUp);
	    strcpy(sProtDn, PROT.ProtDn);
	    strcpy(sProtAdvice, PROT.Advice);
	    uProtInternal = PROT.Internal;
	    iProtEfficiency = PROT.Efficiency;
	} else
	    precno++;
    }

    free(temp);
    fclose(pProtConfig);
}
Beispiel #25
0
/*
 * Function will download a specific file
 */
int DownloadDirect(char *Name, int Wait)
{
    int		rc = 0;
    int		Size;
    down_list	*dl = NULL;

    if ((Size = file_size(Name)) == -1) {
	WriteError("No file %s", Name);
	pout(CFG.HiliteF, CFG.HiliteB, (char *)"File not found");
	Enter(2);
	Pause();
    }

    Syslog('+', "Download direct %s", Name);

    add_download(&dl, Name, basename(Name), 0, Size, FALSE);
    WhosDoingWhat(DOWNLOAD, NULL);

    if ((rc = download(dl))) {
	/*
	 * Error
	 */
	Syslog('+', "Download failed rc=%d", rc);
	poutCR(LIGHTRED, BLACK, (char *)Language(353));
    } else {
	/*
	 * Update the users record. The file is free, so only statistics.
	 */
	ReadExitinfo();
	exitinfo.Downloads++;    /* Increase download counter */
	mib_downloads++;
	WriteExitinfo();
    }

    if (Wait)
	Pause();
    return rc;
}
Beispiel #26
0
int
testIVFAB(const EBISBox& a_ebisBox, const Box& a_box)
{
  IntVectSet ivs = a_ebisBox.getIrregIVS(a_box);
  if (ivs.isEmpty()) return 0;

  Interval comps(0,0);
  BaseIVFAB<Real> srcFab(ivs, a_ebisBox.getEBGraph(), 1);
  BaseIVFAB<Real> dstFab(ivs, a_ebisBox.getEBGraph(), 1);
  //set source fab to right ans
  for (VoFIterator vofit(ivs, a_ebisBox.getEBGraph()); vofit.ok(); ++vofit)
    {
      srcFab(vofit(), 0) = rightAns(vofit());
    }

  //linearize the data to dst
  int sizeFab = srcFab.size(a_box, comps);
  unsigned char* buf = new unsigned char[sizeFab];
  srcFab.linearOut(buf, a_box, comps);
  dstFab.linearIn( buf, a_box, comps);
  delete[] buf;

  //check the answer
  int eekflag = 0;
  Real tolerance = 0.001;
  for (VoFIterator vofit(ivs, a_ebisBox.getEBGraph()); vofit.ok(); ++vofit)
    {
      Real correct  = rightAns(vofit());
      if (Abs(dstFab(vofit(), 0) - correct) > tolerance)
        {
          pout() << "ivfab test failed at vof " << vofit().gridIndex() << endl;
          eekflag = -1;
          return eekflag;
        }
    }

  return 0;
}
Beispiel #27
0
void
XInputDriver::setup_xinput()
{
  if (!xinput_is_present())
  {
    std::cout << "debug: XInput extentsion not found" << std::endl;
  }
  else
  {
    int num_devices;
    XDeviceInfo* info = XListInputDevices(sys.info.x11.display, &num_devices);
    for(int i = 0; i < num_devices; ++i) 
    {
      pout(PINGUS_DEBUG_INPUT) << "XInputDriver: Device name='" << info[i].name << "'" << std::endl;
      // FIXME: Xinput isn't necesarrily a mouse, could be anything
      //if (info[i].use == IsXExtensionDevice)
      // {
      devices.push_back(new XInputDevice(this, &info[i]));
      // } 
    }
    XFreeDeviceList(info);
  }
}
Beispiel #28
0
int checkCoarseAssortment(const Box& a_domain)
{
  int retval = 0;
  const EBIndexSpace* const ebisPtr = Chombo_EBIS::instance();
  CH_assert(ebisPtr->isDefined());
  Box fineDomain = a_domain;

  int numLevels = ebisPtr->numLevels();
  for (int ilev = 1; ilev < numLevels; ilev++)
    {
      CH_assert(!fineDomain.isEmpty());
      Vector<Box> vbox(1, fineDomain);
      Vector<int> proc(1, 0);
      DisjointBoxLayout fineDBL(vbox, proc);
      EBISLayout fineEBISL;
      int nghost = 4;
      ebisPtr->fillEBISLayout(fineEBISL, fineDBL, fineDomain, nghost);
      Box coarDomain = coarsen(fineDomain, 2);
      DisjointBoxLayout coarDBL;
      coarsen(coarDBL, fineDBL, 2);
      EBISLayout coarEBISL;
      ebisPtr->fillEBISLayout(coarEBISL, coarDBL, coarDomain, nghost);

      for (DataIterator dit = fineDBL.dataIterator(); dit.ok(); ++dit)
        {
          retval = checkEBISBox(coarDBL.get(dit()), coarEBISL[dit()], fineEBISL[dit()]);
          if (retval != 0)
            {
              pout() << "problem in coarsening  " << fineDomain << " to " << coarDomain << endl;
              return retval;
            }
        }
      fineDomain.coarsen(2);
   }
return retval;
}
Beispiel #29
0
int makeGeometry(Box& a_domain)
{
  Real dx;
  RealVect origin;
  int eekflag =  0;
  //parse input file
  ParmParse pp;

  Vector<int> n_cell(SpaceDim);
  pp.getarr("n_cell",n_cell,0,SpaceDim);

  CH_assert(n_cell.size() == SpaceDim);
  IntVect lo = IntVect::Zero;
  IntVect hi;
  for (int ivec = 0; ivec < SpaceDim; ivec++)
    {
      if (n_cell[ivec] <= 0)
        {
          pout() << " bogus number of cells input = " << n_cell[ivec];
          return(-1);
        }
      hi[ivec] = n_cell[ivec] - 1;
    }

  a_domain.setSmall(lo);
  a_domain.setBig(hi);

  Vector<Real> prob_lo(SpaceDim, 1.0);
  Real prob_hi;
  pp.getarr("prob_lo",prob_lo,0,SpaceDim);
  pp.get("prob_hi",prob_hi);
  dx = (prob_hi-prob_lo[0])/n_cell[0];
  RealVect dxVect = dx*RealVect::Unit;
  for (int idir = 0; idir < SpaceDim; idir++)
    {
      origin[idir] = prob_lo[idir];
    }
  int verbosity = 0;
  int whichgeom;
  pp.get("which_geom",whichgeom);
  EBIndexSpace* ebisPtr = Chombo_EBIS::instance();

  if (whichgeom == 0)
    {
      //allregular
      pout() << "all regular geometry" << endl;
      AllRegularService regserv;
      ebisPtr->define(a_domain, origin, dx, regserv);
    }
  else if (whichgeom == 1)
    {
      pout() << "ramp geometry" << endl;
      int upDir;
      int indepVar;
      Real startPt;
      Real slope;
      pp.get("up_dir",upDir);
      pp.get("indep_var",indepVar);
      pp.get("start_pt", startPt);
      pp.get("ramp_slope", slope);

      RealVect normal = RealVect::Zero;
      normal[upDir] = 1.0;
      normal[indepVar] = -slope;

      RealVect point = RealVect::Zero;
      point[upDir] = -slope*startPt;

      bool normalInside = true;

      PlaneIF ramp(normal,point,normalInside);

      GeometryShop workshop(ramp,verbosity,dxVect);
      //this generates the new EBIS
      ebisPtr->define(a_domain, origin, dx, workshop);
    }
  else if (whichgeom == 5)
    {
      pout() << "sphere geometry" << endl;
      vector<Real> sphere_center(SpaceDim);
      pp.getarr("sphere_center",sphere_center, 0, SpaceDim);
      RealVect sphereCenter;
      for (int idir = 0; idir < SpaceDim; idir++)
        {
          sphereCenter[idir] = sphere_center[idir];
        }
      Real sphereRadius;
      pp.get("sphere_radius", sphereRadius);

      bool     insideRegular = false;
      SphereIF implicit(sphereRadius,sphereCenter,insideRegular);
      GeometryShop workshop(implicit,verbosity,dxVect);
      //this generates the new EBIS
      ebisPtr->define(a_domain, origin, dx, workshop);
    }
  else if (whichgeom == 13)
    {
      pout() << "rhodonea geometry" << endl;
      vector<Real> tmp(SpaceDim);
      pp.getarr("rhodonea_center", tmp, 0, SpaceDim);
      RealVect rhodoneaCenter;
      for (int idir = 0; idir < SpaceDim; idir++)
        {
          rhodoneaCenter[idir] = tmp[idir];
        }
      Real innerRadius;
      pp.get("inner_radius", innerRadius);

      Real outerRadius;
      pp.get("outer_radius", outerRadius);

      int frequency;
      pp.get("frequency", frequency);

      bool     insideRegular = false;

      RhodoneaIF implicit(innerRadius, outerRadius, frequency,
                          rhodoneaCenter, insideRegular);

      GeometryShop workshop(implicit,verbosity,dxVect);
      //this generates the new EBIS
      ebisPtr->define(a_domain, origin, dx, workshop);
    }
  else if (whichgeom == 18)
    {
      pout() << "Low swirl burner geometry" << endl;
      //        AttachDebugger();

      Box domain;

      for (int idir = 0; idir < SpaceDim; idir++)
        {
          origin[idir] = prob_lo[idir];
        }

      Real outerRadius;
      pp.get("outer_radius",outerRadius);

      Real outerThick;
      pp.get("outer_thick",outerThick);

      Real outerHeight;
      pp.get("outer_height",outerHeight);

      Real outerOffset = ((prob_hi - prob_lo[0]) - outerHeight) / 2.0 + prob_lo[0];

      Real innerRadius;
      pp.get("inner_radius",innerRadius);

      Real innerThick;
      pp.get("inner_thick",innerThick);

      Real innerOffset = 0.0;
      innerOffset += outerOffset;

      Real innerHeight;
      pp.get("inner_height",innerHeight);

      Real plateHeight;
      pp.get("plate_height",plateHeight);
      plateHeight += outerOffset;

      Real plateThick;
      pp.get("plate_thick",plateThick);

      int doHoles;
      pp.get("do_holes",doHoles);

      Real holeRadius;
      pp.get("hole_radius",holeRadius);

      Real holeSpace;
      pp.get("hole_space",holeSpace);

      int vaneNum;
      pp.get("vane_num",vaneNum);

      Real vaneThick;
      pp.get("vane_thick",vaneThick);

      RealVect vaneNorm;

      Vector<Real> vectVaneNorm;
      pp.getarr("vane_norm",vectVaneNorm,0,SpaceDim);

      for (int idir = 0; idir < SpaceDim; idir++)
        {
          vaneNorm[idir] = vectVaneNorm[idir];
        }

      Real vaneOffset;
      pp.get("vane_offset",vaneOffset);

      Real vaneHeight = innerHeight - 2*vaneOffset;

      vaneOffset += outerOffset;

      // Make the outer chamber
      BaseIF* outerChamber = makeChamber(outerRadius,outerThick,
                                         outerOffset,outerHeight);

      // Make the inner chamber
      BaseIF* innerChamber = makeChamber(innerRadius,innerThick,
                                         innerOffset,innerHeight);

      // Make the inner plate with holes
      BaseIF* holyPlate = makePlate(plateHeight,plateThick,innerRadius,
                                    doHoles,holeRadius,holeSpace);

      // Make the vanes
      BaseIF* vanes = makeVanes(vaneNum,vaneThick,vaneNorm,innerRadius,outerRadius,
                                vaneOffset,vaneHeight);

      // Union all the pieces together
      Vector<BaseIF*> pieces;

      pieces.push_back(outerChamber);
      pieces.push_back(innerChamber);
      pieces.push_back(holyPlate);
      pieces.push_back(vanes);

      UnionIF swirl(pieces);
      ComplementIF outside(swirl,true);

      GeometryShop workshop(outside,verbosity,dxVect);

      // This generates the new EBIS
      EBIndexSpace* ebisPtr = Chombo_EBIS::instance();
      ebisPtr->define(a_domain, origin, dx, workshop);

    }
  else
    {
      //bogus which_geom
      pout() << " bogus which_geom input = " << whichgeom;
      eekflag = 33;
    }

  return eekflag;
}
Beispiel #30
0
int checkEBISBox(const Box& a_gridCoar, const EBISBox& a_ebisBoxCoar, const EBISBox& a_ebisBoxFine)
{
  IntVectSet ivs = a_ebisBoxCoar.getIrregIVS(a_gridCoar);
  Real dxCoar = 2;  Real dxFine = 1;

#if CH_SPACEDIM==2
  Real areaFineCell = dxFine;
  Real areaCoarCell = dxCoar;
  Real voluFineCell = dxFine*dxFine;
  Real voluCoarCell = dxCoar*dxCoar;
#elif CH_SPACEDIM==3
  Real areaFineCell = dxFine*dxFine;
  Real areaCoarCell = dxCoar*dxCoar;
  Real voluFineCell = dxFine*dxFine*dxFine;
  Real voluCoarCell = dxCoar*dxCoar*dxCoar;
#else
  MayDay::Error();
#endif
  int retval = 0;
  for (VoFIterator vofit(ivs, a_ebisBoxCoar.getEBGraph()); vofit.ok(); ++vofit)
    {
      const VolIndex&  vofCoar = vofit();
      Vector<VolIndex> vofsFine = a_ebisBoxCoar.refine(vofCoar);

      //check the easy bits
      Real volumCoar = a_ebisBoxCoar.volFrac(  vofCoar);
      RealVect areaCritCoar = a_ebisBoxCoar.bndryArea(vofCoar)*
                              a_ebisBoxCoar.normal(vofCoar);
      Real volumFine = 0;
      RealVect areaCritFine = RealVect::Zero;
      for (int ivof = 0; ivof < vofsFine.size(); ivof++)
        {
          volumFine += a_ebisBoxFine.volFrac(  vofsFine[ivof]);
          areaCritFine += a_ebisBoxFine.bndryArea(vofsFine[ivof])*
                          a_ebisBoxFine.normal(vofsFine[ivof]);
        }
      volumFine *= voluFineCell;
      areaCritFine *= areaFineCell;
      volumCoar *= voluCoarCell;
      areaCritCoar *= areaCoarCell;
      Real tolerance = 1.0e-10;
      if (Abs(volumFine -volumCoar) > tolerance*volumCoar)
        {
          pout() << "volume problem in coar cell " << vofCoar.gridIndex() << endl;
          retval = -1;
        }

      // Real maxCc  = 0.0;
      // Real maxDev = 0.0;
      for (int idir=0; idir<SpaceDim; idir++)
        {
          if (Abs(areaCritFine[idir]-areaCritCoar[idir]) >
             tolerance*Abs(areaCritCoar[idir]))
            {
              pout() << "bndry area problem in coar cell " << vofCoar.gridIndex() << endl;
              retval = -2;
            }
        }
      //centroids are a bit uglier to test
//      RealVect bndryCentroidCoar = a_ebisBoxCoar.bndryCentroid(  vofCoar);
//      RealVect bndryCentroidFine = RealVect::Zero;

      //the areas are somewhat more painful to test
//      for (int idir = 0; idir < SpaceDim; idir++)
//        {
//
//        }
    }

  return retval;
}