当前位置: 首页>>代码示例>>C++>>正文


C++ Files::GetOutputPath方法代码示例

本文整理汇总了C++中Files::GetOutputPath方法的典型用法代码示例。如果您正苦于以下问题:C++ Files::GetOutputPath方法的具体用法?C++ Files::GetOutputPath怎么用?C++ Files::GetOutputPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Files的用法示例。


在下文中一共展示了Files::GetOutputPath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
  char *infile = new char [50];
 
  sprintf(infile,"./input/nsbenchreg.neu");
  
  //Adimensional quantity (Lref,Uref)
  double Lref = 1.;
  double Uref = 1.;
  
  MultiLevelMesh ml_msh(nm,nr,infile,"seventh",Lref,NULL);
   
  MultiLevelSolution ml_sol(&ml_msh);
   
  // generate solution vector
  ml_sol.AddSolution("U",LAGRANGE,SECOND,2);
  ml_sol.AddSolution("V",LAGRANGE,SECOND,2);
  // the pressure variable should be the last for the Schur decomposition
  ml_sol.AddSolution("P",DISCONTINOUS_POLYNOMIAL,FIRST,1);
  ml_sol.AssociatePropertyToSolution("P","Pressure");
  
  //Initialize (update Init(...) function)
  ml_sol.Initialize("All");
  
  //Set Boundary (update Dirichlet(...) function)
  ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryCondition);
  ml_sol.GenerateBdc("U","Time_dependent");
  ml_sol.GenerateBdc("V");
  ml_sol.GenerateBdc("P");

  
  MultiLevelProblem ml_prob(&ml_sol);
  
  
  Parameter parameter(Lref,Uref);
  
  // Generate fluid Object (Adimensional quantities,viscosity,density,fluid-model)
  Fluid fluid(parameter,0.001,1.,"Newtonian");
  cout << "Fluid properties: " << endl;
  cout << fluid << endl;  

  // add fluid material
  ml_prob.parameters.set<Fluid>("Fluid") = fluid;
  
  
 
  //create systems
  // add the system Navier-Stokes to the MultiLevel problem
  TransientNonlinearImplicitSystem & system = ml_prob.add_system<TransientNonlinearImplicitSystem> ("Navier-Stokes");
  system.AddSolutionToSystemPDE("U");
  system.AddSolutionToSystemPDE("V");
  system.AddSolutionToSystemPDE("P");
  
  // init all the systems
  system.init();
 
  // System Navier-Stokes
  system.SetAssembleFunction(AssembleMatrixResNS);  
  system.SetMaxNumberOfLinearIterations(1);
  system.SetLinearConvergenceTolerance(1.e-8);  
  system.SetMgType(V_CYCLE);
  system.SetMaxNumberOfNonLinearIterations(15);

  // time loop parameter
  system.SetIntervalTime(0.1);
  const unsigned int n_timesteps = 20;
  const unsigned int write_interval = 1;
  
  for (unsigned time_step = 0; time_step < n_timesteps; time_step++) {
   
    // Solving Navier-Stokes system
    std::cout << std::endl;
    std::cout << " *********** Navier-Stokes ************  " << std::endl;
    ml_prob.get_system("Navier-Stokes").solve();
   
    //update Solution
    ml_prob.get_system<TransientNonlinearImplicitSystem>("Navier-Stokes").UpdateSolution();

    // print solution
    if ( !(time_step%write_interval) ) {
        
      //print solution 
      std::vector<std::string> print_vars;
      print_vars.push_back("U");
      print_vars.push_back("V");
      print_vars.push_back("P");
      
//       ml_prob.printsol_vtu_inline("biquadratic",print_vars,time_step);
      VTKWriter vtkio(&ml_sol);
      vtkio.write(files.GetOutputPath(),"biquadratic",print_vars,time_step);
    }
  
  } //end loop timestep
  

  // Destroy all the new systems
  ml_prob.clear();
   

  delete[] infile;
  return 0;
}
开发者ID:coyigg,项目名称:femus,代码行数:101,代码来源:main.cpp

