From 47c1f4e1dc969d9bd69824bec498d0c296b27cc0 Mon Sep 17 00:00:00 2001 From: Knut Morten Okstad Date: Wed, 25 May 2016 06:45:09 +0200 Subject: [PATCH 1/2] Added: Option to use NonLinSIM and HHTSIM as the time integrator --- main_FractureDynamics.C | 46 +++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/main_FractureDynamics.C b/main_FractureDynamics.C index 24d68e6..59d2546 100644 --- a/main_FractureDynamics.C +++ b/main_FractureDynamics.C @@ -20,7 +20,9 @@ #include "SIMCoupledSI.h" #include "SIMSolver.h" #include "SIMSolverTS.h" +#include "HHTSIM.h" #include "GenAlphaSIM.h" +#include "NewmarkNLSIM.h" #include "NonLinSIM.h" #include "ASMstruct.h" #include "AppCommon.h" @@ -100,7 +102,7 @@ int runSimulator2 (char* infile) phaseSim.opt.print(IFEM::cout) << std::endl; SIMFractureDynamics frac(elastoSim,phaseSim,infile); - SIMDriver solver(frac,"newmarksolver"); + SIMDriver solver(frac,Integrator::inputContext); if (!solver.read(infile)) return 1; @@ -141,7 +143,7 @@ int runSimulator2 (char* infile) */ template -int runSimulator3 (char* infile, const char* context = "newmarksolver") +int runSimulator3 (char* infile, const char* context) { typedef SIMDynElasticity SIMElastoDynamics; @@ -216,8 +218,8 @@ int runSimulator1 (char* infile, char coupling, bool timeslabs) return runSolver(infile,timeslabs); else if (coupling == 2) return runSolver(infile,timeslabs); - else - return runSimulator3(infile); // No phase field coupling + else // No phase field coupling + return runSimulator3(infile,Integrator::inputContext); } @@ -239,7 +241,8 @@ public: \brief Creates the combined fracture simulator and launches the simulation. \param[in] infile The input file to parse \param[in] integrator The time integrator to use (0=linear quasi-static, - no phase-field coupling, 1=linear Newmark, 2=Generalized alpha) + no phase-field coupling, 1=linear Newmark, 2=Generalized alpha, + 3=nonlinear quasi-static, 4=nonlinear Hilber-Hughes-Taylor) \param[in] coupling Coupling flag (0: none, 1: staggered, 2: semi-implicit) \param[in] timeslabs Use time-slab adaptive solver */ @@ -247,12 +250,23 @@ public: template int runSimulator (char* infile, char integrator, char coupling, bool timeslabs) { - if (integrator == 2) - return runSimulator1(infile,coupling,timeslabs); - else if (integrator > 0) - return runSimulator1(infile,coupling,timeslabs); - else + switch (integrator) { + case 0: return runSimulator3(infile,"staticsolver"); + case 1: + return runSimulator1(infile,coupling,timeslabs); + case 2: + return runSimulator1(infile,coupling,timeslabs); + case 3: + return runSimulator1(infile,coupling,timeslabs); + case 4: + return runSimulator1(infile,coupling,timeslabs); + case 5: + return runSimulator1(infile,coupling,timeslabs); + default: + std::cerr <<" *** Invalid time integrator "<< integrator << std::endl; + return 99; + } } @@ -282,10 +296,16 @@ int main (int argc, char** argv) coupling = 0; else if (!strcmp(argv[i],"-semiimplicit")) coupling = 2; - else if (!strcmp(argv[i],"-static")) + else if (!strcmp(argv[i],"-lstatic")) integrator = 0; else if (!strcmp(argv[i],"-GA")) integrator = 2; + else if (!strcmp(argv[i],"-qstatic")) + integrator = 3; + else if (!strcmp(argv[i],"-HHT")) + integrator = 4; + else if (!strcmp(argv[i],"-oldHHT")) + integrator = 5; else if (!strcmp(argv[i],"-principal")) Elasticity::wantPrincipalStress = true; else if (!strcmp(argv[i],"-dbgElm") && i < argc-1) @@ -301,8 +321,8 @@ int main (int argc, char** argv) { std::cout <<"usage: "<< argv[0] <<" [-dense|-spr|-superlu[]|-samg|-petsc]\n" - <<" [-lag|-spec|-LR] [-2D] [-nGauss ]\n" - <<" [-nocrack|-semiimplicit] [-static|-GA] [-adaptive]\n" + <<" [-lag|-spec|-LR] [-2D] [-nGauss ]\n " + <<"[-nocrack|-semiimplicit] [-[l|q]static|-GA|-HHT] [-adaptive]\n" <<" [-vtf [-nviz ] [-nu ] [-nv ]] [-hdf5] [-principal]\n"<< std::endl; return 0; From 91743d652671ea60584cf1aaf1d1235e75a196de Mon Sep 17 00:00:00 2001 From: Knut Morten Okstad Date: Sat, 4 Jun 2016 09:05:37 +0200 Subject: [PATCH 2/2] Changed: The executing command is now printed by IFEM::Init --- main_CahnHilliard.C | 14 +++++--------- main_FractureDynamics.C | 13 ++++--------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/main_CahnHilliard.C b/main_CahnHilliard.C index d1189ea..6479c3d 100644 --- a/main_CahnHilliard.C +++ b/main_CahnHilliard.C @@ -70,12 +70,12 @@ int main (int argc, char** argv) { Profiler prof(argv[0]); - int i, ndim = 3; - char* infile = 0; + int ndim = 3; + char* infile = nullptr; - IFEM::Init(argc,argv); + IFEM::Init(argc,argv,"Cahn-Hilliard equation solver"); - for (i = 1; i < argc; i++) + for (int i = 1; i < argc; i++) if (SIMoptions::ignoreOldOptions(argc,argv,i)) ; // ignore the obsolete option else if (!strcmp(argv[i],"-2D")) @@ -97,11 +97,7 @@ int main (int argc, char** argv) return 0; } - IFEM::cout <<"\n >>> IFEM Cahn-Hilliard equation solver <<<" - <<"\n ==========================================\n" - <<"\n Executing command:\n"; - for (i = 0; i < argc; i++) IFEM::cout <<" "<< argv[i]; - IFEM::cout <<"\n\nInput file: "<< infile; + IFEM::cout <<"\nInput file: "<< infile; IFEM::getOptions().print(IFEM::cout); IFEM::cout << std::endl; diff --git a/main_FractureDynamics.C b/main_FractureDynamics.C index 59d2546..aac3cfb 100644 --- a/main_FractureDynamics.C +++ b/main_FractureDynamics.C @@ -278,16 +278,15 @@ int main (int argc, char** argv) { Profiler prof(argv[0]); - int i; - char* infile = 0; + char* infile = nullptr; char coupling = 1; char integrator = 1; bool twoD = false; bool adaptive = false; - IFEM::Init(argc,argv); + IFEM::Init(argc,argv,"Fracture dynamics solver"); - for (i = 1; i < argc; i++) + for (int i = 1; i < argc; i++) if (SIMoptions::ignoreOldOptions(argc,argv,i)) ; // ignore the obsolete option else if (!strcmp(argv[i],"-2D")) @@ -331,11 +330,7 @@ int main (int argc, char** argv) if (adaptive) IFEM::getOptions().discretization = ASM::LRSpline; - IFEM::cout <<"\n >>> IFEM Fracture dynamics solver <<<" - <<"\n =====================================\n" - <<"\n Executing command:\n"; - for (i = 0; i < argc; i++) IFEM::cout <<" "<< argv[i]; - IFEM::cout <<"\n\nInput file: "<< infile; + IFEM::cout <<"\nInput file: "<< infile; IFEM::getOptions().print(IFEM::cout); IFEM::cout << std::endl;