Skip to content

Commit 71bfb7b

Browse files
committed
Changed: Derive class NLargs from SIMargsBase
1 parent 5c89ede commit 71bfb7b

3 files changed

Lines changed: 30 additions & 39 deletions

File tree

NLargs.C

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ bool NLargs::parseArg (const char* argv)
3737
else if (!strcmp(argv,"-fixDup"))
3838
fixDup = true;
3939
else if (!strncmp(argv,"-2Dpstra",8))
40-
twoD = Elastic::planeStrain = true;
40+
{
41+
dim = 2;
42+
Elastic::planeStrain = true;
43+
}
4144
else if (!strncmp(argv,"-2Daxi",6))
42-
twoD = Elastic::axiSymmetry = true;
43-
else if (!strncmp(argv,"-2D",3))
44-
twoD = true;
45+
{
46+
dim = 2;
47+
Elastic::axiSymmetry = true;
48+
}
4549
else if (!strcmp(argv,"-linear"))
4650
form = SIM::LINEAR;
4751
else if (!strcmp(argv,"-UL"))
@@ -81,10 +85,8 @@ bool NLargs::parseArg (const char* argv)
8185
algor = NEWHHT;
8286
else if (!strcmp(argv,"-arclen"))
8387
algor = ARCLEN;
84-
else if (!strncmp(argv,"-adap",5))
85-
adaptive = true;
8688
else
87-
return false;
89+
return this->SIMargsBase::parseArg(argv);
8890

8991
this->setFormulation(form,pOrd);
9092
return true;
@@ -93,16 +95,8 @@ bool NLargs::parseArg (const char* argv)
9395

9496
bool NLargs::parse (const tinyxml2::XMLElement* elem)
9597
{
96-
if (!strcasecmp(elem->Value(),"geometry"))
97-
{
98-
int dim = 3;
99-
if (!utl::getAttribute(elem,"dimension",dim))
100-
utl::getAttribute(elem,"dim",dim);
101-
twoD = dim == 2;
102-
}
103-
else if (!strcasecmp(elem->Value(),"finitedeformation"))
98+
if (!strcasecmp(elem->Value(),"finitedeformation"))
10499
{
105-
utl::getAttribute(elem,"adaptive",adaptive);
106100
const tinyxml2::XMLElement* child = elem->FirstChildElement("formulation");
107101
if (child) this->parseFormulation(child);
108102
}
@@ -123,7 +117,7 @@ bool NLargs::parse (const tinyxml2::XMLElement* elem)
123117
algor = NEWHHT;
124118
}
125119

126-
return IFEM::getOptions().parseDiscretizationTag(elem);
120+
return this->SIMargsBase::parse(elem);
127121
}
128122

129123