示例2: main


//.........这里部分代码省略.........
  system1.SetLinearConvergenceTolerance(1.e-10);
  system1.SetNonLinearConvergenceTolerance(1.e-10);
  system1.SetMgType(F_CYCLE);
  system1.SetNumberPreSmoothingStep(1);
  system1.SetNumberPostSmoothingStep(1);
      
  //Set Smoother Options
  if(Gmres) 		system1.SetMgSmoother(GMRES_SMOOTHER);
  else if(Asm) 		system1.SetMgSmoother(ASM_SMOOTHER);
  else if(Vanka)	system1.SetMgSmoother(VANKA_SMOOTHER);
  
  system1.init();
  //common smoother options
//   system1.AddStabilization(true);
  system1.SetSolverFineGrids(GMRES);
  system1.SetPreconditionerFineGrids(ILU_PRECOND); 
  system1.SetTolerances(1.e-12,1.e-20,1.e+50,4);
 
  system1.ClearVariablesToBeSolved();
  //system1.AddVariableToBeSolved("All");
  system1.AddVariableToBeSolved("U");
  system1.AddVariableToBeSolved("V");
  system1.AddVariableToBeSolved("P");
  //for Vanka and ASM smoothers
  system1.SetNumberOfSchurVariables(0);
  system1.SetElementBlockNumber(4);   
  //system1.SetElementBlockNumber("All",1);     
  //for Gmres smoother
  system1.SetDirichletBCsHandling(PENALTY); 
  //system1.SetDirichletBCsHandling(ELIMINATION); 
   
  // Solve Navier-Stokes system
  ml_prob.get_system("Navier-Stokes").solve();
  //END Navier-Stokes Multilevel Problem
  
  
  //BEGIN Temperature MultiLevel Problem
  std::cout << std::endl;
  std::cout << " *********** Temperature ************* " << std::endl;
    
  LinearImplicitSystem & system2 = ml_prob.add_system<LinearImplicitSystem> ("Temperature");
  system2.AddSolutionToSystemPDE("T");
  
  
  // Set MG Options
  system2.SetAssembleFunction(AssembleMatrixResT);
  system2.SetMaxNumberOfLinearIterations(6);
  system2.SetLinearConvergenceTolerance(1.e-9);  
  system2.SetMgType(V_CYCLE);
  system2.SetNumberPreSmoothingStep(1);
  system2.SetNumberPostSmoothingStep(1);
   
  //Set Smoother Options
  if(Gmres) 		system2.SetMgSmoother(GMRES_SMOOTHER);
  else if(Asm) 		system2.SetMgSmoother(ASM_SMOOTHER);
  else if(Vanka)	system2.SetMgSmoother(VANKA_SMOOTHER);
  
  system2.init(); 
  //common smoother option
  system2.SetSolverFineGrids(GMRES); 
  system2.SetTolerances(1.e-12,1.e-20,1.e+50,4);
  system2.SetPreconditionerFineGrids(ILU_PRECOND);
  //for Vanka and ASM smoothers
  system2.ClearVariablesToBeSolved();
  system2.AddVariableToBeSolved("All");
  system2.SetNumberOfSchurVariables(0);
  system2.SetElementBlockNumber(4);                
  //for Gmres smoother
  system2.SetDirichletBCsHandling(PENALTY); 
  //system2.SetDirichletBCsHandling(ELIMINATION); 
  
  
  // Solve Temperature system
  ml_prob.get_system("Temperature").solve();
  //END Temperature Multilevel Problem
    
  /// Print all solutions
  std::vector<std::string> print_vars;
  print_vars.push_back("U");
  print_vars.push_back("V");
  print_vars.push_back("P");
  print_vars.push_back("T");
       
  VTKWriter vtkio(&ml_sol);
  vtkio.write(files.GetOutputPath(),"biquadratic",print_vars);
  //vtkio.write(DEFAULT_OUTPUTDIR,"biquadratic",print_vars);
  
  GMVWriter gmvio(&ml_sol);
  gmvio.write(DEFAULT_OUTPUTDIR,"biquadratic",print_vars);
  // gmvio.write(files.GetOutputPath(),"biquadratic",print_vars);
    
  //   XDMFWriter xdmfio(ml_sol);
  //   xdmfio.write(files.GetOutputPath(),"biquadratic",print_vars);
   
  //Destroy all the new systems
  ml_prob.clear();
  
  delete [] infile;
  return 0;
}
开发者ID:rushs777,项目名称:femus,代码行数:101,代码来源:main.cpp

