/*
  phasefield_mpi.h
  by Wei Cai  caiwei@stanford.edu
  Last Modified : Fri Sep  12  2014

  FUNCTION  :  Easy-to-use Phase Field simulation Framefork

*/


#ifndef _PHASEFIELDMPI_H
#define _PHASEFIELDMPI_H

#include "phasefield.h"

#ifndef _PARALLEL
class PhaseFieldMPIFrame : public PhaseFieldFrame { };
#else
#include "mpi.h"

#include "mpi_array_distrib.h"

/* MD simulation framework */
class PhaseFieldMPIFrame : public PhaseFieldFrame
{
public:

    class Distributor3D *d;

    /* Constructor (set initial values of member variables) */
    PhaseFieldMPIFrame(): d(NULL)
    {
        PhaseFieldFrame::PhaseFieldFrame();
    }

    //virtual void call_potential() { potential_parallel(); }
    virtual void FreeEnergy() { PhaseFieldFrame::FreeEnergy(); }
    
    virtual void initvars();
    virtual void initparser();
    virtual int exec(const char *name);
    virtual void Alloc();
    
    void ParallelInit(int *pargc, char ***pargv);
    void WaitForCommand();
    void Master_to_Slave(char *cmd);
    void Slave_to_Master_Atoms();
    void Slave_chdir();
    
    void alloc_all();
    void quit_all();

};    
#endif //_PARALLEL

#endif //_PHASEFIELDMPI_H