@@ -135,9 +129,9 @@ void NLargs::parseFormulation (const tinyxml2::XMLElement* elem)
135129
const tinyxml2::XMLElement* child = elem->FirstChildElement();
136130
for (; child; child = child->NextSiblingElement())
137131
if (!strcasecmp(child->Value(),"planestrain"))
138-
Elastic::planeStrain = twoD;
132+
Elastic::planeStrain = dim == 2;
139133
else if (!strcasecmp(child->Value(),"axisymmetric"))
140-
Elastic::axiSymmetry = twoD;
134+
Elastic::axiSymmetry = dim == 2;
141135
else if (!strcasecmp(child->Value(),"totallagrange"))
142136
form = SIM::TOTAL_LAGRANGE;
143137
else if (!strcasecmp(child->Value(),"updatedlagrange") &&

NLargs.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifndef _NL_ARGS_H
1515
#define _NL_ARGS_H
1616

17-
#include "XMLInputBase.h"
17+
#include "SIMargsBase.h"
1818

1919

2020
//! \brief Enum defining various solution drivers.
@@ -25,11 +25,13 @@ enum Algorithm { ARCLEN, STATIC, GENALPHA, OLDHHT, NEWHHT };
2525
\brief Class for input file pre-parsing and command-line argument values.
2626
*/
2727

28-
class NLargs : public XMLInputBase
28+
class NLargs : public SIMargsBase
2929
{
3030
public:
31+
//! \brief Default constructor.
32+
explicit NLargs() : SIMargsBase("finitedeformation") {}
3133
//! \brief Parses a command-line argument.
32-
bool parseArg(const char* argv);
34+
virtual bool parseArg(const char* argv);
3335

3436
protected:
3537
//! \brief Parses a data section from an XML element.
@@ -44,10 +46,8 @@ class NLargs : public XMLInputBase
4446
public:
4547
std::vector<int> options; //!< Problem formulation options
4648
Algorithm algor = STATIC; //!< Solution algorithm driver flag
47-
bool adaptive = false; //!< Run and adaptive simulation?
4849
bool checkRHS = false; //!< Check for right-hand-side patch orientation?
4950
bool fixDup = false; //!< Check and resolve duplicated nodes?
50-
bool twoD = false; //!< Use the 2D driver?
5151
char printMax = false; //!< Print out max field values?
5252
bool dNodeMap = false; //!< Dump node mapping to HDF5 file?
5353
};

main_NonLinEl.C

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,15 @@ int main (int argc, char** argv)
312312
stopTime = atof(argv[++i]);
313313
else if (!strcmp(argv[i],"-check"))
314314
stopTime = -1.0;
315-
else if (!infile)
315+
else if (infile)
316+
std::cerr <<" ** Unknown option ignored: "<< argv[i] << std::endl;
317+
else if (strcasestr(infile = argv[i],".xinp"))
316318
{
317-
infile = argv[i];
318-
if (strcasestr(infile,".xinp"))
319-
{
320-
if (!args.readXML(infile,false))
321-
return 1;
319+
if (args.readXML(infile,false))
322320
i = 0; // start over and let command-line options override input file
323-
}
321+
else
322+
return 1; // pre-parse failure
324323
}
325-
else
326-
std::cerr <<" ** Unknown option ignored: "<< argv[i] << std::endl;
327324

328325
if (!infile)
329326
{
@@ -342,10 +339,10 @@ int main (int argc, char** argv)
342339
return 0;
343340
}
344341

345-
if (IFEM::getOptions().discretization == ASM::Spline && args.adaptive)
342+
if (IFEM::getOptions().discretization == ASM::Spline && args.adap)
346343
IFEM::getOptions().discretization = ASM::LRSpline;
347344
else if (IFEM::getOptions().discretization < ASM::LRSpline)
348-
args.adaptive = false;
345+
args.adap = false;
349346

350347
IFEM::cout <<"\nInput file: "<< infile;
351348
IFEM::getOptions().print(IFEM::cout);
@@ -378,7 +375,7 @@ int main (int argc, char** argv)
378375
if (linear && args.algor > STATIC)
379376
{
380377
// Create the linear continuum model
381-
if (args.twoD)
378+
if (args.dim == 2)
382379
model = new SIMElasticity<SIM2D>(args.checkRHS);
383380
else
384381
model = new SIMElasticity<SIM3D>(args.checkRHS);
@@ -400,7 +397,7 @@ int main (int argc, char** argv)
400397
}
401398

402399
// Create the nonlinear continuum model
403-
if (args.twoD)
400+
if (args.dim == 2)
404401
model = new SIMFiniteDefEl<SIM2D>(args.checkRHS,args.options);
405402
else
406403
model = new SIMFiniteDefEl<SIM3D>(args.checkRHS,args.options);
@@ -409,15 +406,15 @@ int main (int argc, char** argv)
409406
case STATIC:
410407
{
411408
// Invoke the nonlinear quasi-static solver with fixed load increments
412-
NonlinearDriver simulator(*model,linear,args.adaptive);
409+
NonlinearDriver simulator(*model,linear,args.adap);
413410
return runSimulator(simulator,model,infile,ignoredPatches,args.fixDup,
414411
args.printMax,dtDump,stopTime,zero_tol,outPrec,
415412
args.dNodeMap);
416413
}
417414
case ARCLEN:
418415
{
419416
// Invoke the nonlinear quasi-static arc-length solver
420-
ArcLengthDriver simulator(*model,args.adaptive);
417+
ArcLengthDriver simulator(*model,args.adap);
421418
return runSimulator(simulator,model,infile,ignoredPatches,args.fixDup,
422419
args.printMax,dtDump,stopTime,zero_tol,outPrec,
423420
args.dNodeMap);

0 commit comments

Comments
 (0)