示例3: main

int main(int argc, char** args) {

    // ======= Init ========================
  // init Petsc-MPI communicator
  FemusInit mpinit(argc, args, MPI_COMM_WORLD);
  
    // ======= Files ========================
  Files files; 
        files.CheckIODirectories();
        files.RedirectCout();

    // ======= Quad Rule ========================
  std::string fe_quad_rule("seventh");
 /* "seventh" is the order of accuracy that is used in the gauss integration scheme
    In the future it is not going to be an argument of the mesh function   */
  
    // ======= Mesh ========================
  MultiLevelMesh ml_mesh;
  ml_mesh.GenerateCoarseBoxMesh(NSUB_X,NSUB_Y,0,0.,1.,0.,1.,0.,0.,QUAD9,fe_quad_rule.c_str());
  unsigned numberOfUniformLevels = 1;
  unsigned numberOfSelectiveLevels = 0;
  ml_mesh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL);
  ml_mesh.PrintInfo();

    // ======= Solution ========================
  MultiLevelSolution ml_sol(&ml_mesh);  // define the multilevel solution and attach the ml_mesh object to it

  // add variables to ml_sol
  ml_sol.AddSolution("state",   LAGRANGE, FIRST);
  ml_sol.AddSolution("control", LAGRANGE, FIRST);
  ml_sol.AddSolution("adjoint", LAGRANGE, FIRST);
  ml_sol.AddSolution("mu",      LAGRANGE, FIRST);  
  ml_sol.AddSolution("TargReg", DISCONTINUOUS_POLYNOMIAL, ZERO); //this variable is not solution of any eqn, it's just a given field
  ml_sol.AddSolution("ContReg", DISCONTINUOUS_POLYNOMIAL, ZERO); //this variable is not solution of any eqn, it's just a given field

  const unsigned int fake_time_dep_flag = 2;  //this is needed to be able to use _SolOld
  const std::string act_set_flag_name = "act_flag";
  ml_sol.AddSolution(act_set_flag_name.c_str(), LAGRANGE, FIRST,fake_time_dep_flag);               

    // ======= Problem ========================
  MultiLevelProblem ml_prob(&ml_sol);  // define the multilevel problem attach the ml_sol object to it

  ml_prob.SetQuadratureRuleAllGeomElems(fe_quad_rule);
  ml_prob.SetFilesHandler(&files);
  
    // ======= Initial values ========================
  ml_sol.Initialize("All");    // initialize all variables to zero

//   ml_sol.Initialize("All", SetInitialCondition, &ml_prob); //unfortunately if I do this it sets all to zero //I would like to do an attach function similar to the BC
  ml_sol.Initialize("state",   SetInitialCondition, &ml_prob);
  ml_sol.Initialize("control", SetInitialCondition, &ml_prob);
  ml_sol.Initialize("adjoint", SetInitialCondition, &ml_prob);
  ml_sol.Initialize("mu",      SetInitialCondition, &ml_prob);
  ml_sol.Initialize("TargReg", SetInitialCondition, &ml_prob);
  ml_sol.Initialize("ContReg", SetInitialCondition, &ml_prob);
  ml_sol.Initialize(act_set_flag_name.c_str(),  SetInitialCondition, &ml_prob);

    // ======= Boundary Conditions ========================
  ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryCondition);  // attach the boundary condition function and generate boundary data

