int
OPS_UniaxialMaterial()
{
    static bool initDone = false;
    if (initDone == false) {
	setUpUniaxialMaterials();
	initDone = true;
    }

    if (OPS_GetNumRemainingInputArgs() < 2) {
	opserr<<"WARNING too few arguments: uniaxialMaterial type? tag? ...\n";
	return -1;
    }

    const char* matType = OPS_GetString();

    OPS_ParsingFunctionMap::const_iterator iter = uniaxialMaterialsMap.find(matType);
    if (iter == uniaxialMaterialsMap.end()) {
	opserr<<"WARNING material type " << matType << " is unknown\n";
	return -1;
    }

    UniaxialMaterial* theMaterial = (UniaxialMaterial*) (*iter->second)();
    if (theMaterial == 0) {
	return -1;
    }

    // Now add the material to the modelBuilder
    if (OPS_addUniaxialMaterial(theMaterial) == false) {
	opserr<<"ERROR could not add uniaaialMaterial.\n";
	delete theMaterial; // invoke the material objects destructor, otherwise mem leak
	return -1;
    }

    return 0;

}
示例#2
0
int
TclCommand_AxialSp(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv)
{
  //arguments (necessary)
  int tag;
  double sce;
  double fty;
  double fcy;

  //arguments (optional)
  double bte = 0.0;
  double bty = 0.0;
  double bcy = 0.0;
  double fcr = 0.0;
      
  //
  UniaxialMaterial *theMaterial = 0;


  //error flag
  bool ifNoError = true;
  
  if (argc < 6 || argc > 10) { // uniaxialMaterial AxialSp matTag? sce? fty? fcy?

    opserr << "WARNING invalid number of arguments\n";
    ifNoError = false;

  }

    //argv[2~5]
    if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
      opserr << "WARNING invalid AxialSp tag" << endln;
      ifNoError = false;
    }

    if (Tcl_GetDouble(interp, argv[3], &sce) != TCL_OK) {
      opserr << "WARNING invalid sce\n";
      opserr << "AxialSp: " << tag << endln;
      ifNoError = false;
    }

    if (Tcl_GetDouble(interp, argv[4], &fty) != TCL_OK) {
      opserr << "WARNING invalid fty\n";
      opserr << "AxialSp: " << tag << endln;
      ifNoError = false;
    }

    if (Tcl_GetDouble(interp, argv[5], &fcy) != TCL_OK) {
      opserr << "WARNING invalid fcy\n";
      opserr << "AxialSp: " << tag << endln;
      ifNoError = false;
    }
    
    //argv[6~]
    if (argc >= 7) {
      if (Tcl_GetDouble(interp, argv[6], &bte) != TCL_OK) {
	opserr << "WARNING invalid bte\n";
	opserr << "AxialSp: " << tag << endln;
	ifNoError = false;
      }
    }

    if (argc >= 8) {
      if (Tcl_GetDouble(interp, argv[7], &bty) != TCL_OK) {
	opserr << "WARNING invalid bty\n";
	opserr << "AxialSp: " << tag << endln;
	ifNoError = false;
      }
    }

    if (argc >= 9) {
      if (Tcl_GetDouble(interp, argv[8], &bcy) != TCL_OK) {
	opserr << "WARNING invalid bcy\n";
	opserr << "AxialSp: " << tag << endln;
	ifNoError = false;
      }
    }

    if (argc == 10) {
      if (Tcl_GetDouble(interp, argv[9], &fcr) != TCL_OK) {
	opserr << "WARNING invalid fcr\n";
	opserr << "AxialSp: " << tag << endln;
	ifNoError = false;
      }
    }


  //if error detected
  if (!ifNoError) {
    //input:
    opserr << "Input command: ";
    for (int i=0; i<argc; i++){
      opserr << argv[i] << " ";
    }
    opserr << endln;
    
    //want:
    opserr << "WANT: AxialSp tag? sce? fty? fcy? <bte?> <bty?> <bcy?> <fcr?>" << endln;

    return TCL_ERROR;
  }

 
  
  // Parsing was successful, allocate the material
  theMaterial = new AxialSp(tag, sce, fty, fcy, bte, bty, bcy, fcr);

  if (theMaterial == 0) {
    opserr << "WARNING could not create uniaxialMaterial " << argv[1] << endln;
    return TCL_ERROR;
  }

  // Now add the material to the modelBuilder
  if (OPS_addUniaxialMaterial(theMaterial) == false) {
    opserr << "WARNING could not add uniaxialMaterial to the modelbuilder\n";
    opserr << *theMaterial << endln;
    delete theMaterial; // invoke the material objects destructor, otherwise mem leak
    return TCL_ERROR;
  } else {
    return TCL_OK;
  }

}