Skip to content
Snippets Groups Projects
iPic3D.cpp 1.22 KiB
Newer Older
  • Learn to ignore specific revisions
  • #include "iPic3D.h"
    
    using namespace iPic3D;
    
    int main(int argc, char **argv) {
    
      iPic3D::c_Solver KCode;
      bool b_err = false;
    
    
      /* ------------------------------ */
      /* 0- Initialize the solver class */
      /* ------------------------------ */
    
    
      KCode.Init(argc, argv);
    
      KCode.InjectBoundaryParticles();
    
    Jorge Amaya's avatar
    Jorge Amaya committed
      KCode.GatherMoments();
    
      /* ------------ */
      /* 1- Main loop */
      /* ------------ */
    
    
      for (int i = KCode.FirstCycle(); i <= KCode.LastCycle(); i++) {
    
    
        if (KCode.get_myrank() == 0) cout << " ======= Cycle " << i << " ======= " << endl;
    
    
        /* ----------------------------------------------------- */
        /* 2- Calculate fields and move particles                */
        /*    Exit if there is a memory issue with the particles */
        /* ----------------------------------------------------- */
    
    
    Jorge Amaya's avatar
    Jorge Amaya committed
        KCode.UpdateCycleInfo(i);
    
    Jorge Amaya's avatar
    Jorge Amaya committed
        KCode.CalculateField();
    
        b_err = KCode.ParticlesMover();
    
        if (!b_err) KCode.CalculateBField();
        if (!b_err) KCode.GatherMoments();
    
        if ( b_err) i = KCode.LastCycle() + 1;
    
        /* --------------- */
        /* 3- Output files */
        /* --------------- */
    
    
        KCode.WriteConserved(i);
        KCode.WriteRestart(i);
    
      }
    
      KCode.Finalize();
    
      return 0;
    }