//   ml_sol.GenerateBdc("All");  //this would do it also for the non-equation-related variables
  ml_sol.GenerateBdc("state");
  ml_sol.GenerateBdc("control");
  ml_sol.GenerateBdc("adjoint");
  ml_sol.GenerateBdc("mu");  //we need this for all Pde variables to make the matrix iterations work... but this should be related to the matrix and not to the sol... The same for the initial condition

    // ======= System ========================
  NonLinearImplicitSystemWithPrimalDualActiveSetMethod& system = ml_prob.add_system < NonLinearImplicitSystemWithPrimalDualActiveSetMethod > ("OptSys");

  system.SetActiveSetFlagName(act_set_flag_name);

  //here we decide the order in the matrix!
  const std::vector < std::string > sol_matrix_pos = {"state","control","adjoint","mu"};
  for (unsigned k = 0; k < sol_matrix_pos.size(); k++)  system.AddSolutionToSystemPDE(sol_matrix_pos[k].c_str());  
  
  // attach the assembling function to system
  system.SetAssembleFunction(AssembleProblem);
  
  ml_sol.SetWriter(VTK);   //need to move this here for the DebugNonlinear function
  ml_sol.GetWriter()->SetDebugOutput(true);
  
  system.SetDebugNonlinear(true);
  system.SetDebugFunction(ComputeIntegral);
  //   system.SetMaxNumberOfNonLinearIterations(2);

    // ======= Solve ========================
  system.init();    // initialize and solve the system
  system.MGsolve();
  
//   ComputeIntegral(ml_prob);
 
    // ======= Final Print ========================
  std::vector < std::string > variablesToBePrinted;
  variablesToBePrinted.push_back("all");
  ml_sol.GetWriter()->Write(files.GetOutputPath()/*DEFAULT_OUTPUTDIR*/, "biquadratic", variablesToBePrinted);    // print solutions


  return 0;
}
开发者ID:FeMTTU,项目名称:femus,代码行数:99,代码来源:elliptic_nonlin.cpp

示例4: main


//.........这里部分代码省略.........
  ml_sol.GenerateBdc("U","Time_dependent");
  ml_sol.GenerateBdc("V","Steady");
  ml_sol.GenerateBdc("AX","Steady");
  ml_sol.GenerateBdc("AY","Steady");
  ml_sol.GenerateBdc("P","Steady");

  
  MultiLevelProblem ml_prob(&ml_sol);
  

  Parameter par(Lref,Uref);
  
  // Generate Solid Object
  Solid solid(par,E,ni,rhos,"Neo-Hookean");
  cout << "Solid properties: " << endl;
  cout << solid << endl;
  
  // Generate Fluid Object
  Fluid fluid(par,muf,rhof,"Newtonian");
  cout << "Fluid properties: " << endl;
  cout << fluid << endl;

  // Add fluid object
  ml_prob.parameters.set<Fluid>("Fluid") = fluid;
  
  // Add Solid Object
  ml_prob.parameters.set<Solid>("Solid") = solid;

  ml_msh.MarkStructureNode();
   
  //create systems
  // add the system FSI to the MultiLevel problem
  TransientMonolithicFSINonlinearImplicitSystem & system = ml_prob.add_system<TransientMonolithicFSINonlinearImplicitSystem> ("Fluid-Structure-Interaction");
  system.AddSolutionToSystemPDE("DX");
  system.AddSolutionToSystemPDE("DY");
  system.AddSolutionToSystemPDE("U");
  system.AddSolutionToSystemPDE("V");
  system.AddSolutionToSystemPDE("P");
  
  // init all the systems
  system.init();
   
  // System Fluid-Structure-Interaction
  system.SetAssembleFunction(AssembleMatrixResFSI);  
  system.SetMaxNumberOfLinearIterations(1);
  system.SetLinearConvergenceTolerance(1.e-8);  
  system.SetMgType(V_CYCLE);
  system.SetMaxNumberOfNonLinearIterations(4);
  system.SetNonLinearConvergenceTolerance(1.e-5);
  system.SetDirichletBCsHandling(PENALTY);
  
  //system.SetDirichletBCsHandling(ELIMINATION);
  
  // time loop parameter
  system.AttachGetTimeIntervalFunction(SetVariableTimeStep);
  const unsigned int n_timesteps = 5;
  const unsigned int write_interval = 1;
  
  std::vector<std::string> mov_vars;
  mov_vars.push_back("DX");
  mov_vars.push_back("DY");
  VTKWriter vtkio(&ml_sol);
  vtkio.SetMovingMesh(mov_vars);
  
  for (unsigned time_step = 0; time_step < n_timesteps; time_step++) {
   
    // Solving Fluid-Structure-Interaction system
    std::cout << std::endl;
    std::cout << " *********** Fluid-Structure-Interaction ************  " << std::endl;
    system.solve();
   
    //The update of the acceleration must be done before the update of the other variables
    system.NewmarkAccUpdate();
    
    //update Solution
    system.UpdateSolution();

    // print solution
    if ( !(time_step%write_interval) ) {
        
      //print solution 
      std::vector<std::string> print_vars;
      print_vars.push_back("DX");
      print_vars.push_back("DY");
      print_vars.push_back("U");
      print_vars.push_back("V");
      print_vars.push_back("P");
      
//       ml_prob.printsol_vtu_inline("biquadratic",print_vars,time_step);
      vtkio.write(files.GetOutputPath(),"biquadratic",print_vars,time_step);
    }
  
  } //end loop timestep
  

  // Destroy all the new systems
  ml_prob.clear();
   
  return 0;
}
开发者ID:rushs777,项目名称:femus,代码行数:101,代码来源:main.cpp

