Exemplo n.º 1
0
void TextCanvas::apply_shortcut(const QString & s)
{
    if (s == "Upper")
        upper();
    else if (s == "Lower")
        lower();
    else if (s == "Go up")
        z_up();
    else if (s == "Go down")
        z_down();
    else if (s == "Edit") {
        open();  // call package_modified
        return;
    }
    else
        return;

    // force son reaffichage
    hide();
    show();
    canvas()->update();

    package_modified();
}
Exemplo n.º 2
0
void SdLifeLineCanvas::exec_menu(int rank) {
  double old_z = z();
  
  switch (rank) {
  case 0:
    SdDurationCanvas::propag_visible(durations, FALSE);
    upper();
    SdDurationCanvas::propag_visible(durations, TRUE);
    break;
  case 1:
    lower();
    break;
  case 2:
    SdDurationCanvas::propag_visible(durations, FALSE);
    z_up();
    SdDurationCanvas::propag_visible(durations, TRUE);
    break;
  case 3:
    z_down();
    break;
  default:
    return;
  }
  
  double dz = z() - old_z;
  
  if (dz != 0) {
    SdDurationCanvas::propag_dz(durations, dz);
  
    // force son reaffichage
    hide();
    show();
    canvas()->update();
    package_modified();
  }
}
Exemplo n.º 3
0
void SdSelfMsgCanvas::apply_shortcut(QString s) {
    if (s == "Upper")
        upper();
    else if (s == "Lower")
        lower();
    else if (s == "Go up")
        z_up();
    else if (s == "Go down")
        z_down();
    else if (s == "Edit drawing settings") {
        edit_drawing_settings();
        return;
    }
    else if (s == "Edit")
        open();
    else
        return;

    // force son reaffichage
    hide();
    show();
    package_modified();
    canvas()->update();
}
Exemplo n.º 4
0
void NoteCanvas::apply_shortcut(QString s)
{
    if (s == "Upper")
        upper();
    else if (s == "Lower")
        lower();
    else if (s == "Go up")
        z_up();
    else if (s == "Go down")
        z_down();
    else if (s == "Edit drawing settings") {
        edit_drawing_settings();
        return;
    }
    else if (s == "Edit") {
        open();  // call modified then package_modified
        return;
    }
    else
        return;

    modified();
    package_modified();
}
Exemplo n.º 5
0
MultiMooseEnum &
MultiMooseEnum::assign(InputIterator first, InputIterator last, bool append)
{
  if (!append)
    clear();

  std::copy(first, last, std::back_inserter(_current_names_preserved));
  for (InputIterator it = first; it != last; ++it)
  {
    std::string upper(*it);
    std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper);

    checkDeprecatedBase(upper);

    _current_names.insert(upper);

    if (std::find(_names.begin(), _names.end(), upper) == _names.end())
    {
      if (_out_of_range_index == 0)     // Are out of range values allowed?
        mooseError("Invalid option \"" << upper << "\" in MultiMooseEnum.  Valid options (not case-sensitive) are \"" << _raw_names << "\".");
      else
      {
        // Allow values assigned outside of the enumeration range
        _names.push_back(upper);

        int current_id = _out_of_range_index++;
        _name_to_id[upper] = current_id;

        _current_ids.push_back(current_id);
      }
    }
    else
      _current_ids.push_back(_name_to_id[upper]);
  }
  return *this;
}
Exemplo n.º 6
0
void LCD_PutCmd ( unsigned int c )
{
	GPIO->P[COM_PORT].DOUTCLR = 1 << LCD_RS;
/* this subroutine works specifically for 4-bit Port A */
	upper ( c ); /* send high nibble */
	delay(1);
	LCD_PulseEnable();

	//delay(2);
	lower ( c ); /* send low nibble */
	LCD_PulseEnable();
	//delay(2);

//		if(c & 0x80) GPIO->P[COM_PORT].DOUTSET = 1 << LCD_D7; else GPIO->P[COM_PORT].DOUTCLR = 1 << LCD_D7;
//		if(c & 0x40) GPIO->P[COM_PORT].DOUTSET = 1 << LCD_D6; else GPIO->P[COM_PORT].DOUTCLR = 1 << LCD_D6;
//		if(c & 0x20) GPIO->P[COM_PORT].DOUTSET = 1 << LCD_D5; else GPIO->P[COM_PORT].DOUTCLR = 1 << LCD_D5;
//		if(c & 0x10) GPIO->P[COM_PORT].DOUTSET = 1 << LCD_D4; else GPIO->P[COM_PORT].DOUTCLR = 1 << LCD_D4;
//
//		if(c & 0x08) GPIO->P[COM_PORT].DOUTSET = 1 << LCD_D3; else GPIO->P[COM_PORT].DOUTCLR = 1 << LCD_D3;
//		if(c & 0x04) GPIO->P[COM_PORT].DOUTSET = 1 << LCD_D2; else GPIO->P[COM_PORT].DOUTCLR = 1 << LCD_D2;
//		if(c & 0x02) GPIO->P[COM_PORT].DOUTSET = 1 << LCD_D1; else GPIO->P[COM_PORT].DOUTCLR = 1 << LCD_D1;
//		if(c & 0x01) GPIO->P[COM_PORT].DOUTSET = 1 << LCD_D0; else GPIO->P[COM_PORT].DOUTCLR = 1 << LCD_D0;

}
Exemplo n.º 7
0
    void TripleBandLinearOp::axpyb(const Array& a,
                                   const TripleBandLinearOp& x,
                                   const TripleBandLinearOp& y,
                                   const Array& b) {
        const Size size = mesher_->layout()->size();

        Real *diag(diag_.get());
        Real *lower(lower_.get());
        Real *upper(upper_.get());

        const Real *y_diag (y.diag_.get());
        const Real *y_lower(y.lower_.get());
        const Real *y_upper(y.upper_.get());

        if (a.empty()) {
            if (b.empty()) {
                //#pragma omp parallel for
                for (Size i=0; i < size; ++i) {
                    diag[i]  = y_diag[i];
                    lower[i] = y_lower[i];
                    upper[i] = y_upper[i];
                }
            }
            else {
                Array::const_iterator bptr(b.begin());
                const Size binc = (b.size() > 1) ? 1 : 0;
                //#pragma omp parallel for
                for (Size i=0; i < size; ++i) {
                    diag[i]  = y_diag[i] + bptr[i*binc];
                    lower[i] = y_lower[i];
                    upper[i] = y_upper[i];
                }
            }
        }
        else if (b.empty()) {
            Array::const_iterator aptr(a.begin());
            const Size ainc = (a.size() > 1) ? 1 : 0;

            const Real *x_diag (x.diag_.get());
            const Real *x_lower(x.lower_.get());
            const Real *x_upper(x.upper_.get());

            //#pragma omp parallel for
            for (Size i=0; i < size; ++i) {
                const Real s = aptr[i*ainc];
                diag[i]  = y_diag[i]  + s*x_diag[i];
                lower[i] = y_lower[i] + s*x_lower[i];
                upper[i] = y_upper[i] + s*x_upper[i];
            }
        }
        else {
            Array::const_iterator bptr(b.begin());
            const Size binc = (b.size() > 1) ? 1 : 0;

            Array::const_iterator aptr(a.begin());
            const Size ainc = (a.size() > 1) ? 1 : 0;

            const Real *x_diag (x.diag_.get());
            const Real *x_lower(x.lower_.get());
            const Real *x_upper(x.upper_.get());

            //#pragma omp parallel for
            for (Size i=0; i < size; ++i) {
                const Real s = aptr[i*ainc];
                diag[i]  = y_diag[i]  + s*x_diag[i] + bptr[i*binc];
                lower[i] = y_lower[i] + s*x_lower[i];
                upper[i] = y_upper[i] + s*x_upper[i];
            }
        }
    }
