Added use of utl::getAttribute to make the XML parsing more compact and readable

git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@1460 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
kmo 2012-02-13 08:34:56 +00:00 committed by Knut Morten Okstad
parent 6af84a8eb4
commit 90c92317e9
2 changed files with 187 additions and 211 deletions

View File

@ -164,13 +164,14 @@ bool SIMLinEl2D::parse (char* keyWord, std::istream& is)
code = 0; code = 0;
for (int i = 0; i < lines; i++) { for (int i = 0; i < lines; i++) {
std::string function = utl::readLine(is); std::string function = utl::readLine(is);
size_t pos; size_t pos = function.find("Variables=");
if ((pos = function.find("Variables=")) != std::string::npos) { if (pos != std::string::npos) {
variables += function.substr(pos+10); variables += function.substr(pos+10);
if (variables[variables.size()-1] != ';') if (variables[variables.size()-1] != ';')
variables += ";"; variables += ";";
} }
if ((pos = function.find("Stress=")) != std::string::npos) { pos = function.find("Stress=");
if (pos != std::string::npos) {
stress = function.substr(pos+7); stress = function.substr(pos+7);
mySol = new AnaSol(new STensorFuncExpr(stress,variables)); mySol = new AnaSol(new STensorFuncExpr(stress,variables));
std::cout <<"\nAnalytical solution:"; std::cout <<"\nAnalytical solution:";
@ -296,127 +297,114 @@ bool SIMLinEl2D::parse (char* keyWord, std::istream& is)
} }
bool SIMLinEl2D::parse(const TiXmlElement* elem) bool SIMLinEl2D::parse (const TiXmlElement* elem)
{ {
if (strcasecmp(elem->Value(),"linearelasticity")) if (strcasecmp(elem->Value(),"elasticity"))
return SIM2D::parse(elem); return this->SIM2D::parse(elem);
Elasticity* elp = dynamic_cast<Elasticity*>(myProblem); Elasticity* elp = dynamic_cast<Elasticity*>(myProblem);
if (!elp) if (!elp) return false;
return false;
std::vector<const TiXmlElement*> parsed = handlePriorityTags(elem); std::vector<const TiXmlElement*> parsed = handlePriorityTags(elem);
const TiXmlElement* child = elem->FirstChildElement(); const TiXmlElement* child = elem->FirstChildElement();
while (child) { while (child) {
if (find(parsed.begin(),parsed.end(),child) != parsed.end()) { if (find(parsed.begin(),parsed.end(),child) != parsed.end())
child = child->NextSiblingElement(); ;
continue;
} else if (!strcasecmp(child->Value(),"gravity")) {
if (!strcasecmp(child->Value(),"gravity")) { double gx = 0.0, gy = 0.0;
double gx=0, gy=0; utl::getAttribute(child,"x",gx);
if (child->Attribute("x")) utl::getAttribute(child,"y",gy);
gx = atof(child->Attribute("x"));
if (child->Attribute("y"))
gy = atof(child->Attribute("y"));
elp->setGravity(gx,gy); elp->setGravity(gx,gy);
if (myPid == 0) if (myPid == 0)
std::cout <<"\nGravitation vector: " << gx <<" "<< gy << std::endl; std::cout <<"\nGravitation vector: " << gx <<" "<< gy << std::endl;
} else if (!strcasecmp(child->Value(),"isotropic")) { }
int code=0;
if (child->Attribute("code")) else if (!strcasecmp(child->Value(),"isotropic")) {
code = atoi(child->Attribute("code")); int code = 0;
if (code > 0) if (utl::getAttribute(child,"code",code) && code > 0)
setPropertyType(code,Property::MATERIAL,mVec.size()); setPropertyType(code,Property::MATERIAL,mVec.size());
double E=1000.f, nu=0.3f, rho = 1.f; double E = 1000.0, nu = 0.3, rho = 1.0;
if (child->Attribute("E")) utl::getAttribute(child,"E",E);
E = atof(child->Attribute("E")); utl::getAttribute(child,"nu",nu);
if (child->Attribute("rho")) utl::getAttribute(child,"rho",rho);
rho = atof(child->Attribute("rho"));
if (child->Attribute("nu"))
nu = atof(child->Attribute("nu"));
mVec.push_back(new LinIsotropic(E,nu,rho,!planeStrain,axiSymmetry)); mVec.push_back(new LinIsotropic(E,nu,rho,!planeStrain,axiSymmetry));
if (myPid == 0) if (myPid == 0)
std::cout <<"\tMaterial code "<< code <<": " std::cout <<"\tMaterial code "<< code <<": "
<< E <<" "<< nu <<" "<< rho << std::endl; << E <<" "<< nu <<" "<< rho << std::endl;
if (!mVec.empty()) }
elp->setMaterial(mVec.front());
} else if (!strcasecmp(child->Value(),"constantpressure")) { else if (!strcasecmp(child->Value(),"constantpressure") ||
int code=0, pdir=1; !strcasecmp(child->Value(),"linearpressure")) {
double p=0; if (child->FirstChild() && child->FirstChild()->Value()) {
if (child->Attribute("code")) double p = atof(child->FirstChild()->Value());
code = atoi(child->Attribute("code")); int code = 0, pdir = 1;
if (child->Attribute("dir")) utl::getAttribute(child,"code",code);
pdir = atoi(child->Attribute("dir")); utl::getAttribute(child,"dir",pdir);
if (child->FirstChild() && child->FirstChild()->Value()) setPropertyType(code,Property::NEUMANN);
p = atof(child->FirstChild()->Value()); if (!strcasecmp(child->Value(),"linearpressure")) {
if (myPid == 0) RealFunc* pfl = new ConstTimeFunc(new LinearFunc(p));
std::cout <<"\tPressure code "<< code <<" direction "<< pdir myTracs[code] = new PressureField(pfl,pdir);
<<": "<< p << std::endl; }
setPropertyType(code,Property::NEUMANN); else
myTracs[code] = new PressureField(p,pdir); myTracs[code] = new PressureField(p,pdir);
} else if (!strcasecmp(child->Value(),"anasol")) { if (myPid == 0)
if (child->Attribute("type") && std::cout <<"\tPressure code "<< code <<" direction "<< pdir
!strcasecmp(child->Attribute("type"),"hole")) { <<": "<< p << std::endl;
double a=0, F0 = 0, nu = 0; }
if (child->Attribute("a")) }
a = atof(child->Attribute("a"));
if (child->Attribute("F0")) else if (!strcasecmp(child->Value(),"anasol")) {
F0 = atof(child->Attribute("F0")); std::string type;
if (child->Attribute("nu")) utl::getAttribute(child,"type",type,true);
nu = atof(child->Attribute("nu")); if (type == "hole") {
double a = 0.0, F0 = 0.0, nu = 0.0;
utl::getAttribute(child,"a",a);
utl::getAttribute(child,"F0",F0);
utl::getAttribute(child,"nu",nu);
mySol = new AnaSol(new Hole(a,F0,nu)); mySol = new AnaSol(new Hole(a,F0,nu));
std::cout <<"\nAnalytical solution: Hole a="<< a <<" F0="<< F0 std::cout <<"\nAnalytical solution: Hole a="<< a <<" F0="<< F0
<<" nu="<< nu << std::endl; <<" nu="<< nu << std::endl;
} else if (child->Attribute("type") && }
!strcasecmp(child->Attribute("type"),"Lshape")) { else if (type == "lshape") {
double a=0, F0 = 0, nu = 0; double a = 0.0, F0 = 0.0, nu = 0.0;
if (child->Attribute("a")) utl::getAttribute(child,"a",a);
a = atof(child->Attribute("a")); utl::getAttribute(child,"F0",F0);
if (child->Attribute("F0")) utl::getAttribute(child,"nu",nu);
F0 = atof(child->Attribute("F0"));
if (child->Attribute("nu"))
nu = atof(child->Attribute("nu"));
mySol = new AnaSol(new Lshape(a,F0,nu)); mySol = new AnaSol(new Lshape(a,F0,nu));
std::cout <<"\nAnalytical solution: Lshape a="<< a <<" F0="<< F0 std::cout <<"\nAnalytical solution: Lshape a="<< a <<" F0="<< F0
<<" nu="<< nu << std::endl; <<" nu="<< nu << std::endl;
} else if (child->Attribute("type") && }
!strcasecmp(child->Attribute("type"),"cants")) { else if (type == "cants") {
double L=0, F0 = 0, H = 0; double L = 0.0, H = 0.0, F0 = 0.0;
if (child->Attribute("L")) utl::getAttribute(child,"L",L);
L = atof(child->Attribute("L")); utl::getAttribute(child,"H",H);
if (child->Attribute("F0")) utl::getAttribute(child,"F0",F0);
F0 = atof(child->Attribute("F0"));
if (child->Attribute("H"))
H = atof(child->Attribute("H"));
mySol = new AnaSol(new CanTS(L,H,F0)); mySol = new AnaSol(new CanTS(L,H,F0));
std::cout <<"\nAnalytical solution: CanTS L="<< L <<" H="<< H std::cout <<"\nAnalytical solution: CanTS L="<< L <<" H="<< H
<<" F0="<< F0 << std::endl; <<" F0="<< F0 << std::endl;
} else if (child->Attribute("type") && }
!strcasecmp(child->Attribute("type"),"cantm")) { else if (type == "cantm") {
double M0 = 0, H = 0; double L = 0.0, H = 0.0, M0 = 0.0;
if (child->Attribute("M0")) utl::getAttribute(child,"L",L);
M0 = atof(child->Attribute("M0")); utl::getAttribute(child,"H",H);
if (child->Attribute("H")) utl::getAttribute(child,"M0",M0);
H = atof(child->Attribute("H"));
mySol = new AnaSol(new CanTM(H,M0)); mySol = new AnaSol(new CanTM(H,M0));
std::cout <<"\nAnalytical solution: CanTM H="<< H std::cout <<"\nAnalytical solution: CanTM H="<< H
<<" M0="<< M0 << std::endl; <<" M0="<< M0 << std::endl;
} else if (child->Attribute("type") && }
!strcasecmp(child->Attribute("type"),"curved")) { else if (type == "curved") {
double a=0, b=0, u0 = 0, E = 0; double a = 0.0, b = 0.0, u0 = 0.0, E = 0.0;
if (child->Attribute("a")) utl::getAttribute(child,"a",a);
a = atof(child->Attribute("a")); utl::getAttribute(child,"b",b);
if (child->Attribute("b")) utl::getAttribute(child,"u0",u0);
b = atof(child->Attribute("b")); utl::getAttribute(child,"E",E);
if (child->Attribute("u0"))
u0 = atof(child->Attribute("u0"));
if (child->Attribute("E"))
E = atof(child->Attribute("E"));
mySol = new AnaSol(new CurvedBeam(u0,a,b,E)); mySol = new AnaSol(new CurvedBeam(u0,a,b,E));
std::cout <<"\nAnalytical solution: Curved Beam a="<< a <<" b="<< b std::cout <<"\nAnalytical solution: Curved Beam a="<< a <<" b="<< b
<<" u0="<< u0 <<" E="<< E << std::endl; <<" u0="<< u0 <<" E="<< E << std::endl;
} else if (child->Attribute("type") && }
!strcasecmp(child->Attribute("type"),"expression")) { else if (type == "expression") {
std::string variables, stress; std::string variables, stress;
const TiXmlElement* var = child->FirstChildElement("variables"); const TiXmlElement* var = child->FirstChildElement("variables");
if (var && var->FirstChild() && var->FirstChild()->Value()) { if (var && var->FirstChild() && var->FirstChild()->Value()) {
@ -432,27 +420,28 @@ bool SIMLinEl2D::parse(const TiXmlElement* elem)
if (!variables.empty()) if (!variables.empty())
std::cout <<"\n\tVariables = "<< variables; std::cout <<"\n\tVariables = "<< variables;
std::cout <<"\n\tStress = "<< stress << std::endl; std::cout <<"\n\tStress = "<< stress << std::endl;
} else {
std::cerr <<" ** SIMLinEl2D::parse: Unknown analytical solution "
<< (child->Attribute("type")?child->Attribute("type"):"") << std::endl;
} }
else
std::cerr <<" ** SIMLinEl2D::parse: Unknown analytical solution "
<< type << std::endl;
// Define the analytical boundary traction field // Define the analytical boundary traction field
int code=0; int code = 0;
if (child->Attribute("code")) utl::getAttribute(child,"code",code);
code = atoi(child->Attribute("code"));
if (code > 0 && mySol && mySol->getStressSol()) { if (code > 0 && mySol && mySol->getStressSol()) {
std::cout <<"Pressure code "<< code <<": Analytical traction"<< std::endl; std::cout <<"Pressure code "<< code
<<": Analytical traction"<< std::endl;
setPropertyType(code,Property::NEUMANN); setPropertyType(code,Property::NEUMANN);
myTracs[code] = new TractionField(*mySol->getStressSol()); myTracs[code] = new TractionField(*mySol->getStressSol());
} }
} }
else
SIM2D::parse(child);
child = child->NextSiblingElement(); child = child->NextSiblingElement();
} }
if (!mVec.empty())
elp->setMaterial(mVec.front());
return true; return true;
} }

View File

@ -199,6 +199,7 @@ bool SIMLinEl3D::parse (char* keyWord, std::istream& is)
int code = atoi(strtok(cline," ")); int code = atoi(strtok(cline," "));
if (code > 0) if (code > 0)
this->setPropertyType(code,Property::MATERIAL,mVec.size()); this->setPropertyType(code,Property::MATERIAL,mVec.size());
double E = atof(strtok(NULL," ")); double E = atof(strtok(NULL," "));
double nu = atof(strtok(NULL," ")); double nu = atof(strtok(NULL," "));
double rho = atof(strtok(NULL," ")); double rho = atof(strtok(NULL," "));
@ -258,13 +259,14 @@ bool SIMLinEl3D::parse (char* keyWord, std::istream& is)
code = 0; code = 0;
for (int i = 0; i < lines; i++) { for (int i = 0; i < lines; i++) {
std::string function = utl::readLine(is); std::string function = utl::readLine(is);
size_t pos; size_t pos = function.find("Variables=");
if ((pos = function.find("Variables=")) != std::string::npos) { if (pos != std::string::npos) {
variables += function.substr(pos+10); variables += function.substr(pos+10);
if (variables[variables.size()-1] != ';') if (variables[variables.size()-1] != ';')
variables += ";"; variables += ";";
} }
if ((pos = function.find("Stress=")) != std::string::npos) { pos = function.find("Stress=");
if (pos != std::string::npos) {
stress = function.substr(pos+7); stress = function.substr(pos+7);
mySol = new AnaSol(new STensorFuncExpr(stress,variables)); mySol = new AnaSol(new STensorFuncExpr(stress,variables));
std::cout <<"\nAnalytical solution:"; std::cout <<"\nAnalytical solution:";
@ -284,7 +286,7 @@ bool SIMLinEl3D::parse (char* keyWord, std::istream& is)
// Define the analytical boundary traction field // Define the analytical boundary traction field
if (code == -1) if (code == -1)
code = (cline = strtok(NULL," ")) ? atoi(cline) : 0; code = (cline = strtok(NULL," ")) ? atoi(cline) : 0;
if (code > 0 && mySol->getStressSol()) if (code > 0 && mySol->getStressSol())
{ {
std::cout <<"Pressure code "<< code <<": Analytical traction"<< std::endl; std::cout <<"Pressure code "<< code <<": Analytical traction"<< std::endl;
@ -377,10 +379,10 @@ bool SIMLinEl3D::parse (char* keyWord, std::istream& is)
myProps.push_back(Property(Property::MATERIAL,mVec.size(),pid,3)); myProps.push_back(Property(Property::MATERIAL,mVec.size(),pid,3));
mVec.push_back(new LinIsotropic(E,nu,rho)); mVec.push_back(new LinIsotropic(E,nu,rho));
} }
if (!mVec.empty())
elp->setMaterial(mVec.front());
} }
if (!mVec.empty())
elp->setMaterial(mVec.front());
} }
else if (!strncasecmp(keyWord,"LOCAL_SYSTEM",12)) else if (!strncasecmp(keyWord,"LOCAL_SYSTEM",12))
@ -429,110 +431,97 @@ bool SIMLinEl3D::parse (char* keyWord, std::istream& is)
} }
bool SIMLinEl3D::parse(const TiXmlElement* elem) bool SIMLinEl3D::parse (const TiXmlElement* elem)
{ {
if (strcasecmp(elem->Value(),"linearelasticity")) if (strcasecmp(elem->Value(),"elasticity"))
return SIM3D::parse(elem); return this->SIM3D::parse(elem);
Elasticity* elp = dynamic_cast<Elasticity*>(myProblem); Elasticity* elp = dynamic_cast<Elasticity*>(myProblem);
if (!elp) if (!elp) return false;
return false;
std::vector<const TiXmlElement*> parsed = handlePriorityTags(elem); std::vector<const TiXmlElement*> parsed = handlePriorityTags(elem);
const TiXmlElement* child = elem->FirstChildElement(); const TiXmlElement* child = elem->FirstChildElement();
while (child) { while (child) {
if (find(parsed.begin(),parsed.end(),child) != parsed.end()) { if (find(parsed.begin(),parsed.end(),child) != parsed.end())
child = child->NextSiblingElement(); ;
continue;
} else if (!strcasecmp(child->Value(),"gravity")) {
if (!strcasecmp(child->Value(),"gravity")) { double gx = 0.0, gy = 0.0, gz = 0.0;
double gx=0, gy=0, gz=0; utl::getAttribute(child,"x",gx);
if (child->Attribute("x")) utl::getAttribute(child,"y",gy);
gx = atof(child->Attribute("x")); utl::getAttribute(child,"z",gz);
if (child->Attribute("y"))
gy = atof(child->Attribute("y"));
if (child->Attribute("z"))
gz = atof(child->Attribute("z"));
elp->setGravity(gx,gy,gz); elp->setGravity(gx,gy,gz);
if (myPid == 0) if (myPid == 0)
std::cout <<"\nGravitation vector: " << gx <<" "<< gy <<" " << gz << std::endl; std::cout <<"\nGravitation vector: "<< gx <<" "<< gy <<" "<< gz
} else if (!strcasecmp(child->Value(),"isotropic")) { << std::endl;
int code=0; }
if (child->Attribute("code"))
code = atoi(child->Attribute("code")); else if (!strcasecmp(child->Value(),"isotropic")) {
if (code > 0) int code = 0;
if (utl::getAttribute(child,"code",code) && code > 0)
setPropertyType(code,Property::MATERIAL,mVec.size()); setPropertyType(code,Property::MATERIAL,mVec.size());
double E=1000.f, nu=0.3f, rho = 1.f; double E = 1000.0, nu = 0.3, rho = 1.0;
if (child->Attribute("E")) utl::getAttribute(child,"E",E);
E = atof(child->Attribute("E")); utl::getAttribute(child,"nu",nu);
if (child->Attribute("rho")) utl::getAttribute(child,"rho",rho);
rho = atof(child->Attribute("rho"));
if (child->Attribute("nu"))
nu = atof(child->Attribute("nu"));
mVec.push_back(new LinIsotropic(E,nu,rho)); mVec.push_back(new LinIsotropic(E,nu,rho));
if (myPid == 0) if (myPid == 0)
std::cout <<"\tMaterial code "<< code <<": " std::cout <<"\tMaterial code "<< code <<": "
<< E <<" "<< nu <<" "<< rho << std::endl; << E <<" "<< nu <<" "<< rho << std::endl;
if (!mVec.empty()) }
elp->setMaterial(mVec.front());
} else if (!strcasecmp(child->Value(),"constantpressure") || else if (!strcasecmp(child->Value(),"constantpressure") ||
!strcasecmp(child->Value(),"linearpressure")) { !strcasecmp(child->Value(),"linearpressure")) {
int code=0, pdir=1; if (child->FirstChild() && child->FirstChild()->Value()) {
double p=0; double p = atof(child->FirstChild()->Value());
if (child->Attribute("code")) int code = 0, pdir = 1;
code = atoi(child->Attribute("code")); utl::getAttribute(child,"code",code);
if (child->Attribute("dir")) utl::getAttribute(child,"dir",pdir);
pdir = atoi(child->Attribute("dir")); setPropertyType(code,Property::NEUMANN);
if (child->FirstChild() && child->FirstChild()->Value()) if (!strcasecmp(child->Value(),"linearpressure")) {
p = atof(child->FirstChild()->Value()); RealFunc* pfl = new ConstTimeFunc(new LinearFunc(p));
if (myPid == 0) myTracs[code] = new PressureField(pfl,pdir);
std::cout <<"\tPressure code "<< code <<" direction "<< pdir }
<<": "<< p << std::endl; else
setPropertyType(code,Property::NEUMANN); myTracs[code] = new PressureField(p,pdir);
if (!strcasecmp(child->Value(),"linearpressure")) { if (myPid == 0)
RealFunc* pfl = new ConstTimeFunc(new LinearFunc(p)); std::cout <<"\tPressure code "<< code <<" direction "<< pdir
myTracs[code] = new PressureField(pfl,pdir); <<": "<< p << std::endl;
} else }
myTracs[code] = new PressureField(p,pdir);
} else if (!strcasecmp(child->Value(),"anasol")) { }
if (child->Attribute("type") && else if (!strcasecmp(child->Value(),"anasol")) {
!strcasecmp(child->Attribute("type"),"hole")) { std::string type;
double a=0, F0 = 0, nu = 0; utl::getAttribute(child,"type",type,true);
if (child->Attribute("a")) if (type == "hole") {
a = atof(child->Attribute("a")); double a = 0.0, F0 = 0.0, nu = 0.0;
if (child->Attribute("F0")) utl::getAttribute(child,"a",a);
F0 = atof(child->Attribute("F0")); utl::getAttribute(child,"F0",F0);
if (child->Attribute("nu")) utl::getAttribute(child,"nu",nu);
nu = atof(child->Attribute("nu"));
mySol = new AnaSol(new Hole(a,F0,nu,true)); mySol = new AnaSol(new Hole(a,F0,nu,true));
std::cout <<"\nAnalytical solution: Hole a="<< a <<" F0="<< F0 std::cout <<"\nAnalytical solution: Hole a="<< a <<" F0="<< F0
<<" nu="<< nu << std::endl; <<" nu="<< nu << std::endl;
} else if (child->Attribute("type") && }
!strcasecmp(child->Attribute("type"),"Lshape")) { else if (type == "lshape") {
double a=0, F0 = 0, nu = 0; double a = 0.0, F0 = 0.0, nu = 0.0;
if (child->Attribute("a")) utl::getAttribute(child,"a",a);
a = atof(child->Attribute("a")); utl::getAttribute(child,"F0",F0);
if (child->Attribute("F0")) utl::getAttribute(child,"nu",nu);
F0 = atof(child->Attribute("F0"));
if (child->Attribute("nu"))
nu = atof(child->Attribute("nu"));
mySol = new AnaSol(new Lshape(a,F0,nu,true)); mySol = new AnaSol(new Lshape(a,F0,nu,true));
std::cout <<"\nAnalytical solution: Lshape a="<< a <<" F0="<< F0 std::cout <<"\nAnalytical solution: Lshape a="<< a <<" F0="<< F0
<<" nu="<< nu << std::endl; <<" nu="<< nu << std::endl;
} else if (child->Attribute("type") && }
!strcasecmp(child->Attribute("type"),"cants")) { else if (type == "cants") {
double L=0, F0 = 0, H = 0; double L = 0.0, H = 0.0, F0 = 0.0;
if (child->Attribute("L")) utl::getAttribute(child,"L",L);
L = atof(child->Attribute("L")); utl::getAttribute(child,"H",H);
if (child->Attribute("F0")) utl::getAttribute(child,"F0",F0);
F0 = atof(child->Attribute("F0"));
if (child->Attribute("H"))
H = atof(child->Attribute("H"));
mySol = new AnaSol(new CanTS(L,H,F0,true)); mySol = new AnaSol(new CanTS(L,H,F0,true));
std::cout <<"\nAnalytical solution: CanTS L="<< L <<" H="<< H std::cout <<"\nAnalytical solution: CanTS L="<< L <<" H="<< H
<<" F0="<< F0 << std::endl; <<" F0="<< F0 << std::endl;
} else if (child->Attribute("type") && }
!strcasecmp(child->Attribute("type"),"expression")) { else if (type == "expression") {
std::string variables, stress; std::string variables, stress;
const TiXmlElement* var = child->FirstChildElement("variables"); const TiXmlElement* var = child->FirstChildElement("variables");
if (var && var->FirstChild() && var->FirstChild()->Value()) { if (var && var->FirstChild() && var->FirstChild()->Value()) {
@ -548,45 +537,43 @@ bool SIMLinEl3D::parse(const TiXmlElement* elem)
if (!variables.empty()) if (!variables.empty())
std::cout <<"\n\tVariables = "<< variables; std::cout <<"\n\tVariables = "<< variables;
std::cout <<"\n\tStress = "<< stress << std::endl; std::cout <<"\n\tStress = "<< stress << std::endl;
} else {
std::cerr <<" ** SIMLinEl3D::parse: Unknown analytical solution "
<< (child->Attribute("type")?child->Attribute("type"):"") << std::endl;
} }
else
std::cerr <<" ** SIMLinEl3D::parse: Unknown analytical solution "
<< type << std::endl;
// Define the analytical boundary traction field // Define the analytical boundary traction field
int code=0; int code = 0;
if (child->Attribute("code")) utl::getAttribute(child,"code",code);
code = atoi(child->Attribute("code"));
if (code > 0 && mySol &&mySol->getStressSol()) { if (code > 0 && mySol &&mySol->getStressSol()) {
std::cout <<"Pressure code "<< code <<": Analytical traction"<< std::endl; std::cout <<"Pressure code "<< code
<<": Analytical traction"<< std::endl;
setPropertyType(code,Property::NEUMANN); setPropertyType(code,Property::NEUMANN);
myTracs[code] = new TractionField(*mySol->getStressSol()); myTracs[code] = new TractionField(*mySol->getStressSol());
} }
} else if (!strcasecmp(child->Value(),"localsystem")) { }
bool ok=true;
else if (!strcasecmp(child->Value(),"localsystem")) {
if (child->FirstChild() && child->FirstChild()->Value()) { if (child->FirstChild() && child->FirstChild()->Value()) {
if (!strcasecmp(child->FirstChild()->Value(),"cylindricz")) if (!strcasecmp(child->FirstChild()->Value(),"cylindricz"))
elp->setLocalSystem(new CylinderCS); elp->setLocalSystem(new CylinderCS);
else if (!strcasecmp(child->FirstChild()->Value(),"cylinder+sphere")) { else if (!strcasecmp(child->FirstChild()->Value(),"cylinder+sphere")) {
double H = 0; double H = 0.0;
if (child->Attribute("H")) utl::getAttribute(child,"H",H);
H = atof(child->Attribute("H"));
elp->setLocalSystem(new CylinderSphereCS(H)); elp->setLocalSystem(new CylinderSphereCS(H));
} }
else else
ok = false; std::cerr <<" *** SIMLinEl3D::parse: Unsupported coordinate system: "
} << child->FirstChild()->Value() << std::endl;
if (!ok) {
const char* type=NULL;
if (child->FirstChild() && child->FirstChild()->Value())
type = child->FirstChild()->Value();
std::cerr <<" *** SIMLinEl3D::parse: Unsupported coordinate system: "
<< (type?type:"") << std::endl;
} }
} }
child = child->NextSiblingElement(); child = child->NextSiblingElement();
} }
if (!mVec.empty())
elp->setMaterial(mVec.front());
return true; return true;
} }