Parse "vector" argument

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
alnagme
Posts: 10
Joined: Sat Feb 25, 2012 4:27 am
Location: Universidad Politécnica de Valencia

Parse "vector" argument

Post by alnagme »

Hi everyone,

I'm developing a new material in OpenSEES, with 3 arguments, namely, tag and two vectors: stress and strain points which define a stress-strain general path. For any new material, we need to parse the command line in order to achieve the values of the arguments. In the elementAPI there are procedures for getting double and integer from the command line, but no one for vectors... Any help about how to input a vector as an argument?

Cheers,

Alberto Navarro
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: Parse "vector" argument

Post by fmk »

the getDouble does not just get one double value, it can get many at once (think vector!)

you just have to tell it the size, if you want arbitrary size for the command line, put that number as an integer after the tag in the command line.

anothe roption is to just put the 2 vectors in a file and pas the filename in and red the values from it.
alnagme
Posts: 10
Joined: Sat Feb 25, 2012 4:27 am
Location: Universidad Politécnica de Valencia

Re: Parse "vector" argument

Post by alnagme »

So this is my command line 's definition:

GeneralElastic(int tag, int pathSize, Vector * backboneStrain, Vector * backboneStress);


I have tried this to parse the arguments:

UniaxialMaterial *theMaterial = 0;

int iData[2]; // tag in first position, number of points in second position
Vector * eData; // strain coordinates
Vector * sData; // stress coordinates
int numData;

numData = 2;
if (OPS_GetIntInput(&numData, iData) != 0) {
opserr << "WARNING invalid uniaxialMaterial ElasticPP tag" << endln;
return 0;
}

numData = iData[1];
if (OPS_GetDoubleInput(&numData, eData) != 0) {
opserr << "WARNING invalid strain coordinates";
return 0;
}

if (OPS_GetDoubleInput(&numData, sData) != 0) {
opserr << "WARNING invalid stress coordinates";
return 0;
}

theMaterial = new GeneralElastic(iData[0], iData[1], eData, sData);


But it warns me that sData and eData are arguments of type 'Vector', which is incompatible with parameter of type 'double'.

Thank you so much for your kind attention

Alberto Navarro
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: Parse "vector" argument

Post by fmk »

eData and SData as used in GetDouble must be double []. you can create a Vector that uses a double * in the constructor.
alnagme
Posts: 10
Joined: Sat Feb 25, 2012 4:27 am
Location: Universidad Politécnica de Valencia

Re: Parse "vector" argument

Post by alnagme »

It worked! Thank you so much!
Post Reply