Exemplo n.º 8
0
void textedit_trigger ( struct widget *self,
                        s32 type,
                        union trigparam *param) {
    int key;
    struct cursor * c;
    u32 v_height, v_top;
    struct font_metrics m;

    switch (type) {
    case PG_TRIGGER_DEACTIVATE:
        UNSET_FLAG(DATA->flags, TEXT_WIDGET_FOCUS);
        UNSET_FLAG(DATA->flags, TEXT_WIDGET_FLASH_ON);
        break;
    case PG_TRIGGER_ACTIVATE:
        SET_FLAG(DATA->flags, TEXT_WIDGET_FOCUS);
        SET_FLAG(DATA->flags, TEXT_WIDGET_FLASH_ON);
        post_event(PG_WE_FOCUS,self,1,0,NULL);
        /* Fall into PG_TRIGGER_TIMER to set up cursor flash */
    case PG_TRIGGER_TIMER:
        if (!DATA->cursor_state)
            DATA->cursor_state++;
        else
            DATA->cursor_state--;
        DATA->cursor_grop->param[0] = VID(color_pgtohwr)(DATA->cursor_state ? 
                                                         CURSORCOLOR_ON :
                                                         CURSORCOLOR_OFF );
        add_update_region(self,
                          DATA->cursor_grop->r.x,
                          DATA->cursor_grop->r.y,
                          DATA->cursor_grop->r.w,
                          DATA->cursor_grop->r.h);
        if (GET_FLAG(DATA->flags, TEXT_WIDGET_FLASH_ON)) {
            /* Reset timer */
            DATA->cursor_grop->r.w = CURSORWIDTH;
            install_timer(self, (DATA->cursor_state ? FLASHTIME_ON : 
                                 FLASHTIME_OFF ));
        } else { 
            DATA->cursor_grop->r.w = 0;
         }
        break;
    case PG_TRIGGER_DOWN:
        if (!GET_FLAG(DATA->flags, TEXT_WIDGET_FOCUS))
             request_focus(self);
        if (!GET_FLAG(DATA->flags, TEXT_WIDGET_READONLY)) {
            if (param->mouse.x - self->in->div->r.x < DATA->width) {
                /* Move cursor. */
                DATA->thumb_drag_start = -1;
                text_backend_cursor_move_xy ( DATA, 
                                              param->mouse.x - self->in->div->r.x,
                                              param->mouse.y - self->in->div->r.y);
                grop_render(self->in->div, NULL);
            } else {
                text_backend_selection_unset(DATA);
                v_height = MAX(DATA->v_height, 
                               DATA->cursor_v_y + DATA->cursor_grop->r.h);
                
                /* In scrollbar region */
                if ((param->mouse.y - self->in->div->r.y < DATA->thumb_top) ||
                    (param->mouse.y - self->in->div->r.y >
                     DATA->thumb_top + DATA->thumb_size)) {
                    /* Page up or down */
                    if (param->mouse.y - self->in->div->r.y < DATA->thumb_top)
                        DATA->thumb_top -= DATA->thumb_size;
                    else 
                        DATA->thumb_top += DATA->thumb_size;
                    DATA->thumb_top = MAX(0, MIN(DATA->thumb_top, 
                                                 DATA->height - 
                                                 DATA->thumb_size));
                    v_top = (v_height * DATA->thumb_top) / DATA->height;
                    /* Round to full screen lines */
                    DATA->fd->lib->getmetrics(DATA->fd,&m);
                    if (v_top % m.lineheight) {
                        v_top = (v_top  - v_top % m.lineheight) +
                            m.lineheight;
                    }
                    if (v_top != DATA->v_y_top) {
                        DATA->scroll_lock = 1;                
                        text_backend_set_v_top(DATA, v_top);
                        DATA->scroll_lock = 0;
                    }
                    div_rebuild(self->in->div->div);
                    update(NULL,1);
                } else {
                    DATA->thumb_drag_start = 
                        (param->mouse.y - self->in->div->r.y) - 
                        DATA->thumb_top;
                }
            }
        } 
        break;
    case PG_TRIGGER_DRAG:
        if (param->mouse.btn) {
            if (DATA->thumb_drag_start < 0) {
                text_backend_selection_xy( DATA,
                                           param->mouse.x - self->in->div->r.x,
                                           param->mouse.y - self->in->div->r.y );
            } else {
                v_height = MAX(DATA->v_height, 
                               DATA->cursor_v_y + DATA->cursor_grop->r.h);
                DATA->thumb_top = param->mouse.y - 
                    self->in->div->r.y -
                    DATA->thumb_drag_start;
                DATA->thumb_top = MAX(0, MIN(DATA->thumb_top, 
                                             DATA->height - DATA->thumb_size));
                DATA->thumb_drag_start = param->mouse.y -
                    self->in->div->r.y -
                    DATA->thumb_top;
                v_top = (v_height * DATA->thumb_top) / DATA->height;
                /* Round to full screen lines */
                DATA->fd->lib->getmetrics(DATA->fd,&m);
                if (v_top % m.lineheight) {
                    v_top = (v_top  - v_top % m.lineheight) +
                                              m.lineheight;
                }
                if (v_top != DATA->v_y_top) {
                    DATA->scroll_lock = 1;  
                    text_backend_set_v_top(DATA, v_top);
                    DATA->scroll_lock = 0;  
                }
                div_rebuild(self->in->div->div);
                update(NULL,1);
            }
        }
        break;
    case PG_TRIGGER_KEYUP:
        if (GET_FLAG(DATA->flags, TEXT_WIDGET_READONLY) ||
            !GET_FLAG(DATA->flags, TEXT_WIDGET_FOCUS))
            return;
        param->kbd.consume++;
        return;
    case PG_TRIGGER_KEYDOWN:
        if (GET_FLAG(DATA->flags, TEXT_WIDGET_READONLY) ||
            !GET_FLAG(DATA->flags, TEXT_WIDGET_FOCUS))
            return;
        param->kbd.consume++;
        key = param->kbd.key;

        switch(key) {
#ifdef DEBUG_TEXTEDIT 
        case PGKEY_F1:
            print_data(DATA);
            break;
        case PGKEY_F2:
            print_tree(DATA);
            break;
        case PGKEY_F3:
            print_block(DATA, DATA->current);
            break;
#endif /* DEBUG_TEXTEDIT */
        case PGKEY_RETURN:
            text_backend_insert_char(DATA, '\n');
            break;
        case PGKEY_BACKSPACE:
        case PGKEY_DELETE:
            /* Screw "backspace" vs. "delete". This is my widget, and
             * I say they're going to be the same thing. So, there. */
            text_backend_delete_char(DATA);
            break;
        case PGKEY_TAB:
            if (param->kbd.mods & PGMOD_SHIFT) {
                /* Post event to app */
                post_event(PG_WE_ACTIVATE,self,0,0,NULL);
                param->kbd.consume--;
                return;
            } else {
                text_backend_insert_char(DATA, '\t');
            }
            break;
        case PGKEY_UP:
        case PGKEY_DOWN:
        case PGKEY_RIGHT:
        case PGKEY_LEFT: 
        case PGKEY_HOME:
        case PGKEY_END:
        case PGKEY_PAGEUP:
        case PGKEY_PAGEDOWN: 
            /* CURSOR_UP etc. match the PGKEY_UP etc. values */
            if (param->kbd.mods & PGMOD_SHIFT)
                text_backend_selection_dir(DATA, key);
            else
                text_backend_cursor_move_dir(DATA, key);
            break;
        default:
            if ((key >= PGKEY_SPACE) && (key <= PGKEY_WORLD_95)) {
                if (param->kbd.mods & (PGMOD_SHIFT | PGMOD_CAPS)) {
                    key = upper(key);
                }
		/* if ctrl key is pressed*/
		if (param->kbd.mods & PGMOD_CTRL) {
		  text_backend_cut_copy_paste(DATA, key);
		}
                else {
		  text_backend_insert_char(DATA, key);
		}
            } else {
                /* Post key to app */
                post_event(PG_WE_ACTIVATE,self,0,0,NULL);
                param->kbd.consume--;
                return;
            }
        }
    }
    textedit_draw_update(self);
    //update(NULL,1);
}
Exemplo n.º 9
0
/*
 * Process a text input stream for plot commands
 */