示例5: main

 int main(int argc, char** argv) {

#ifdef HAVE_LIBMESH
   libMesh::LibMeshInit init(argc,argv);
#else   
   FemusInit init(argc,argv);
#endif
   
 // ======= Files ========================
  Files files; 
        files.ConfigureRestart();
        files.CheckIODirectories();
        files.CopyInputFiles();
        files.RedirectCout();

  // ======= Physics Input Parser ========================
  FemusInputParser<double> physics_map("Physics",files.GetOutputPath());

  const double rhof   = physics_map.get("rho0");
  const double Uref   = physics_map.get("Uref");
  const double Lref   = physics_map.get("Lref");
  const double  muf   = physics_map.get("mu0");

  const double  _pref = rhof*Uref*Uref;           physics_map.set("pref",_pref);
  const double   _Re  = (rhof*Uref*Lref)/muf;     physics_map.set("Re",_Re);
  const double   _Fr  = (Uref*Uref)/(9.81*Lref);  physics_map.set("Fr",_Fr);
  const double   _Pr  = muf/rhof;                 physics_map.set("Pr",_Pr);

  // ======= Mesh =====
  const unsigned NoLevels = 3;
  const unsigned dim = 2;
  const GeomElType geomel_type = QUAD;
  GenCase mesh(NoLevels,dim,geomel_type,"inclQ2D2x2.gam");
          mesh.SetLref(1.);  
	  
  // ======= MyDomainShape  (optional, implemented as child of Domain) ====================
  FemusInputParser<double> box_map("Box",files.GetOutputPath());
  Box mybox(mesh.get_dim(),box_map);
      mybox.InitAndNondimensionalize(mesh.get_Lref());

          mesh.SetDomain(&mybox);    
	  
          mesh.GenerateCase(files.GetOutputPath());

          mesh.SetLref(Lref);
      mybox.InitAndNondimensionalize(mesh.get_Lref());
	  
          XDMFWriter::ReadMeshAndNondimensionalizeBiquadraticHDF5(files.GetOutputPath(),mesh); 
	  XDMFWriter::PrintMeshXDMF(files.GetOutputPath(),mesh,BIQUADR_FE);
          XDMFWriter::PrintMeshLinear(files.GetOutputPath(),mesh);
	  
  //gencase is dimensionalized, meshtwo is nondimensionalized
  //since the meshtwo is nondimensionalized, all the BC and IC are gonna be implemented on a nondimensionalized mesh
  //now, a mesh may or may not have an associated domain
  //moreover, a mesh may or may not be read from file
  //the generation is dimensional, the nondimensionalization occurs later
  //Both the Mesh and the optional domain must be nondimensionalized
  //first, we have to say if the mesh has a shape or not
  //that depends on the application, it must be put at the main level
  //then, after you know the shape, you may or may not generate the mesh with that shape 
  //the two things are totally independent, and related to the application, not to the library

  // ===== QuantityMap : this is like the MultilevelSolution =========================================
  QuantityMap  qty_map;
  qty_map.SetMeshTwo(&mesh);
  qty_map.SetInputParser(&physics_map);

  Pressure       pressure("Qty_Pressure",qty_map,1,LL);             qty_map.AddQuantity(&pressure);
  VelocityX     velocityX("Qty_Velocity0",qty_map,1,QQ);            qty_map.AddQuantity(&velocityX);
  VelocityY     velocityY("Qty_Velocity1",qty_map,1,QQ);            qty_map.AddQuantity(&velocityY);
  Temperature temperature("Qty_Temperature",qty_map,1,QQ);          qty_map.AddQuantity(&temperature);
  TempLift       templift("Qty_TempLift",qty_map,1,QQ);             qty_map.AddQuantity(&templift);  
  TempAdj         tempadj("Qty_TempAdj",qty_map,1,QQ);              qty_map.AddQuantity(&tempadj);  
  // ===== end QuantityMap =========================================
  
  // ====== Start new main =================================
  
  MultiLevelMesh ml_msh;
  ml_msh.GenerateCoarseBoxMesh(8,8,0,0,1,0,2,0,0,QUAD9,"fifth"); //   ml_msh.GenerateCoarseBoxMesh(numelemx,numelemy,numelemz,xa,xb,ya,yb,za,zb,elemtype,"fifth");
  ml_msh.RefineMesh(NoLevels,NoLevels,NULL);
  ml_msh.PrintInfo();
  
  ml_msh.SetWriter(XDMF);
  //ml_msh.GetWriter()->write(files.GetOutputPath(),"biquadratic");
  
  ml_msh.SetDomain(&mybox);    
	  
  MultiLevelSolution ml_sol(&ml_msh);
  ml_sol.AddSolution("Qty_Temperature",LAGRANGE,SECOND,0);
  ml_sol.AddSolution("Qty_TempLift",LAGRANGE,SECOND,0);
  ml_sol.AddSolution("Qty_TempAdj",LAGRANGE,SECOND,0);
  ml_sol.AddSolutionVector(ml_msh.GetDimension(),"Qty_Velocity",LAGRANGE,SECOND,0);
  ml_sol.AddSolution("Qty_Pressure",LAGRANGE,FIRST,0);
  ml_sol.AddSolution("Qty_TempDes",LAGRANGE,SECOND,0,false); //this is not going to be an Unknown! //moreover, this is not going to need any BC (i think they are excluded with "false") // I would like to have a Solution that is NOT EVEN related to the mesh at all... just like a function "on-the-fly"

  // ******* Set problem *******
  MultiLevelProblem ml_prob(&ml_sol);
  ml_prob.SetMeshTwo(&mesh);
  ml_prob.SetQruleAndElemType("fifth");
  ml_prob.SetInputParser(&physics_map);
//.........这里部分代码省略.........
开发者ID:CasaNostra,项目名称:femus,代码行数:101,代码来源:main.cpp

示例6: main


//.........这里部分代码省略.........
  system.SetPreconditionerFineGrids(MLU_PRECOND);
  
//   system.SetMaxNumberOfLinearIterations(1);
//   system.SetAbsoluteLinearConvergenceTolerance(1.e-8);
//   system.SetMgType(V_CYCLE);
  system.SetMaxNumberOfNonLinearIterations(30);
  system.SetNonLinearConvergenceTolerance(1.e-8);

  //**************
  ml_sol.SetWriter(VTK);   //need to move this here for the DebugNonlinear function
  ml_sol.GetWriter()->SetDebugOutput(true);
//   system.SetDebugNonlinear(true);
  //**************
  
  const unsigned fine_lev = ml_sol._mlMesh->GetNumberOfLevels() - 1;
  
  const double total_time = 1.;  
  
  std::vector< unsigned int > n_steps =  {2000/*6*//*2, *//*4, 8, 16*/};
 
//   std::vector< MultiLevelSolution >  last_sol(n_steps.size(),  & ml_msh);  
//   std::vector< Solution >  last_sol(n_steps.size(),  ml_msh.GetLevel(fine_lev) );  
  std::vector< NumericVector* >  last_sol(n_steps.size());
  
  
  for (unsigned i = 0; i < n_steps.size(); i++) {
      
  const double interval_time = total_time/n_steps[i];
  
  system.SetIntervalTime(interval_time);
  
  const unsigned int write_interval = 1.; //n_steps[i];

  const bool detect_quench = false; // Set to 0 for no adaptation and 1 for adaptation (which starts at a specified solution magnitude)
     
     
  for (unsigned time_step = 0; time_step < n_steps[i]; time_step++) {
      
  // ======= Check for quenching ==========
    if ( detect_quench == true ) {
      if ( (ml_sol.GetSolutionLevel( fine_lev ) )->GetSolutionName( unknown.c_str() ).linfty_norm() >= 0.99 ) { std::cout << "Detected quenching" << std::endl; exit(0); }
    }
      
  // ======= Print ========================
    if ( !(time_step % write_interval) ) {

        std::vector < std::string > variablesToBePrinted;
        variablesToBePrinted.push_back("all");
        std::string run_prefix = "n_steps_" + std::to_string(n_steps[i]);
        ml_sol.GetWriter()->Write(run_prefix, files.GetOutputPath(), "biquadratic", variablesToBePrinted, time_step);    // print solutions

    }
    
    // ======= Solve ========================
    std::cout << std::endl;
    std::cout << " *********** Timedep ************ " << std::endl;

    system.SetOuterSolver(PREONLY);
    system.MGsolve();
    
    
      ml_sol.Set("time", SetInitialCondition, &ml_prob);
      
//       system.compute_convergence_rate();
      
    // ======= Update Solution ===============
    system.CopySolutionToOldSolution();
    
     
     bool adapt_flag = 0; // Set to 0 for no adaptation and 1 for adaptation (which starts at a specified solution magnitude)
     
      if ( adapt_flag == 1 ) {
      
        double AdaptStarter = 0.85; // Value of ||u||_\infty at which to start adaptation
        if ( (ml_sol.GetSolutionLevel( fine_lev ) )->GetSolutionName( unknown.c_str() ).linfty_norm() >= AdaptStarter ) {
     
            double NonlinearityTracker = 0.1 * Singularity::derivative( (ml_sol.GetSolutionLevel( fine_lev ) )->GetSolutionName( unknown.c_str() ).linfty_norm() ) ;
            double NewTime = std::min( system.GetIntervalTime(), NonlinearityTracker );
            double minTimeStep = 0.001; // Minimum step-size controller
            double NewTimeFixed = std::max( NewTime , minTimeStep );
            system.SetIntervalTime(NewTimeFixed);
          }    
     
        }
       

     } //end loop timestep
     
     //here is where we store the ends of the simulations
//      last_sol[i] =  ml_sol;
//      last_sol[i] = *( ml_sol.GetSolutionLevel( fine_lev ) )/*->GetSolutionName( unknown.c_str() )*/;
     last_sol[i] =  &( ml_sol.GetSolutionLevel( fine_lev ) )->GetSolutionName( unknown.c_str() );
  
  }

//   last_sol[0]->add(-1., *(last_sol[1]));    const double numerator   = last_sol[0]->linfty_norm();
//   last_sol[2]->add(-1., *(last_sol[1]));   const double denominator = last_sol[2]->linfty_norm();

  return 0;
}
开发者ID:FeMTTU,项目名称:femus,代码行数:101,代码来源:ex_time.cpp


注:本文中的Files::GetOutputPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。