Пример #1
0
void MGuiSlide::sendVariable(void)
{
	if(getVariablePointer())
	{
		switch(getVariableType())
		{
		case M_VAR_INT:
			{
				int * value = (int *)getVariablePointer();
				if(m_value >= 0)
					*value = (int)(m_value + 0.5f);
				else
					*value = (int)(m_value - 0.5f);
			}
			break;
		case M_VAR_FLOAT:
			{
				float * value = (float *)getVariablePointer();
				*value = m_value;
			}
			break;
		}
	}

	// send on change gui event
	if(m_pointerEvent)
	{
		MGuiEvent guiEvent;
		guiEvent.type = MGUI_EVENT_SEND_VARIABLE;

		m_pointerEvent(this, &guiEvent);
	}
}
Пример #2
0
float MGuiSlide::getNormalizedValue(void)
{
	if(getVariableType())
	{
		if(getVariableType() == M_VAR_INT)
		{
			int iValue;
			if(m_value >= 0)
				iValue = (int)(m_value + 0.5f);
			else
				iValue = (int)(m_value - 0.5f);

			return (iValue - getMinValue()) / (getMaxValue() - getMinValue());
		}
	}

	return (getValue() - getMinValue()) / (getMaxValue() - getMinValue());
}
Пример #3
0
//FIXME: this function is not used (latency availability traces support exists in surf network models?)
void TRACE_surf_link_set_latency(double date, const char *resource, double latency)
{
  if (!TRACE_is_active())
    return;

  container_t container = getContainerByName(resource);
  type_t type = getVariableType("latency", NULL, container->type);
  new_pajeSetVariable(date, container, type, latency);
}
Пример #4
0
void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth)
{
  if (!TRACE_is_active())
    return;

  container_t container = getContainerByName(resource);
  type_t type = getVariableType("bandwidth", NULL, container->type);
  new_pajeSetVariable(date, container, type, bandwidth);
}
Пример #5
0
void TRACE_surf_host_set_power(double date, const char *resource, double power)
{
  if (!TRACE_is_active())
    return;

  container_t container = getContainerByName(resource);
  type_t type = getVariableType("power", NULL, container->type);
  new_pajeSetVariable(date, container, type, power);
}
Пример #6
0
void MGuiEditText::updateFromVariable(void)
{
	if(! getVariablePointer())
		return;

	switch(getVariableType())
	{
	case M_VAR_BOOL:
		{
			bool * value = (bool *)getVariablePointer();

			if(*value)
				setText("1");
			else
				setText("0");
		}
		break;
	case M_VAR_INT:
		{
			int * value = (int *)getVariablePointer();

			char text[256];
			sprintf(text, "%d", *value);

			setText(text);
		}
		break;
	case M_VAR_UINT:
		{
			unsigned int * value = (unsigned int *)getVariablePointer();

			char text[256];
			sprintf(text, "%d", *value);

			setText(text);
		}
		break;
	case M_VAR_FLOAT:
		{
			float * value = (float *)getVariablePointer();

			char text[256];
			sprintf(text, "%0.2f", *value);

			setText(text);
		}
		break;
	case M_VAR_STRING:
		{
			MString * value = (MString *)getVariablePointer();
			setText(value->getData());
		}
		break;
	}
}
Пример #7
0
int CellmlModelDefinition::getVariableIndex(const std::string& variableId, unsigned char variableType)
{
    unsigned char vt = getVariableType(variableId);
    if (vt == csim::UndefinedType)
    {
        std::cerr << "CellML Model Definition::getVariableIndex: unable to get the variable type for: "
                  << variableId << std::endl;
        return csim::UNDEFINED_VARIABLE_TYPE;
    }
    // can now assume everything set up for use
    if (vt & variableType)
    {
        ObjRef<iface::cellml_api::CellMLVariable> sv = findLocalVariable(mCapi, variableId);
        return mVariableIndices[getVariableUniqueId(sv)][variableType];
    }
    std::cerr << "CellML Model Definition::getVariableIndex: no computation target of matching type." << std::endl;
    return csim::MISMATCHED_COMPUTATION_TARGET;
}
Пример #8
0
MVector2 MGuiSlide::getPointfromValue(float value)
{
	float nValue;
	MVector2 point;

	// variable pointer
	if(getVariablePointer())
	{
		if(getVariableType() == M_VAR_INT)
		{
			int iValue;

			if(value >= 0)
				iValue = (int)(value+0.5f);
			else
				iValue = (int)(value-0.5f);

			nValue = (iValue - getMinValue()) / (getMaxValue() - getMinValue());

			if(nValue < 0)
				nValue = 0;

			if(nValue > 1)
				nValue = 1;

			point = getPosition() + (getDirection() * nValue);
			return point;
		}
	}

	// normal
	nValue = (value - getMinValue()) / (getMaxValue() - getMinValue());

	if(nValue < 0)
		nValue = 0;

	if(nValue > 1)
		nValue = 1;

	point = getPosition() + (getDirection() * nValue);
	return point;
}
Пример #9
0
void MGuiSlide::updateFromVariable(void)
{
	if(! getVariablePointer())
		return;

	switch(getVariableType())
	{
	case M_VAR_INT:
		{
			int * value = (int *)getVariablePointer();
			setValue((float)*value);
		}
		break;
	case M_VAR_FLOAT:
		{
			float * value = (float *)getVariablePointer();
			setValue(*value);
		}
		break;
	}
}
Пример #10
0
//------------------------------------------------------------------------------
Albany::MechanicsProblem::
MechanicsProblem(const Teuchos::RCP<Teuchos::ParameterList>& params,
    const Teuchos::RCP<ParamLib>& param_lib,
    const int num_dims,
    const Teuchos::RCP<AAdapt::rc::Manager>& rc_mgr,
    Teuchos::RCP<const Teuchos::Comm<int>>& commT) :
    Albany::AbstractProblem(params, param_lib),
    have_source_(false),
    thermal_source_(SOURCE_TYPE_NONE),
    thermal_source_evaluated_(false),
    have_contact_(false),
    num_dims_(num_dims),
    have_mech_eq_(false),
    have_temperature_eq_(false),
    have_pore_pressure_eq_(false),
    have_transport_eq_(false),
    have_hydrostress_eq_(false),
    have_damage_eq_(false),
    have_stab_pressure_eq_(false),
    have_peridynamics_(false),
    have_topmod_adaptation_(false),
    have_sizefield_adaptation_(false),
    rc_mgr_(rc_mgr)
{

  std::string& method = params->get("Name", "Mechanics ");
  *out << "Problem Name = " << method << '\n';

  // Are any source functions specified?
  have_source_ = params->isSublist("Source Functions");

  // Is contact specified?
  have_contact_ = params->isSublist("Contact");

  // Is adaptation specified?
  bool adapt_sublist_exists = params->isSublist("Adaptation");

  if(adapt_sublist_exists){

    Teuchos::ParameterList const &
    adapt_params = params->sublist("Adaptation");

    std::string const &
    adaptation_method_name = adapt_params.get<std::string>("Method");

    have_sizefield_adaptation_ = (adaptation_method_name == "RPI Albany Size");

  }

  getVariableType(params->sublist("Displacement"),
      "DOF",
      mech_type_,
      have_mech_,
      have_mech_eq_);
  getVariableType(params->sublist("Temperature"),
      "None",
      temperature_type_,
      have_temperature_,
      have_temperature_eq_);
  getVariableType(params->sublist("Pore Pressure"),
      "None",
      pore_pressure_type_,
      have_pore_pressure_,
      have_pore_pressure_eq_);
  getVariableType(params->sublist("Transport"),
      "None",
      transport_type_,
      have_transport_,
      have_transport_eq_);
  getVariableType(params->sublist("HydroStress"),
      "None",
      hydrostress_type_,
      have_hydrostress_,
      have_hydrostress_eq_);
  getVariableType(params->sublist("Damage"),
      "None",
      damage_type_,
      have_damage_,
      have_damage_eq_);
  getVariableType(params->sublist("Stabilized Pressure"),
      "None",
      stab_pressure_type_,
      have_stab_pressure_,
      have_stab_pressure_eq_);

  // Compute number of equations
  int num_eq = 0;
  if (have_mech_eq_) num_eq += num_dims_;
  if (have_temperature_eq_) num_eq += 1;
  if (have_pore_pressure_eq_) num_eq += 1;
  if (have_transport_eq_) num_eq += 1;
  if (have_hydrostress_eq_) num_eq += 1;
  if (have_damage_eq_) num_eq += 1;
  if (have_stab_pressure_eq_) num_eq += 1;
  this->setNumEquations(num_eq);

  // Print out a summary of the problem
  *out << "Mechanics problem:" << '\n'
      << "\tSpatial dimension             : " << num_dims_ << '\n'
      << "\tMechanics variables           : "
      << variableTypeToString(mech_type_)
      << '\n'
      << "\tTemperature variables         : "
      << variableTypeToString(temperature_type_)
      << '\n'
      << "\tPore Pressure variables       : "
      << variableTypeToString(pore_pressure_type_)
      << '\n'
      << "\tTransport variables           : "
      << variableTypeToString(transport_type_)
      << '\n'
      << "\tHydroStress variables         : "
      << variableTypeToString(hydrostress_type_)
      << '\n'
      << "\tDamage variables              : "
      << variableTypeToString(damage_type_)
      << '\n'
      << "\tStabilized Pressure variables : "
      << variableTypeToString(stab_pressure_type_)
      << '\n';

  material_db_ = LCM::createMaterialDatabase(params, commT);

  // Determine the Thermal source 
  //   - the "Source Functions" list must be present in the input file,
  //   - we must have temperature and have included a temperature equation

  if (have_source_ && have_temperature_ && have_temperature_eq_) {
    // If a thermal source is specified
    if (params->sublist("Source Functions").isSublist("Thermal Source")) {

      Teuchos::ParameterList& thSrcPL = params->sublist("Source Functions")
          .sublist("Thermal Source");

      if (thSrcPL.get<std::string>("Thermal Source Type", "None")
          == "Block Dependent") {

        if (Teuchos::nonnull(material_db_)) {
          thermal_source_ = SOURCE_TYPE_MATERIAL;
        }
      }
      else {

        thermal_source_ = SOURCE_TYPE_INPUT;

      }
    }
  }

  //the following function returns the problem information required for
  //setting the rigid body modes (RBMs) for elasticity problems (in
  //src/Albany_SolverFactory.cpp) written by IK, Feb. 2012

  // Need numPDEs should be num_dims_ + nDOF for other governing equations  -SS

  int num_PDEs = neq;
  int num_elasticity_dim = 0;
  if (have_mech_eq_) num_elasticity_dim = num_dims_;
  int num_scalar = neq - num_elasticity_dim;
  int null_space_dim(0);
  if (have_mech_eq_) {
    if (num_dims_ == 1) {
      null_space_dim = 0;
    }
    else if (num_dims_ == 2) {
      null_space_dim = 3;
    }
    else if (num_dims_ == 3) {
      null_space_dim = 6;
    }
    else {
      TEUCHOS_TEST_FOR_EXCEPTION(
          true,
          std::logic_error,
          '\n' << "Error: " << __FILE__ << " line " << __LINE__ <<
          ": num_dims_ set incorrectly." << '\n');
    }
  }

  rigidBodyModes->setParameters(
      num_PDEs,
      num_elasticity_dim,
      num_scalar,
      null_space_dim);

  // Check whether we are doing adaptive insertion with topology modification.
  bool const
  have_adaptation = params->isSublist("Adaptation");

  if (have_adaptation == true) {
    Teuchos::ParameterList const &
    adapt_params = params->sublist("Adaptation");

    std::string const &
    adaptation_method_name = adapt_params.get<std::string>("Method");

    have_topmod_adaptation_ = adaptation_method_name == "Topmod";
  }

}
Пример #11
0
void MGuiEditText::sendVariable(void)
{
	if(getVariablePointer())
	{
		switch(getVariableType())
		{
		case M_VAR_BOOL:
			{
				bool * value = (bool *)getVariablePointer();

				int i;
				sscanf(getText(), "%d", &i);

				if(i == 1)
					*value = true;
				else if(i == 0)
					*value = false;
			}
			break;
		case M_VAR_INT:
			{
				int * value = (int *)getVariablePointer();

				int i;
				sscanf(getText(), "%d", &i);
				if(i == (*value))
					return;

				*value = i;
			}
			break;
		case M_VAR_UINT:
			{
				unsigned int * value = (unsigned int *)getVariablePointer();

				int i;
				sscanf(getText(), "%d", &i);
				if(i < 0) i = 0;
				if((unsigned int)i == (*value))
					return;

				*value = (unsigned int)i;
			}
			break;
		case M_VAR_FLOAT:
			{
				float * value = (float *)getVariablePointer();

				float f;
				sscanf(getText(), "%f", &f);
				if(f == (*value))
					return;

				*value = f;
			}
			break;
		case M_VAR_STRING:
			{
				MString * value = (MString *)getVariablePointer();
				value->set(getText());
			}
			break;
		}

		unsigned int tSize = m_text.size();
		if(getCharId() > tSize)
			setCharId(tSize);
	}

	// send on change gui event
	if(m_pointerEvent)
	{
		MGuiEvent guiEvent;
		guiEvent.type = MGUI_EVENT_SEND_VARIABLE;
		m_pointerEvent(this, &guiEvent);
	}
}
Пример #12
0
//------------------------------------------------------------------------------
Albany::MechanicsProblem::
MechanicsProblem(const Teuchos::RCP<Teuchos::ParameterList>& params,
    const Teuchos::RCP<ParamLib>& param_lib,
    const int num_dims,
    Teuchos::RCP<const Teuchos::Comm<int> >& commT) : 
    Albany::AbstractProblem(params, param_lib),
    have_source_(false),
    num_dims_(num_dims),
    have_mech_eq_(false),
    have_temperature_eq_(false),
    have_pore_pressure_eq_(false),
    have_transport_eq_(false),
    have_hydrostress_eq_(false),
    have_damage_eq_(false),
    have_stab_pressure_eq_(false),
    have_peridynamics_(false)
{

  std::string& method = params->get("Name", "Mechanics ");
  *out << "Problem Name = " << method << '\n';

  have_source_ = params->isSublist("Source Functions");

  getVariableType(params->sublist("Displacement"),
      "DOF",
      mech_type_,
      have_mech_,
      have_mech_eq_);
  getVariableType(params->sublist("Temperature"),
      "None",
      temperature_type_,
      have_temperature_,
      have_temperature_eq_);
  getVariableType(params->sublist("Pore Pressure"),
      "None",
      pore_pressure_type_,
      have_pore_pressure_,
      have_pore_pressure_eq_);
  getVariableType(params->sublist("Transport"),
      "None",
      transport_type_,
      have_transport_,
      have_transport_eq_);
  getVariableType(params->sublist("HydroStress"),
      "None",
      hydrostress_type_,
      have_hydrostress_,
      have_hydrostress_eq_);
  getVariableType(params->sublist("Damage"),
      "None",
      damage_type_,
      have_damage_,
      have_damage_eq_);
  getVariableType(params->sublist("Stabilized Pressure"),
      "None",
      stab_pressure_type_,
      have_stab_pressure_,
      have_stab_pressure_eq_);

  if (have_temperature_eq_)
    have_source_ = params->isSublist("Source Functions");

  // Compute number of equations
  int num_eq = 0;
  if (have_mech_eq_) num_eq += num_dims_;
  if (have_temperature_eq_) num_eq += 1;
  if (have_pore_pressure_eq_) num_eq += 1;
  if (have_transport_eq_) num_eq += 1;
  if (have_hydrostress_eq_) num_eq += 1;
  if (have_damage_eq_) num_eq += 1;
  if (have_stab_pressure_eq_) num_eq += 1;
  this->setNumEquations(num_eq);

  // Print out a summary of the problem
  *out << "Mechanics problem:" << '\n'
      << "\tSpatial dimension             : " << num_dims_ << '\n'
      << "\tMechanics variables           : "
      << variableTypeToString(mech_type_)
      << '\n'
      << "\tTemperature variables         : "
      << variableTypeToString(temperature_type_)
      << '\n'
      << "\tPore Pressure variables       : "
      << variableTypeToString(pore_pressure_type_)
      << '\n'
      << "\tTransport variables           : "
      << variableTypeToString(transport_type_)
      << '\n'
      << "\tHydroStress variables         : "
      << variableTypeToString(hydrostress_type_)
      << '\n'
      << "\tDamage variables              : "
      << variableTypeToString(damage_type_)
      << '\n'
      << "\tStabilized Pressure variables : "
      << variableTypeToString(stab_pressure_type_)
      << '\n';

  material_db_ = LCM::createMaterialDatabase(params, commT);

  //the following function returns the problem information required for
  //setting the rigid body modes (RBMs) for elasticity problems (in
  //src/Albany_SolverFactory.cpp) written by IK, Feb. 2012

  // Need numPDEs should be num_dims_ + nDOF for other governing equations  -SS

  int num_PDEs = neq;
  int num_elasticity_dim = 0;
  if (have_mech_eq_) num_elasticity_dim = num_dims_;
  int num_scalar = neq - num_elasticity_dim;
  int null_space_dim(0);
  if (have_mech_eq_) {
    if (num_dims_ == 1) {
      null_space_dim = 0;
    }
    if (num_dims_ == 2) {
      null_space_dim = 3;
    }
    if (num_dims_ == 3) {
      null_space_dim = 6;
    }
  }

  rigidBodyModes->setParameters(
      num_PDEs,
      num_elasticity_dim,
      num_scalar,
      null_space_dim);

}