void
SciPlotReadDataFile(Widget parent, FILE * fd)
{
  int count;
  PlotDialogData *working;
  float xlist[10], ylist[10];
  int line[256], linecount = 0;
  Boolean readnext;
  int num, i;

  working = NULL;
  count = getfields(fd);
  while (count > 0) {
    if (count > 0) {
      readnext = True;
      upper(field[0]);
      if (strcmp(field[0], "TITLE") == 0 || strcmp(field[0], "NEW") == 0 ) {
          /* Pop up the last dialog if it exists */
        if (working) SciPlotDialogInternalPopup(working);
        
	working = SciPlotDialogInternal(parent, field[1]);
	for (i = 0; i < NUM_COLORS; i++) {
	  colors_list[i].num = SciPlotAllocNamedColor(working->plot, colors_list[i].text);
	}
	linecount = 0;
      }
      else if (strcmp(field[0], "POLAR") == 0) {
	Boolean degflag;

	degflag = True;
	if (count > 1) {
	  upper(field[1]);
	  if (strncmp(field[1], "RAD", 3) == 0)
	    degflag = False;
	}
	XtVaSetValues(working->plot,
	  XtNchartType, XtPOLAR,
	  XtNdegrees, degflag,
	  NULL);
      }
      else if (strcmp(field[0], "XAXIS") == 0) {
	if (working) {
            if (count > 1) XtVaSetValues(working->plot, XtNxLabel, field[1], NULL);
            if (count>2) {
                for (i=2; i<count; i++) {
                    upper(field[i]);
                    if (strcmp(field[i], "LOG") == 0)
                        XtVaSetValues(working->plot, XtNxLog, True, NULL);
                    else if (strcmp(field[i], "NOZERO") == 0)
                        XtVaSetValues(working->plot, XtNxOrigin, False, NULL);
                }
            }
        }
      }
      else if (strcmp(field[0], "YAXIS") == 0) {
	if (working) {
            if (count > 1) XtVaSetValues(working->plot, XtNyLabel, field[1], NULL);
            if (count>2) {
                for (i=2; i<count; i++) {
                    upper(field[i]);
                    if (strcmp(field[i], "LOG") == 0)
                        XtVaSetValues(working->plot, XtNyLog, True, NULL);
                    else if (strcmp(field[i], "NOZERO") == 0)
                        XtVaSetValues(working->plot, XtNyOrigin, False, NULL);
                }
            }
        }
      }
      else if (strcmp(field[0], "LEGEND") == 0) {
	int colorcount, markercount, linestyle;

	if (working && count > 1) {
	  if (count >= 4) {
	    XtVaSetValues(working->plot,
	      XtNxLabel, field[2],
	      XtNyLabel, field[3],
	      NULL);
	  }
	  line[0] = SciPlotListCreateFromFloat(working->plot, 0, NULL, NULL, field[1]);
	  do {
	    count = getfields(fd);
	    readnext = False;

	    num = checkfloat(0);
	    if (count > 0 && num) {
	      tofloat(count);
	      xlist[0] = ffield[0];
	      ylist[0] = ffield[1];
	      SciPlotListAddFloat(working->plot, line[0], 1, xlist, ylist);
	    }

	  } while (count > 0 && num);
	  colorcount = linecount % NUM_COLORS;
	  markercount = linecount % NUM_MARKERS;
	  linestyle = -1;
	  SciPlotListSetStyle(working->plot, line[0],
	    colors_list[colorcount].num, marker_list[markercount].num,
	    colors_list[colorcount].num, linestyle);
	  linecount++;
	}

      }
      else if (strcmp(field[0], "LINE") == 0) {
	int colorcount, markercount, linestyle, maxlines;
        Boolean skip;
        
	if (working && count > 1) {
	  for (i = 1; i < count; i++) {
	    line[i] = SciPlotListCreateFromFloat(working->plot, 0, NULL, NULL, field[i]);
	  }
	  maxlines = count;

	  do {
	    count = getfields(fd);
	    readnext = False;

	    num = checkfloat(0);
            if (strcmp(field[0],"skip")==0) skip=True;
            else skip=False;
            
	    if (count > 0 && (num || skip)) {
              if (skip) {
                for (i = 1; i < maxlines; i++) {
                  xlist[0] = ylist[0] = SCIPLOT_SKIP_VAL;
                  SciPlotListAddFloat(working->plot, line[i], 1, xlist, ylist);
                }
              }
              else {
                tofloat(count);
                xlist[0] = ffield[0];
                for (i = 1; i < maxlines; i++) {
                  ylist[0] = ffield[i];
                  SciPlotListAddFloat(working->plot, line[i], 1, xlist, ylist);
                }
              }
              
	    }
	  } while (count > 0 && (num || skip));
	  for (i = 1; i < maxlines; i++) {
	    linecount++;
	    colorcount = linecount % NUM_COLORS;
	    markercount = linecount % NUM_MARKERS;
	    linestyle = -1;
	    SciPlotListSetStyle(working->plot, line[i],
	      colors_list[colorcount].num, marker_list[markercount].num,
	      colors_list[colorcount].num, linestyle);
/*             SciPlotListSetMarkerSize(working->plot, line[i], (float) linecount*4); */
	  }
	}

      }
    }
    if (readnext)
      count = getfields(fd);
  }
  if (working) SciPlotDialogInternalPopup(working);
}
    void TestCaBasedSquareMonolayer()
    {
        PottsMeshGenerator<2> generator(10, 0, 0, 10, 0, 0);
        PottsMesh<2>* p_mesh = generator.GetMesh();

        // Scale so cells are on top of those in the above centre based tests
        p_mesh->Scale(1.0,sqrt(3.0)*0.5);

        // Specify where cells lie
        std::vector<unsigned> location_indices;
        for (unsigned i=0; i<100; i++)
        {
            location_indices.push_back(i);
        }

        std::vector<CellPtr> cells;
        MAKE_PTR(DifferentiatedCellProliferativeType, p_differentiated_type);
        CellsGenerator<UniformCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, location_indices.size(), p_differentiated_type);

        // Make cells with x<5.0 apoptotic (so no source term)
        boost::shared_ptr<AbstractCellProperty> p_apoptotic_property =
            cells[0]->rGetCellPropertyCollection().GetCellPropertyRegistry()->Get<ApoptoticCellProperty>();
        for (unsigned i=0; i<cells.size(); i++)
        {
            c_vector<double,2> cell_location;
            cell_location = p_mesh->GetNode(i)->rGetLocation();
            if (cell_location(0) < 5.0)
            {
                cells[i]->AddCellProperty(p_apoptotic_property);
            }
            // Set initial condition for PDE
            cells[i]->GetCellData()->SetItem("variable",1.0);
        }
        TS_ASSERT_EQUALS(p_apoptotic_property->GetCellCount(), 50u);

        CaBasedCellPopulation<2> cell_population(*p_mesh, cells, location_indices);

        // Set up simulation time for file output
        SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 10);

        // Create PDE and boundary condition objects
        MAKE_PTR_ARGS(AveragedSourceParabolicPde<2>, p_pde, (cell_population, 0.1, 1.0, -1.0));
        MAKE_PTR_ARGS(ConstBoundaryCondition<2>, p_bc, (1.0));

        // Create a ChasteCuboid on which to base the finite element mesh used to solve the PDE
        ChastePoint<2> lower(-5.0, -5.0);
        ChastePoint<2> upper(15.0, 15.0);
        MAKE_PTR_ARGS(ChasteCuboid<2>, p_cuboid, (lower, upper));

        // Create a PDE modifier and set the name of the dependent variable in the PDE
        MAKE_PTR_ARGS(ParabolicBoxDomainPdeModifier<2>, p_pde_modifier, (p_pde, p_bc, false, p_cuboid));
        p_pde_modifier->SetDependentVariableName("variable");

        // For coverage, output the solution gradient
        p_pde_modifier->SetOutputGradient(true);
        p_pde_modifier->SetupSolve(cell_population,"TestAveragedParabolicPdeWithNodeOnSquare");

        // Run for 10 time steps
        for (unsigned i=0; i<10; i++)
        {
            SimulationTime::Instance()->IncrementTimeOneStep();
            p_pde_modifier->UpdateAtEndOfTimeStep(cell_population);
            p_pde_modifier->UpdateAtEndOfOutputTimeStep(cell_population);
        }

        // Test the solution at some fixed points to compare with other cell populations
        CellPtr p_cell_0 = cell_population.GetCellUsingLocationIndex(0);
        TS_ASSERT_DELTA(cell_population.GetLocationOfCellCentre(p_cell_0)[0], 0, 1e-4);
        TS_ASSERT_DELTA(cell_population.GetLocationOfCellCentre(p_cell_0)[1], 0.0, 1e-4);
        TS_ASSERT_DELTA( p_cell_0->GetCellData()->GetItem("variable"), 0.8513, 2e-2); // Low tolerance as mesh is slightly larger than for off-lattice models

        // Checking it doesn't change for this cell population
        TS_ASSERT_DELTA(p_cell_0->GetCellData()->GetItem("variable"), 0.8343, 1e-4);
    }
    void TestArchiveParabolicBoxDomainPdeModifier()
    {
        // Create a file for archiving
        OutputFileHandler handler("archive", false);
        handler.SetArchiveDirectory();
        std::string archive_filename = handler.GetOutputDirectoryFullPath() + "ParabolicBoxDomainPdeModifier.arch";

        // Separate scope to write the archive
        {
            // Create PDE and boundary condition objects
            MAKE_PTR_ARGS(UniformSourceParabolicPde<2>, p_pde, (-0.1));
            MAKE_PTR_ARGS(ConstBoundaryCondition<2>, p_bc, (1.0));

            // Create a ChasteCuboid on which to base the finite element mesh used to solve the PDE
            ChastePoint<2> lower(-10.0, -10.0);
            ChastePoint<2> upper(10.0, 10.0);
            MAKE_PTR_ARGS(ChasteCuboid<2>, p_cuboid, (lower, upper));

            // Create a PDE modifier and set the name of the dependent variable in the PDE
            std::vector<double> data(10);
            for (unsigned i=0; i<10; i++)
            {
                data[i] = i + 0.45;
            }
            Vec vector = PetscTools::CreateVec(data);
            ParabolicBoxDomainPdeModifier<2> modifier(p_pde, p_bc, false, p_cuboid, 2.0, vector);
            modifier.SetDependentVariableName("averaged quantity");

            // Create an output archive
            std::ofstream ofs(archive_filename.c_str());
            boost::archive::text_oarchive output_arch(ofs);

            // Serialize via pointer
            AbstractCellBasedSimulationModifier<2,2>* const p_modifier = &modifier;
            output_arch << p_modifier;
        }

        // Separate scope to read the archive
        {
            AbstractCellBasedSimulationModifier<2,2>* p_modifier2;

            // Restore the modifier
            std::ifstream ifs(archive_filename.c_str());
            boost::archive::text_iarchive input_arch(ifs);

            input_arch >> p_modifier2;

            // Test that member variables are correct
            TS_ASSERT_EQUALS((static_cast<ParabolicBoxDomainPdeModifier<2>*>(p_modifier2))->rGetDependentVariableName(), "averaged quantity");
            TS_ASSERT_DELTA((static_cast<ParabolicBoxDomainPdeModifier<2>*>(p_modifier2))->GetStepSize(), 2.0, 1e-5);
            TS_ASSERT_EQUALS((static_cast<ParabolicBoxDomainPdeModifier<2>*>(p_modifier2))->AreBcsSetOnBoxBoundary(), true);

            Vec solution = (static_cast<ParabolicBoxDomainPdeModifier<2>*>(p_modifier2))->GetSolution();
            ReplicatableVector solution_repl(solution);

            TS_ASSERT_EQUALS(solution_repl.GetSize(), 10u);
            for (unsigned i=0; i<10; i++)
            {
                TS_ASSERT_DELTA(solution_repl[i], i + 0.45, 1e-6);
            }

            delete p_modifier2;
        }
    }
Exemplo n.º 12
0
void b2VoronoiDiagram::Generate(float32 radius)
{
	b2Assert(m_diagram == NULL);
	float32 inverseRadius = 1 / radius;
	b2Vec2 lower(+b2_maxFloat, +b2_maxFloat);
	b2Vec2 upper(-b2_maxFloat, -b2_maxFloat);
	for (int32 k = 0; k < m_generatorCount; k++)
	{
		Generator& g = m_generatorBuffer[k];
		lower = b2Min(lower, g.center);
		upper = b2Max(upper, g.center);
	}
	m_countX = 1 + (int32) (inverseRadius * (upper.x - lower.x));
	m_countY = 1 + (int32) (inverseRadius * (upper.y - lower.y));
	m_diagram = (Generator**)
		m_allocator->Allocate(sizeof(Generator*) * m_countX * m_countY);
	for (int32 i = 0; i < m_countX * m_countY; i++)
	{
		m_diagram[i] = NULL;
	}
	b2StackQueue<b2VoronoiDiagramTask> queue(
		m_allocator, 4 * m_countX * m_countX);
	for (int32 k = 0; k < m_generatorCount; k++)
	{
		Generator& g = m_generatorBuffer[k];
		g.center = inverseRadius * (g.center - lower);
		int32 x = b2Max(0, b2Min((int32) g.center.x, m_countX - 1));
		int32 y = b2Max(0, b2Min((int32) g.center.y, m_countY - 1));
		queue.Push(b2VoronoiDiagramTask(x, y, x + y * m_countX, &g));
	}
	while (!queue.Empty())
	{
		int32 x = queue.Front().m_x;
		int32 y = queue.Front().m_y;
		int32 i = queue.Front().m_i;
		Generator* g = queue.Front().m_generator;
		queue.Pop();
		if (!m_diagram[i])
		{
			m_diagram[i] = g;
			if (x > 0)
			{
				queue.Push(b2VoronoiDiagramTask(x - 1, y, i - 1, g));
			}
			if (y > 0)
			{
				queue.Push(b2VoronoiDiagramTask(x, y - 1, i - m_countX, g));
			}
			if (x < m_countX - 1)
			{
				queue.Push(b2VoronoiDiagramTask(x + 1, y, i + 1, g));
			}
			if (y < m_countY - 1)
			{
				queue.Push(b2VoronoiDiagramTask(x, y + 1, i + m_countX, g));
			}
		}
	}
	int32 maxIteration = m_countX + m_countY;
	for (int32 iteration = 0; iteration < maxIteration; iteration++)
	{
		for (int32 y = 0; y < m_countY; y++)
		{
			for (int32 x = 0; x < m_countX - 1; x++)
			{
				int32 i = x + y * m_countX;
				Generator* a = m_diagram[i];
				Generator* b = m_diagram[i + 1];
				if (a != b)
				{
					queue.Push(b2VoronoiDiagramTask(x, y, i, b));
					queue.Push(b2VoronoiDiagramTask(x + 1, y, i + 1, a));
				}
			}
		}
		for (int32 y = 0; y < m_countY - 1; y++)
		{
			for (int32 x = 0; x < m_countX; x++)
			{
				int32 i = x + y * m_countX;
				Generator* a = m_diagram[i];
				Generator* b = m_diagram[i + m_countX];
				if (a != b)
				{
					queue.Push(b2VoronoiDiagramTask(x, y, i, b));
					queue.Push(b2VoronoiDiagramTask(x, y + 1, i + m_countX, a));
				}
			}
		}
		bool updated = false;
		while (!queue.Empty())
		{
			int32 x = queue.Front().m_x;
			int32 y = queue.Front().m_y;
			int32 i = queue.Front().m_i;
			Generator* k = queue.Front().m_generator;
			queue.Pop();
			Generator* a = m_diagram[i];
			Generator* b = k;
			if (a != b)
			{
				float32 ax = a->center.x - x;
				float32 ay = a->center.y - y;
				float32 bx = b->center.x - x;
				float32 by = b->center.y - y;
				float32 a2 = ax * ax + ay * ay;
				float32 b2 = bx * bx + by * by;
				if (a2 > b2)
				{
					m_diagram[i] = b;
					if (x > 0)
					{
						queue.Push(b2VoronoiDiagramTask(x - 1, y, i - 1, b));
					}
					if (y > 0)
					{
						queue.Push(b2VoronoiDiagramTask(x, y - 1, i - m_countX, b));
					}
					if (x < m_countX - 1)
					{
						queue.Push(b2VoronoiDiagramTask(x + 1, y, i + 1, b));
					}
					if (y < m_countY - 1)
					{
						queue.Push(b2VoronoiDiagramTask(x, y + 1, i + m_countX, b));
					}
					updated = true;
				}
			}
		}
		if (!updated)
		{
			break;
		}
	}
}
Exemplo n.º 13
0
void Foam::lduMatrix::operator-=(const lduMatrix& A)
{
    if (A.diagPtr_)
    {
        diag() -= A.diag();
    }

    if (symmetric() && A.symmetric())
    {
        upper() -= A.upper();
    }
    else if (symmetric() && A.asymmetric())
    {
        if (upperPtr_)
        {
            lower();
        }
        else
        {
            upper();
        }

        upper() -= A.upper();
        lower() -= A.lower();
    }
    else if (asymmetric() && A.symmetric())
    {
        if (A.upperPtr_)
        {
            lower() -= A.upper();
            upper() -= A.upper();
        }
        else
        {
            lower() -= A.lower();
            upper() -= A.lower();
        }

    }
    else if (asymmetric() && A.asymmetric())
    {
        lower() -= A.lower();
        upper() -= A.upper();
    }
    else if (diagonal())
    {
        if (A.upperPtr_)
        {
            upper() = -A.upper();
        }

        if (A.lowerPtr_)
        {
            lower() = -A.lower();
        }
    }
    else if (A.diagonal())
    {
    }
    else
    {
        if (debug > 1)
        {
            WarningIn("lduMatrix::operator-=(const lduMatrix& A)")
                << "Unknown matrix type combination" << nl
                << "    this :"
                << " diagonal:" << diagonal()
                << " symmetric:" << symmetric()
                << " asymmetric:" << asymmetric() << nl
                << "    A    :"
                << " diagonal:" << A.diagonal()
                << " symmetric:" << A.symmetric()
                << " asymmetric:" << A.asymmetric()
                << endl;
        }
    }
}
void Foam::BlockLduMatrix<Type>::segregateB
(
    TypeField& sMul,
    const TypeField& x
) const
{
    typedef typename TypeCoeffField::linearType linearType;
    typedef typename TypeCoeffField::squareType squareType;

    typedef typename TypeCoeffField::linearTypeField linearTypeField;
    typedef typename TypeCoeffField::squareTypeField squareTypeField;

    const unallocLabelList& u = lduAddr().upperAddr();
    const unallocLabelList& l = lduAddr().lowerAddr();

    // Diagonal multiplication
    if (thereIsDiag())
    {
        if (diag().activeType() == blockCoeffBase::SQUARE)
        {
            const squareTypeField& activeDiag = this->diag().asSquare();
            linearTypeField lf(activeDiag.size());
            squareTypeField sf(activeDiag.size());

            // Expand and contract
            contractLinear(lf, activeDiag);
            expandLinear(sf, lf);

            sMul -= (activeDiag - sf) & x;
        }
    }

    // Lower multiplication

    if (thereIsLower())
    {
        if (lower().activeType() == blockCoeffBase::SQUARE)
        {
            const squareTypeField& activeLower = this->lower().asSquare();

            // Auxiliary variables used in expand/contract
            linearType lt;
            squareType st;

            for (register label coeffI = 0; coeffI < u.size(); coeffI++)
            {
                contractLinear(lt, activeLower[coeffI]);
                expandLinear(st, lt);

                sMul[u[coeffI]] -= (activeLower[coeffI] - st) & x[l[coeffI]];
            }
        }
    }

    // Upper multiplication

    if (thereIsUpper())
    {
        if (upper().activeType() == blockCoeffBase::SQUARE)
        {
            const squareTypeField& activeUpper = this->upper().asSquare();

            // Auxiliary variables used in expand/contract
            linearType lt;
            squareType st;

            for (register label coeffI = 0; coeffI < u.size(); coeffI++)
            {
                contractLinear(lt, activeUpper[coeffI]);
                expandLinear(st, lt);

                sMul[l[coeffI]] -= (activeUpper[coeffI] - st) & x[u[coeffI]];
            }

            // If the matrix is symmetric, the lower triangular product
            // is also needed
            if (symmetric())
            {
                for (register label coeffI = 0; coeffI < u.size(); coeffI++)
                {
                    // Use transpose upper coefficient
                    contractLinear(lt, activeUpper[coeffI]);
                    expandLinear(st, lt);
                    sMul[u[coeffI]] -=
                        (activeUpper[coeffI].T() - st) & x[l[coeffI]];
                }
            }
        }
    }
}
Exemplo n.º 15
0
// Косметические преобразования строки пути.
// CheckFullPath используется в FCTL_SET[ANOTHER]PANELDIR
void PrepareDiskPath(string &strPath, bool CheckFullPath)
{
	// elevation not required during cosmetic operation
	SCOPED_ACTION(elevation::suppress);

	if (!strPath.empty())
	{
		if (strPath.size() > 1 && (strPath[1]==L':' || (IsSlash(strPath[0]) && IsSlash(strPath[1]))))
		{
			ReplaceSlashToBackslash(strPath);
			bool DoubleSlash = strPath[1]==L'\\';
			while(ReplaceStrings(strPath, L"\\\\"sv, L"\\"sv))
				;
			if(DoubleSlash)
			{
				strPath = L'\\' + strPath;
			}

			if (CheckFullPath)
			{
				strPath = ConvertNameToFull(strPath);

				size_t DirOffset = 0;
				const auto Type = ParsePath(strPath, &DirOffset);
				if (Type == root_type::unknown && HasPathPrefix(strPath))
				{
					DirOffset = 4;
				}

				size_t StartPos = DirOffset;

				if (StartPos < strPath.size())
				{
					string TmpStr;
					TmpStr.reserve(strPath.size());
					size_t LastPos = StartPos;
					const auto EndsWithSlash = IsSlash(strPath.back());

					for (size_t i = StartPos; i <= strPath.size(); ++i)
					{
						if ((i < strPath.size() && IsSlash(strPath[i])) || (i == strPath.size() && !EndsWithSlash))
						{
							TmpStr.assign(strPath, 0, i);
							os::fs::find_data fd;

							if (os::fs::get_find_data(TmpStr, fd))
							{
								strPath.replace(LastPos, i - LastPos, fd.FileName);
								i += fd.FileName.size() - (i - LastPos);
							}

							if (i != strPath.size())
							{
								LastPos = i + 1;
							}
						}
					}
				}
			}

			if (ParsePath(strPath) == root_type::drive_letter)
			{
				strPath[0] = upper(strPath[0]);
			}
		}
	}
}
Exemplo n.º 16
0
word do_menu(char *title, word width, word height, char *list[],
             word *result, bool(*reload)(char*, word*), char *preload )
{
    word i;
    word ev,key,mx,my;
    word currenty,currentx;
    word visible;
    word num;
    struct ws *menuw;
    char menu_so_far[MAXMENUWIDTH+1];		/* can, in theory, recurse */
    word numlist;

    if (preload==NULL)
        menu_so_far[0]=0;
    else
    {
        stccpy(menu_so_far,preload,MAXMENUWIDTH);
        strupr(menu_so_far);
    }
    currentx=strlen(menu_so_far);
    (reload)(menu_so_far,&numlist);		/* initial value */
    if (numlist==0)
    {
        *result=-1;
        return 0;
    }
    if ( (num=spare_window())==-1)
        return ERRM_NOSPARE;

    if (width>MAXMENUWIDTH)
        width=MAXMENUWIDTH;

    menuw=wlist[num];

    /* centered on screen */
    menuw->x=(maxw-width-2)/2;
    menuw->y=(maxh-height-2)/2;
    menuw->w=width+2;
    menuw->h=height+2;

    menuw->open=TRUE;
    menuw->number=num;
    menuw->type=WTYPE_DIALOG;
    menuw->magic=NULL;

    add_wlist(menuw);


    /* mark us on the screen, carefully as we are not in the wlist */
    window_cls(menuw);
    window_title2(menuw,title,FALSE);
    recalcw(menuw);
    update_rectangle(menuw->x,menuw->y,menuw->w,menuw->h);

    for (;;)
    {
p:
        visible=min(height,numlist);
        currenty=0;
        /* print the entries */
        for (i=0; i<visible; i++)
        {
            menuw->xpos=DLOGX;
            menuw->ypos=i+1;
            wprint_str(list[i]);
        }
k:
        if (visible)
            light_line(currenty,(word)(currentx+1),(word)(width-currentx-1));
        else
            light_line(currenty,1,(word)(width-1));

        ev=get_event(&key,&mx,&my);

        if (visible)
            light_line(currenty,(word)(currentx+1),(word)(width-currentx-1));
        else
            light_line(currenty,1,(word)(width-1));

        if (ev&EV_CLICK)
        {
            word w;
            ubyte edge;
            if (visible)
            {
                w=which_window(&mx,&my,&edge);
                if ( (w==num) && (edge==0) && (my<=visible) )
                {
                    if (key)
                    {   /* a double-click */
                        key=KEY_RETURN;
                        break;
                    }
                    currenty=--my;
                    goto k;
                }
            }
        }
        if (ev&EV_KEY)
        {
            if ( (key==KEY_UP) && (currenty) && visible )
            {
                currenty--;
                goto k;
            }
            if ( (key==KEY_DOWN) && visible && (currenty<(visible-1)) )
            {
                currenty++;
                goto k;
            }
            if ( (key==KEY_RETURN) || (key==KEY_ENTER) || (key==KEY_ESC) )
                break;
            if (reload)
            {
                if (key==KEY_BACKSPACE)
                {
                    if (currentx)
                        menu_so_far[--currentx]=0;
                }
                else if (key==KEY_CLEAR)
                {
                    menu_so_far[currentx=0]=0;
                }
                else if (key&0xFF)
                {
                    if (currentx<MAXMENUWIDTH)
                        menu_so_far[currentx++]=upper((char)key);
                    menu_so_far[currentx]=0;
                }
                else
                    goto k;
                if ( (reload)(menu_so_far,&numlist) )
                {
                    window_cls(menuw);
                    update_contents(menuw);
                    goto p;
                }
                else
                    goto k;
            }
        }
        goto k;
    }
    /* like close_dialog */
    remove_wlist(menuw);
    menuw->open=FALSE;

    /* restore correct view of world */
    recalc_frontback();
    /* and redraw this new place */
    update_rectangle(menuw->x, menuw->y, (word)(menuw->x+menuw->w),
                     (word)(menuw->y+menuw->h) );

    *result=( (key==KEY_ESC) || (visible==0) )
            ? -2 : currenty;
    return 0;
}
Exemplo n.º 17
0
void	dpb_list_add_item(DPB_list *list,char *description, char *ident, DPB_type *dpb)
{
	DPB_list_entry *entry = (DPB_list_entry *)malloc(sizeof(DPB_list_entry));

	if (entry!=NULL)
	{
		if (description==NULL)
		{
			entry->description = NULL;
		}
		else
		{
			entry->description = (char *)malloc(strlen(description)+1);

			if (entry->description!=NULL)
			{
				strcpy(entry->description, description);
			}
		}

		if (ident==NULL)
		{
			entry->ident = NULL;
		}
		else
		{
			entry->ident = (char *)malloc(strlen(ident)+1);

			if (entry->ident!=NULL)
			{
				strcpy(entry->ident, ident);
				upper(entry->ident);
			}
		}


		/* copy dpb */
		memcpy(&entry->dpb, dpb, sizeof(DPB_type));

		/* if cylinders is 40, but used in a 80 track drive, then the drive
		head is automatically double stepped */
		/* want to use cylinders from .def because this is good for discs
		where only 60 tracks are used */
#if 0
		/* The 22disk definition uses CYLINDERS to define, from what I can
		see the physical number of tracks on the disc media. So, you can
		have a 80 track 5.25" drive reading a 40 track format with
		or without double step - calculate a decent TRKS from DSM
		which specifies the total number of blocks on the disc. */
		{
			DPB_type *dpb = &entry->dpb;

			dpb->BLS  = 1 << (dpb->BSH + 7); /* or 2^BSH*128 */

			/* calculate the number of tracks from DSM */
			dpb->TRKS = (((dpb->DSM+1)*dpb->BLS)+(dpb->OFS*dpb->SECS*dpb->BPS) + ((dpb->DRM+1)<<5))/(dpb->SECS*dpb->BPS*dpb->HDS);
		}
#endif

		entry->next = NULL;
	}

	dpb_list_add_entry(list, entry);
}
Exemplo n.º 18
0
	Aabb(const Point<> &llo, const Point<> &uup) {
		lower(llo);
		upper(uup);
	}
Exemplo n.º 19
0
void
Stokes::V_Coarsen_Patch_Strategy::postprocessCoarsen_2D
(SAMRAI::hier::Patch& coarse,
 const SAMRAI::hier::Patch& fine,
 const SAMRAI::hier::Box& ,
 const SAMRAI::hier::IntVector& )
{
  /* Fix up the boundary elements by iterating through the boundary
     boxes */

  /* We only care about edges, not corners, so we only iterate over
     edge boundary boxes. */
  const std::vector<SAMRAI::hier::BoundaryBox>
    &boundaries=coarse_fine[fine.getPatchLevelNumber()]->getEdgeBoundaries(coarse.getGlobalId());
     
  boost::shared_ptr<SAMRAI::pdat::SideData<double> > v_fine =
    boost::dynamic_pointer_cast<SAMRAI::pdat::SideData<double> >
    (fine.getPatchData(v_id));
  boost::shared_ptr<SAMRAI::pdat::SideData<double> > v =
    boost::dynamic_pointer_cast<SAMRAI::pdat::SideData<double> >
    (coarse.getPatchData(v_id));

  TBOX_ASSERT(v);
  TBOX_ASSERT(v_fine);
  TBOX_ASSERT(v_fine->getDepth() == v->getDepth());
  TBOX_ASSERT(v->getDepth() == 1);

  SAMRAI::hier::Box gbox(v_fine->getGhostBox());
  SAMRAI::hier::Index ip(1,0), jp(0,1);
  for(size_t mm=0; mm<boundaries.size(); ++mm)
    {
      SAMRAI::hier::Box bbox=boundaries[mm].getBox();
      int location_index=boundaries[mm].getLocationIndex();

      SAMRAI::hier::Index
        lower=SAMRAI::hier::Index::coarsen(bbox.lower(),
                                           SAMRAI::hier::Index(2,2)),
        upper=SAMRAI::hier::Index::coarsen(bbox.upper(),
                                           SAMRAI::hier::Index(2,2));

      for(int j=lower(1); j<=upper(1); ++j)
        for(int i=lower(0); i<=upper(0); ++i)
          {
            /* Fix vx */
            if(location_index==0)
              {
                SAMRAI::pdat::SideIndex coarse(SAMRAI::hier::Index(i,j),0,
                                               SAMRAI::pdat::SideIndex::Upper);
                SAMRAI::pdat::SideIndex center(coarse*2);
                if(center[1]>=gbox.lower(1) && center[1]<gbox.upper(1))
                  {
                    (*v)(coarse)=((*v_fine)(center) + (*v_fine)(center+jp))/2;
                  }
              }
            else if(location_index==1)
              {
                SAMRAI::pdat::SideIndex coarse(SAMRAI::hier::Index(i,j),0,
                                               SAMRAI::pdat::SideIndex::Lower);
                SAMRAI::pdat::SideIndex center(coarse*2);
                if(center[1]>=gbox.lower(1) && center[1]<gbox.upper(1))
                  {
                    (*v)(coarse)=((*v_fine)(center) + (*v_fine)(center+jp))/2;
                  }
              }
            /* Fix vy */
            else if(location_index==2)
              {
                SAMRAI::pdat::SideIndex coarse(SAMRAI::hier::Index(i,j),1,
                                               SAMRAI::pdat::SideIndex::Upper);
                SAMRAI::pdat::SideIndex center(coarse*2);
                if(center[0]>=gbox.lower(0) && center[0]<gbox.upper(0))
                  {
                    (*v)(coarse)=((*v_fine)(center) + (*v_fine)(center+ip))/2;
                  }
              }
            else if(location_index==3)
              {
                SAMRAI::pdat::SideIndex coarse(SAMRAI::hier::Index(i,j),1,
                                               SAMRAI::pdat::SideIndex::Lower);
                SAMRAI::pdat::SideIndex center(coarse*2);
                if(center[0]>=gbox.lower(0) && center[0]<gbox.upper(0))
                  {
                    (*v)(coarse)=((*v_fine)(center) + (*v_fine)(center+ip))/2;
                  }
              }
            else
              {
                abort();
              }
          }
    }
}
Exemplo n.º 20
0
 vector<int> searchRange(vector<int> &A, int target) {
     return {lower(A, target), upper(A, target)};
 }
    void TestNodeBasedSquareMonolayer()
    {
        HoneycombMeshGenerator generator(10,10,0);
        MutableMesh<2,2>* p_generating_mesh = generator.GetMesh();
        NodesOnlyMesh<2>* p_mesh = new NodesOnlyMesh<2>;
        p_mesh->ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);

        std::vector<CellPtr> cells;
        MAKE_PTR(DifferentiatedCellProliferativeType, p_differentiated_type);
        CellsGenerator<UniformCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, p_mesh->GetNumNodes(), p_differentiated_type);

        // Make cells with x<5.0 apoptotic (so no source term)
        boost::shared_ptr<AbstractCellProperty> p_apoptotic_property =
                        cells[0]->rGetCellPropertyCollection().GetCellPropertyRegistry()->Get<ApoptoticCellProperty>();
        for (unsigned i=0; i<cells.size(); i++)
        {
            c_vector<double,2> cell_location;
            cell_location = p_mesh->GetNode(i)->rGetLocation();
            if (cell_location(0) < 5.0)
            {
                cells[i]->AddCellProperty(p_apoptotic_property);
            }
            // Set initial condition for PDE
            cells[i]->GetCellData()->SetItem("variable",1.0);
        }
        TS_ASSERT_EQUALS(p_apoptotic_property->GetCellCount(), 50u);

        NodeBasedCellPopulation<2> cell_population(*p_mesh, cells);

        // Set up simulation time for file output
        SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 10);

        // Create PDE and boundary condition objects
        MAKE_PTR_ARGS(AveragedSourceParabolicPde<2>, p_pde, (cell_population, 0.1, 1.0, -1.0));
        MAKE_PTR_ARGS(ConstBoundaryCondition<2>, p_bc, (1.0));

        // Create a ChasteCuboid on which to base the finite element mesh used to solve the PDE
        ChastePoint<2> lower(-5.0, -5.0);
        ChastePoint<2> upper(15.0, 15.0);
        MAKE_PTR_ARGS(ChasteCuboid<2>, p_cuboid, (lower, upper));

        // Create a PDE modifier and set the name of the dependent variable in the PDE
        MAKE_PTR_ARGS(ParabolicBoxDomainPdeModifier<2>, p_pde_modifier, (p_pde, p_bc, false, p_cuboid));
        p_pde_modifier->SetDependentVariableName("variable");

        // For coverage, output the solution gradient
        p_pde_modifier->SetOutputGradient(true);
        p_pde_modifier->SetupSolve(cell_population,"TestAveragedParabolicPdeWithNodeOnSquare");

        // Run for 10 time steps
        for (unsigned i=0; i<10; i++)
        {
            SimulationTime::Instance()->IncrementTimeOneStep();
            p_pde_modifier->UpdateAtEndOfTimeStep(cell_population);
            p_pde_modifier->UpdateAtEndOfOutputTimeStep(cell_population);
        }

        // Test the solution at some fixed points to compare with other cell populations
        CellPtr p_cell_0 = cell_population.GetCellUsingLocationIndex(0);
        TS_ASSERT_DELTA(cell_population.GetLocationOfCellCentre(p_cell_0)[0], 0, 1e-4);
        TS_ASSERT_DELTA(cell_population.GetLocationOfCellCentre(p_cell_0)[1], 0.0, 1e-4);
        TS_ASSERT_DELTA( p_cell_0->GetCellData()->GetItem("variable"), 0.8513, 1e-4);

        // Clear memory
        delete p_mesh;
    }
Exemplo n.º 22
0
void call21h()
{
	/*
	 * 对21h 中的功能号进行测试
	 */
	while(1)
	{
		cls();
		print("\r\n         Now, you can run some commands to test the 21h:\n\n\r");
		print("        1.ouch  -- to ouch          2.upper -- change the letter to upper\n\r");
		print("        3.lower         -- change the letter to lower\n\r"); 
		print("        4.to_digit      -- change the string to digit\r\n"); 
		print("        5.to_string     -- change the digit to string\r\n"); 
		print("        6.display_where -- you can assign where to display\r\n");
		print("        7.to_deci      -- change the Hex to a decimal digit\r\n"); 
		print("        8.reverse      -- to reverse your string\r\n"); 
		print("        9.strlen      --  get the length of your string\r\n"); 
		print("        10.quit          -- just to quit\r\n\r\n"); 
		print("Please input your choice:"); 
		getline(input,20);
	    if(strcmp(input,"1") || strcmp(input,"ouch"))
		{
			/*
			 * 测试 0 号功能
			 */
			to_OUCH();
		}
	    else if(strcmp(input,"2") || strcmp(input,"upper"))
		{
			/*
			 * 测试 1 号功能
			 */
			while(1)
			{
				print("\r\nPlease input a sentence or quit to back:");
				getline(input,30);
				if(strcmp(input,"quit")) break;
				upper(input);
				print("\r\nThe upper case is:");
				print(input);
				print("\r\n");
			}
		}
	    else if(strcmp(input,"3") || strcmp(input,"lower"))
		{
			/*
			 * 测试 2 号功能
			 */
		    while(1)
			{
				print("\r\nPlease input a sentence or quit to back:");
				getline(input,30);
				if(strcmp(input,"quit")) break;
				lower(input);
				print("\r\nThe lower case is:");
				print(input);
				print("\r\n");
			}
		}
	    else if(strcmp(input,"4") || strcmp(input,"to_digit"))
		{
			/*
			 * 测试 3 号功能
			 */
			print("\r\nDo you want to continue? Y | N :");
			getline(input,2);
			while(1)
			{
				int t1,t2,t3;
				t1 = 0;t2 = 0;
				if(strcmp(input,"n") || strcmp(input,"N")) break;
				print("\r\nPlease input the first digit:");
				getline(input,4);
				if(isDigit(input))
				{
				    t1 = digital(input);
				}
				else 
				{
					print("\r\nInvalid digit!We assume it is 12\n\r");
					t1 = 12;
				}
				print("\r\nPlease input the second digit:");
				getline(input,4);
				if(isDigit(input))
				{
					t2 = digital(input);
				}
				else 
				{
					print("\r\nInvalid digit!We assume it is 21\n\r");
					t2 = 21;
				}
				print("\r\nThe sum of the them is:");
				t3 = t1 + t2;
				printInt(t3);
				print("\r\n");
				print("\r\nDo you want to continue? Y | N :");
				getline(input,2);
			}
		}
	    else if(strcmp(input,"5") || strcmp(input,"to_string"))
		{
			/*
			 * 测试 4 号功能
			 */
			print("\r\nDo you want to continue? Y | N: ");
			getline(input,2);
			while(1)
			{
				char *cht;
				int tt = rand();
				if(strcmp(input,"n") || strcmp(input,"N")) break;
				cht = convertToString(tt);
				print("\r\nI am a string: ");
				print(cht);
				print("\r\n");
				print("\r\nDo you want to continue? Y | N: ");
				getline(input,2);
			}
		}
	    else if(strcmp(input,"6") || strcmp(input,"display_where"))
		{
			/*
			 * 测试 5 号功能
			 */
			int row,col;
			print("\r\nPlease input the row:");
			getline(input,3);
			if(isDigit(input))
			{
				row = digital(input);
			}
			else 
			{
				print("\r\nInvalid digit!We assume it is 12\n\r");
			    row = 12;
			}
			print("\r\nPlease input column:");
			getline(input,3);
			if(isDigit(input))
			{
				col = digital(input);
			}
			else 
			{
				print("\r\nInvalid digit!We assume it is 40\n\r");
			    col = 40;
			}
			print("\r\nPlease input the string:");
			getline(input,30);
			display(row,col,input);
		}
		else if(strcmp(input,"7") || strcmp(input,"to_dec"))
		{
			/*
			 * 测试 6 号功能
			 */
			print("\r\nDo you want to continue? Y | N :");
			getline(input,2);
			while(1)
			{
				int t1;
				t1 = 0;
				if(strcmp(input,"n") || strcmp(input,"N")) break;
				print("\r\nPlease input the hex digit:");
				getline(input,3);
				if(isHex(input))
				{
				    t1 = convertHexToDec(input);
				}
				else 
				{
					print("\r\nInvalid Hex!We assume it is 12\n\r");
					t1 = 12;
				}
				print("\r\nThe decimal form is:");
				printInt(t1);
				print("\r\n");
				print("\r\nDo you want to continue? Y | N :");
				getline(input,2);
			}
		}
		else if(strcmp(input,"8") || strcmp(input,"reverse"))
		{
			/*
			 * 测试 7 号功能
			 */
			print("\r\nDo you want to continue? Y | N :");
			getline(input,2);
			while(1)
			{
				if(strcmp(input,"n") || strcmp(input,"N")) break;
				print("\r\nPlease input the your string:");
				getline(input,30);
				reverse(input,strlen(input));
				print("\r\nThe string after reverse is:");
				print(input);
				print("\r\n");
				print("\r\nDo you want to continue? Y | N :");
				getline(input,2);
			}
		}
		else if(strcmp(input,"9") || strcmp(input,"strlen"))
		{
			/*
			 * 测试 8 号功能
			 */
			print("\r\nDo you want to continue? Y | N :");
			getline(input,2);
			while(1)
			{
				int t;
				if(strcmp(input,"n") || strcmp(input,"N")) break;
				print("\r\nPlease input the your string:");
				getline(input,30);
				t = strlen(input);
				print("\r\nThe length of the string is:");
				printInt(t);
				print("\r\n");
				print("\r\nDo you want to continue? Y | N :");
				getline(input,2);
			}
		}
	    else if(strcmp(input,"10") || strcmp(input,"quit"))
		{
			/*
			 * 退出
			 */
			break;
		}
	}
}
Exemplo n.º 23
0
/* takes care with symbols ending in .bwl or .bb/ww/ll */
word parse_symbol(void *result,bool getaddr, byte *etype)
{
char *p;
void *value;
byte ssize;
word err;
ubyte len; char size;

/*	if (!isalpha(*ev))		already done for us
		return ERRM_INVALIDSYM;	*/
	p=ev++;
	while (issym(*ev))
		ev++;
	if (issymend(*ev))
		ev++;
	len=(ubyte)(ev-p);	
	if ( (len>2) && (*(ev-2)=='.') )
		{
		size=upper(*(ev-1));
		if ( (size=='B') || (size=='W') || (size=='L') )
			{
			ev-=2;
			len-=2;
			}
		}
	else if ( (len>3) && (*(ev-3)=='.') )
		{
		size=upper(*(ev-1));
		if (
			( (size=='B') || (size=='W') || (size=='L') ) &&
				(upper(*(ev-2))==size)
		   )
			{
			ev-=3;
			len-=3;
			}
		}
	/* try general table */
	if (!checking)
		{
		must( find_general_sym(p,len,&value,&ssize,getaddr) );
		#if DOUBLES
		if (ssize<EXPR_NOTINT)
			{
			must( coerce_value(value,ssize,result,EXPR_LONG) );
			*etype=E_NUMBER;
			}
		else
			{
			*(double*)result=
				ssize==EXPR_DOUBLE ?
					*(double*)value : *(float*)value;		/* cope with singles & doubles */
			*etype=E_DBLNUMBER;
			}
		#else
		must( coerce_value(value,ssize,result,EXPR_LONG) );
		*etype=E_NUMBER;
		#endif
		}
	else
		{
		*etype=E_NUMBER;
		}
	return 0;
}
Exemplo n.º 24
0
static void oracle_set_key(char *key, int index) {
	key_length = 0;
	while( (cur_key[key_length] = upper(key[key_length]) ENDIAN_SHIFT_L ))
		key_length++;
	key_length <<= 1;
}
Exemplo n.º 25
0
void FragmentCanvas::menu(const QPoint&) {
  Q3PopupMenu m(0);
  
  MenuFactory::createTitle(m, TR("Fragment"));
  m.insertSeparator();
  m.insertItem(TR("Upper"), 0);
  m.insertItem(TR("Lower"), 1);
  m.insertItem(TR("Go up"), 7);
  m.insertItem(TR("Go down"), 8);
  m.insertSeparator();
  m.insertItem(TR("Edit"), 2);
  m.insertItem(TR("Add separator"), 6);
  m.insertSeparator();
  m.insertItem(TR("Edit drawing settings"), 3);
  if (linked()) {
    m.insertSeparator();
    m.insertItem(TR("Select linked items"), 4);
  }
  m.insertSeparator();
  m.insertItem(TR("Remove from diagram"),5);
  if ((refer != 0) && !refer->deletedp()) {
    m.insertSeparator();
    m.insertItem(TR("Show referenced diagram"),9);
  }

  int index = m.exec(QCursor::pos());
  
  switch (index) {
  case 0:
    upper();
    modified();	// call package_modified()
    return;
  case 1:
    lower();
    modified();	// call package_modified()
    return;
  case 7:
    z_up();
    modified();	// call package_modified()
    return;
  case 8:
    z_down();
    modified();	// call package_modified()
    return;
  case 2:
    open();
    // modified then package_modified already called
    return;
  case 3:
    edit_drawing_settings();
    return;
  case 4:
    the_canvas()->unselect_all();
    select_associated();
    return;
  case 5:
    delete_it();
    break;
  case 6:
    {
      FragmentSeparatorCanvas * sp =
	new FragmentSeparatorCanvas(the_canvas(), this);
      
      separators.append(sp);
      the_canvas()->unselect_all();
      the_canvas()->select(sp);
    }
    break;
  case 9:
    refer->open(FALSE);
    return;
  default:
    return;
  }
  
  package_modified();
}
Exemplo n.º 26
0
BOOST_AUTO_TEST_CASE_TEMPLATE
( test_mapping_upper_bound, Tp, quad_maps )
{
  { // find the smallest element that is greater than key
    Tp fix(100, randomize(-2, 2));
    quad lower (-3, -3, -3, -3);
    quad in (-1, -1, -1, -1);
    quad upper (1, 1, 1, 1);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<typename Tp::container_type>
          iter (mapping_upper_bound(fix.container, mapping_dim, in));
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim)
                    || quad_less()(mapping_dim, in, iter->first));
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim)
                    || !quad_less()(mapping_dim, (--iter)->first, in));
        iter = mapping_upper_bound(fix.container, mapping_dim, lower);
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
      }
  }
  { // same test with a tree filled with similar values
    Tp fix(100, same());
    quad lower (99, 99, 99, 99);
    quad in (100, 100, 100, 100);
    quad upper (101, 101, 101, 101);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<typename Tp::container_type>
          iter (mapping_upper_bound(fix.container, mapping_dim, lower));
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, in);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
      }
  }
  { // test at the limit: tree with 1 value
    Tp fix(1, same());
    quad lower (0, 0, 0, 0);
    quad in (1, 1, 1, 1);
    quad upper (2, 2, 2, 2);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<const typename Tp::container_type>
          iter (mapping_cupper_bound(fix.container, mapping_dim, lower));
        BOOST_CHECK(iter == mapping_cbegin(fix.container, mapping_dim));
        iter = mapping_cupper_bound(fix.container, mapping_dim, in);
        BOOST_CHECK(iter == mapping_cend(fix.container, mapping_dim));
        iter = mapping_cupper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_cend(fix.container, mapping_dim));
      }
  }
  { // test at the limit: tree filled with decreasing values
    Tp fix(100, decrease()); // first (100, 100, 100, 100), last (1, 1, 1, 1)
    quad lower(0, 0, 0, 0);
    quad in (99, 99, 99, 99);
    quad upper(100, 100, 100, 100);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<typename Tp::container_type>
          iter (mapping_upper_bound(fix.container, mapping_dim, lower));
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, in);
        BOOST_CHECK(iter != mapping_end(fix.container, mapping_dim)
                    && ++iter == mapping_end(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
      }
  }
  { // test at the limit: tree filled with increasing values
    Tp fix(100, increase()); // first (0, 0, 0, 0), last (99, 99, 99, 99)
    quad lower(-1, -1, -1, -1);
    quad in(98, 98, 98, 98);
    quad upper (99, 99, 99, 99);
    for (dimension_type mapping_dim = 0; mapping_dim < 4;
         ++mapping_dim)
      {
        mapping_iterator<typename Tp::container_type>
          iter (mapping_upper_bound(fix.container, mapping_dim, lower));
        BOOST_CHECK(iter == mapping_begin(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, in);
        BOOST_CHECK(iter != mapping_end(fix.container, mapping_dim)
                    && ++iter == mapping_end(fix.container, mapping_dim));
        iter = mapping_upper_bound(fix.container, mapping_dim, upper);
        BOOST_CHECK(iter == mapping_end(fix.container, mapping_dim));
      }
  }
}
Exemplo n.º 27
0
void Foam::lduMatrix::operator-=(const lduMatrix& A)
{
    if (A.diagPtr_)
    {
        diag() -= A.diag();
    }

    if (symmetric() && A.symmetric())
    {
        upper() -= A.upper();
    }
    else if (symmetric() && A.asymmetric())
    {
        if (upperPtr_)
        {
            lower();
        }
        else
        {
            upper();
        }

        upper() -= A.upper();
        lower() -= A.lower();
    }
    else if (asymmetric() && A.symmetric())
    {
        if (A.upperPtr_)
        {
            lower() -= A.upper();
            upper() -= A.upper();
        }
        else
        {
            lower() -= A.lower();
            upper() -= A.lower();
        }

    }
    else if (asymmetric() && A.asymmetric())
    {
        lower() -= A.lower();
        upper() -= A.upper();
    }
    else if (diagonal())
    {
        if (A.upperPtr_)
        {
            upper() = -A.upper();
        }

        if (A.lowerPtr_)
        {
            lower() = -A.lower();
        }
    }
    else if (A.diagonal())
    {
    }
    else
    {
        FatalErrorIn("lduMatrix::operator-=(const lduMatrix& A)")
            << "Unknown matrix type combination"
            << abort(FatalError);
    }
}
Exemplo n.º 28
0
void IconCanvas::menu(const QPoint&) {
  Q3PopupMenu m(0);
  
  m.insertItem(new MenuTitle(browser_node->get_name() + TR("\nshort cut"), m.font()), -1);
  m.insertSeparator();
  m.insertItem(TR("Upper"), 0);
  m.insertItem(TR("Lower"), 1);
  m.insertItem(TR("Go up"), 6);
  m.insertItem(TR("Go down"), 7);
  m.insertSeparator();
  if (! browser_node->deletedp()) {
    m.insertItem(TR("Open"), 2);
    m.insertSeparator();
  }
  m.insertItem(TR("Select diagram in browser"), 3);
  m.insertItem(TR("Select linked items"), 4);
  m.insertSeparator();
  m.insertItem(TR("Remove from diagram"),5);

  switch (m.exec(QCursor::pos())) {
  case 0:
    upper();
    // force son reaffichage
    hide();
    show();
    canvas()->update();
    break;
  case 1:
    lower();
    // force son reaffichage
    hide();
    show();
    canvas()->update();
    break;
  case 6:
    z_up();
    // force son reaffichage
    hide();
    show();
    canvas()->update();
    break;
  case 7:
    z_down();
    // force son reaffichage
    hide();
    show();
    canvas()->update();
    break;
  case 2:
    browser_node->open(FALSE);
    return;
  case 3:
    browser_node->select_in_browser();
    return;
  case 4:
    the_canvas()->unselect_all();
    select_associated();
    return;
  case 5:
    // delete
    delete_it();
    break;
  default:
    return;
  }
  
  package_modified();
}
Exemplo n.º 29
0
void ActivityPartitionCanvas::menu(const QPoint&) {
  Q3PopupMenu m(0);
  Q3PopupMenu toolm(0);
  int index;
  
  MenuFactory::createTitle(m, browser_node->get_data()->definition(FALSE, TRUE));
  m.insertSeparator();
  m.insertItem(TR("Upper"), 0);
  m.insertItem(TR("Lower"), 1);
  m.insertItem(TR("Go up"), 13);
  m.insertItem(TR("Go down"), 14);
  m.insertSeparator();
  m.insertItem((horiz) ? TR("draw vertically") : TR("draw horizontally"), 10);
  m.insertSeparator();
  m.insertItem(TR("Edit drawing settings"), 2);
  m.insertSeparator();
  m.insertItem(TR("Edit activity partition"), 3);
  m.insertSeparator();
  m.insertItem(TR("Select in browser"), 4);
  if (linked())
    m.insertItem(TR("Select linked items"), 5);
  m.insertSeparator();
  if (browser_node->is_writable()) {
    if (browser_node->get_associated() !=
	(BrowserNode *) the_canvas()->browser_diagram())
      m.insertItem(TR("Set associated diagram"),6);
    
    if (browser_node->get_associated())
      m.insertItem(TR("Remove diagram association"),9);
  }
  m.insertSeparator();
  m.insertItem(TR("Remove from diagram"), 7);
  if (browser_node->is_writable())
    m.insertItem(TR("Delete from model"), 8);
  m.insertSeparator();
  if (Tool::menu_insert(&toolm, UmlActivityPartition, 20))
    m.insertItem(TR("Tool"), &toolm);
  
  switch (index = m.exec(QCursor::pos())) {
  case 0:
    upper();
    modified();	// call package_modified()
    return;
  case 1:
    lower();
    modified();	// call package_modified()
    return;
  case 13:
    z_up();
    modified();	// call package_modified()
    return;
  case 14:
    z_down();
    modified();	// call package_modified()
    return;
  case 2:
    edit_drawing_settings();
    return;
  case 3:
    browser_node->open(TRUE);
    return;
  case 4:
    browser_node->select_in_browser();
    return;
  case 5:
    the_canvas()->unselect_all();
    select_associated();
    return;
  case 6:
    ((BrowserActivityPartition *) browser_node)
      ->set_associated_diagram((BrowserActivityDiagram *)
			       the_canvas()->browser_diagram());
    return;
  case 7:
    //remove from diagram
    delete_it();
    break;
  case 8:
    //delete from model
    browser_node->delete_it();	// will delete the canvas
    break;
  case 9:
    ((BrowserActivityPartition *) browser_node)
      ->set_associated_diagram(0);
    return;
  case 10:
    turn(-1000, -1000);
    break;
  default:
    if (index >= 20)
      ToolCom::run(Tool::command(index - 20), browser_node);
    return;
  }
  
  package_modified();
}
Exemplo n.º 30
0
EIO_Status CConnTest::ServiceOkay(string* reason)
{
    static const char kService[] = "bounce";

    SConnNetInfo* net_info = ConnNetInfo_Create(kService, m_DebugPrintout);
    if (net_info)
        net_info->lb_disable = 1/*no local LB to use even if available*/;

    PreCheck(eStatelessService, 0/*main*/,
             "Checking whether NCBI services operational");

    CConn_ServiceStream svc(kService, fSERV_Stateless, net_info,
                            0/*extra*/, m_Timeout);
    svc.SetCanceledCallback(m_Canceled);

    svc << kTest << NcbiEndl;
    string temp;
    svc >> temp;
    bool responded = temp.size() > 0 ? true : false;
    EIO_Status status = ConnStatus(NStr::Compare(temp, kTest) != 0, &svc);

    if (status == eIO_Interrupt)
        temp = kCanceled;
    else if (status == eIO_Success)
        temp = "OK";
    else {
        char* str = net_info ? SERV_ServiceName(kService) : 0;
        if (str  &&  NStr::CompareNocase(str, kService) == 0) {
            free(str);
            str = 0;
        }
        SERV_ITER iter = SERV_OpenSimple(kService);
        if (!iter  ||  !SERV_GetNextInfo(iter)) {
            // Service not found
            SERV_Close(iter);
            iter = SERV_OpenSimple(kTest);
            if (!iter  ||  !SERV_GetNextInfo(iter)
                ||  NStr::CompareNocase(SERV_MapperName(iter), "DISPD") != 0) {
                // Make sure there will be a mapper error printed
                SERV_Close(iter);
                temp.clear();
                iter = 0;
            } else {
                // kTest service can be located but not kService
                temp = str ? "Substituted service" : "Service";
                temp += " cannot be located";
            }
        } else {
            temp = responded ? "Unrecognized" : "No";
            temp += " response from ";
            temp += str ? "substituted service" : "service";
        }
        if (!temp.empty()) {
            if (str) {
                temp += "; please remove [";
                string upper(kService);
                temp += NStr::ToUpper(upper);
                temp += "]CONN_SERVICE_NAME=\"";
                temp += str;
                temp += "\" from your configuration\n";
            } else if (status != eIO_Timeout  ||  m_Timeout > kTimeout)
                temp += "; please contact " + HELP_EMAIL + '\n';
        }
        if (status != eIO_Timeout) {
            const char* mapper = SERV_MapperName(iter);
            if (!mapper  ||  NStr::CompareNocase(mapper, "DISPD") != 0) {
                temp += "Network dispatcher is not enabled as a service"
                    " locator;  please review your configuration to purge any"
                    " occurrences of [CONN]DISPD_DISABLE off your settings\n";
            }
        } else
            temp += x_TimeoutMsg();
        SERV_Close(iter);
        if (str)
            free(str);
    }

    PostCheck(eStatelessService, 0/*main*/, status, temp);

    ConnNetInfo_Destroy(net_info);
    if (reason)
        reason->swap(temp);
    return status;
}