Example #1
0
        public FixEmit(SPARTA sparta, int narg, string[] arg) : base(sparta, narg, arg)
        {
            this.sparta = sparta;
            vector_flag = 1;
            size_vector = 2;
            global_freq = 1;
            gridmigrate = 1;

            // RNG

            int me = sparta.comm.me;

            random = new RanPark(sparta.update.ranmaster.uniform());
            double seed = sparta.update.ranmaster.uniform();

            random.reset(seed, me, 100);

            // local storage of emit data structures

            c2list  = null;
            nglocal = nglocalmax = 0;
            clist   = clistnum = clistfirst = null;
            nlist   = nlistmax = 0;

            // counters common to all emit styles for output from fix

            nsingle = ntotal = 0;
        }
Example #2
0
 public WriteRestart(SPARTA sparta)
 {
     this.sparta = sparta;
     sparta.mpi.MPI_Comm_rank(sparta.world, ref me);
     sparta.mpi.MPI_Comm_size(sparta.world, ref nprocs);
     multiproc = 0;
 }
Example #3
0
        public int size_vector;          // length of global vector

        public SurfCollide(SPARTA sparta, int narg, string[] arg)
        {
            // ID and style
            // ID must be all alphanumeric chars or underscores

            int n = arg[0].Length + 1;

            id = string.Copy(arg[0]);

            for (int i = 0; i < n - 1; i++)
            {
                if (!char.IsLetterOrDigit(id[i]) && id[i] != '_')
                {
                    sparta.error.all("Surf_collide ID must be alphanumeric or underscore characters");
                }
            }

            n     = arg[1].Length + 1;
            style = string.Copy(arg[1]);

            vector_flag = 1;
            size_vector = 2;

            nsingle = ntotal = 0;

            copy = 0;
        }
Example #4
0
        public RCB(SPARTA sparta)
        {
            this.sparta = sparta;
            sparta.mpi.MPI_Comm_rank(sparta.world, ref me);
            sparta.mpi.MPI_Comm_size(sparta.world, ref nprocs);

            ndot = maxdot = 0;
            dots = null;

            nlist   = maxlist = 0;
            dotlist = dotmark = null;

            maxbuf = 0;
            buf    = null;

            maxrecv  = maxsend = 0;
            recvproc = recvindex = sendproc = sendindex = null;

            //tree = (Tree*)memory->smalloc(nprocs * sizeof(Tree), "RCB:tree");
            tree      = new Tree[nprocs];
            irregular = null;

            // create MPI data and function types for box and median AllReduce ops

            sparta.mpi.MPI_Type_contiguous(6, MPI.MPI_DOUBLE, ref box_type);
            sparta.mpi.MPI_Type_commit(ref box_type);
            sparta.mpi.MPI_Type_contiguous(Marshal.SizeOf(typeof(Median)), MPI.MPI_CHAR, ref med_type);
            sparta.mpi.MPI_Type_commit(ref med_type);

            sparta.mpi.MPI_Op_create(box_merge, 1, ref box_op);
            sparta.mpi.MPI_Op_create(median_merge, 1, ref med_op);

            reuse = 0;
        }
Example #5
0
        public Irregular(SPARTA sparta)
        {
            this.sparta = sparta;
            sparta.mpi.MPI_Comm_rank(sparta.world, ref me);
            sparta.mpi.MPI_Comm_size(sparta.world, ref nprocs);

            // allocate fixed-length and work vectors for plan
            proc_send = new int[nprocs];
            num_send  = new int[nprocs];
            proc_recv = new int[nprocs];
            num_recv  = new int[nprocs];
            proc2recv = new int[nprocs];



            request = new MPI_Request[nprocs];
            status  = new MPI._MPI_Status[nprocs];

            size_send = null;
            size_recv = null;

            work1 = new int[nprocs];
            work2 = new int[nprocs];

            indexmax     = 0;
            index_send   = null;
            indexselfmax = 0;
            index_self   = null;
            offsetmax    = 0;
            offset_send  = null;
            bufmax       = 0;
            buf          = null;

            copymode = 0;
        }
Example #6
0
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(str))
            {
                args = new string[] { "-in", "in.circle" };
            }
            else if (new FileInfo(str).Exists)
            {
                args = new string[] { "-in", str };
            }
            else
            {
                Console.WriteLine("File {0} doesn't exits", str);
                Console.ReadKey();
                Environment.Exit(1);
            }

            MPI mpi = new MPI();

            mpi.MPI_Init(args);

            SPARTA sparta = new SPARTA(args, mpi, MPI.MPI_COMM_WORLD);

            sparta.input.file();

            mpi.MPI_Finalize();
            Console.ReadKey();
        }
Example #7
0
        public Domain(SPARTA sparta)
        {
            this.sparta              = sparta;
            box_exist                = 0;
            dimension                = 3;
            axisymmetric             = 0;
            boundary_collision_check = 1;

            for (int i = 0; i < 6; i++)
            {
                bflag[i] = (int)Enum2.PERIODIC;
            }
            for (int i = 0; i < 6; i++)
            {
                surf_collide[i] = surf_react[i] = -1;
            }

            // surface normals of 6 box faces pointed inward towards particles

            norm[(int)Enum1.XLO, 0] = 1.0; norm[(int)Enum1.XLO, 1] = 0.0; norm[(int)Enum1.XLO, 2] = 0.0;
            norm[(int)Enum1.XHI, 0] = -1.0; norm[(int)Enum1.XHI, 1] = 0.0; norm[(int)Enum1.XHI, 2] = 0.0;
            norm[(int)Enum1.YLO, 0] = 0.0; norm[(int)Enum1.YLO, 1] = 1.0; norm[(int)Enum1.YLO, 2] = 0.0;
            norm[(int)Enum1.YHI, 0] = 0.0; norm[(int)Enum1.YHI, 1] = -1.0; norm[(int)Enum1.YHI, 2] = 0.0;
            norm[(int)Enum1.ZLO, 0] = 0.0; norm[(int)Enum1.ZLO, 1] = 0.0; norm[(int)Enum1.ZLO, 2] = 1.0;
            norm[(int)Enum1.ZHI, 0] = 0.0; norm[(int)Enum1.ZHI, 1] = 0.0; norm[(int)Enum1.ZHI, 2] = -1.0;

            nregion = maxregion = 0;
            regions = null;
            copy    = copymode = 0;
        }
Example #8
0
        public Comm(SPARTA sparta)
        {
            this.sparta = sparta;
            sparta.mpi.MPI_Comm_rank(sparta.world, ref me);
            sparta.mpi.MPI_Comm_size(sparta.world, ref nprocs);

            ncomm         = 0;
            commsortflag  = 0;
            commpartstyle = 1;

            neighflag = 0;
            neighlist = null;

            iparticle = new Irregular(sparta);
            igrid     = null;
            iuniform  = null;

            pproc      = null;
            maxpproc   = 0;
            gproc      = gsize = null;
            maxgproc   = 0;
            sbuf       = rbuf = null;
            maxsendbuf = maxrecvbuf = 0;

            copymode = 0;
        }
Example #9
0
        public Mixture(SPARTA sparta, string userid)
        {
            this.sparta = sparta;
            // mixture ID must be all alphanumeric chars or underscores
            int n = userid.Length + 1;

            id = string.Copy(userid);

            for (int i = 0; i < n - 1; i++)
            {
                if (!char.IsLetterOrDigit(id[i]) && id[i] != '_')
                {
                    sparta.error.all(
                        "Mixture ID must be alphanumeric or underscore characters");
                }
            }

            // special default mixtures

            all_default = species_default = 0;
            if (string.Equals(id, "all"))
            {
                all_default = 1;
            }
            if (string.Equals(id, "species"))
            {
                species_default = 1;
            }

            // initialize mixture values

            nspecies = maxspecies = 0;
            species  = null;

            nrho_flag         = 0;
            vstream_flag      = 0;
            temp_thermal_flag = 0;
            temp_rot_flag     = 0;
            temp_vib_flag     = 0;

            fraction      = null;
            fraction_user = null;
            fraction_flag = null;
            cummulative   = null;

            ngroup       = maxgroup = 0;
            groups       = null;
            groupsize    = null;
            groupspecies = null;

            mix2group       = null;
            species2group   = null;
            species2species = null;

            vscale = null;
            active = null;

            allocate();
        }
Example #10
0
        public Particle(SPARTA sparta)
        {
            this.sparta = sparta;
            sparta.mpi.MPI_Comm_rank(sparta.world, ref me);

            exist     = sorted = 0;
            nglobal   = 0;
            nlocal    = maxlocal = 0;
            particles = null;

            nspecies = maxspecies = 0;
            species  = null;

            //maxgrid = 0;
            //cellcount = null;
            //first = null;
            maxsort = 0;
            next    = null;

            // create two default mixtures

            nmixture = maxmixture = 0;
            mixture  = null;

            string[] newarg = new string[1];
            newarg[0] = "all";
            add_mixture(1, newarg);
            newarg[0] = "species";
            add_mixture(1, newarg);
            //delete[] newarg;

            // custom per-particle vectors/arrays

            ncustom = 0;
            ename   = null;
            etype   = esize = ewhich = null;

            ncustom_ivec = ncustom_iarray = 0;
            icustom_ivec = icustom_iarray = null;
            eivec        = null;
            eiarray      = null;
            eicol        = null;

            ncustom_dvec = ncustom_darray = 0;
            icustom_dvec = icustom_darray = null;
            edvec        = null;
            edarray      = null;
            edcol        = null;

            custom_restart_flag = null;

            // RNG for particle weighting

            wrandom = null;

            copy = copymode = 0;
        }
Example #11
0
        public Cut3d(SPARTA sparta)
        {
            this.sparta = sparta;
            cut2d       = new Cut2d(sparta, 0);
            for (int i = 0; i <= cut2d.npushmax; i++)
            {
                cut2d.npushcell[i] = 0;
            }
            path1 = new double[12, 3];
            path2 = new double[12, 3];
            //memory->create(path1, 12, 3, "cut3d:path1");
            //memory->create(path2, 12, 3, "cut3d:path2");

            npushmax = 2;    // if increase this, increase push vec size in cut3d.h

            pushlo_vec[0]    = -1.0;
            pushhi_vec[0]    = 1.0;
            pushvalue_vec[0] = 0.0;
            pushlo_vec[1]    = -1.0;
            pushhi_vec[1]    = 1.0;
            pushvalue_vec[1] = 1.0;

            /*
             * pushlo_vec[0] = -1.0;
             * pushhi_vec[0] = 1.0;
             * pushvalue_vec[0] = 1.0;
             * pushlo_vec[1] = -1.0;
             * pushhi_vec[1] = 1.0;
             * pushvalue_vec[1] = 0.0;
             */

            if (sparta.surf.pushflag == 0)
            {
                npushmax = 0;
            }
            if (sparta.surf.pushflag == 2)
            {
                npushmax = 3;
            }
            if (sparta.surf.pushflag == 2)
            {
                pushlo_vec[2]    = sparta.surf.pushlo;
                pushhi_vec[2]    = sparta.surf.pushhi;
                pushvalue_vec[2] = sparta.surf.pushvalue;
            }

            for (int i = 0; i <= npushmax; i++)
            {
                npushcell[i] = 0;
            }

            // DEBUG
            //totcell = totsurf = totvert = totedge = 0;
        }
Example #12
0
        public string one(string single)       // process a single command
        {
            int n = single.Length + 1;

            if (n > maxline)
            {
                reallocate(ref line, ref maxline, n);
            }
            line = string.Copy(single);

            // echo the command unless scanning for label

            if (me == 0 && label_active == 0)
            {
                if (echo_screen != 0 && sparta.screen != null)
                {
                    SPARTA.fprintf(sparta.screen, "{0}\n", line);
                }

                if (echo_log != 0 && sparta.logfile != null)
                {
                    SPARTA.fprintf(sparta.logfile, "{0}\n", line);
                }
            }

            // parse the line
            // if no command, just return null

            parse();
            if (command == null)
            {
                return(null);
            }

            // if scanning for label, skip command unless it's a label command

            if (label_active != 0 && string.Compare(command, "label") != 0)
            {
                return(null);
            }

            // execute the command and return its name

            if (execute_command())
            {
                string str = string.Format("Unknown command: {0}", line);
                //char* str = new char[maxline + 32];
                //sprintf(str, "Unknown command: %s", line);
                sparta.error.all(str);
            }

            return(command);
        }
Example #13
0
        public Stats(SPARTA sparta)
        {
            this.sparta = sparta;
            sparta.mpi.MPI_Comm_rank(sparta.world, ref me);

            sparta.mpi.MPI_Barrier(sparta.world);
            wall0 = sparta.mpi.MPI_Wtime();

            //line = new char[MAXLINE];

            keyword = null;
            //vfunc = null;
            vtype = null;

            field2index = null;
            argindex1   = null;
            argindex2   = null;

            // default args

            //string[] arg = new string[3];
            //arg[0] = (string)"step";
            //arg[1] = (string)"cpu";
            //arg[2] = (string)"np";
            string[] arg = new string[] { "step", "cpu", "np" };

            nfield = 3;
            Allocate();
            //set_fields(3, arg);

            //delete[] arg;

            // stats_modify defaults

            flushflag = 0;

            // format strings

            string bigint_format = "%lld";

            format_float_def  = "%12.8g";
            format_int_def    = "%8d";
            format_bigint_def = string.Format("%%8%s", bigint_format);

            format_line_user   = null;
            format_float_user  = null;
            format_int_user    = null;
            format_bigint_user = null;
        }
Example #14
0
        public React(SPARTA sparta)
        {
            this.sparta = sparta;
            //int n = strlen(arg[0]) + 1;
            //style = new char[n];
            //strcpy(style, arg[0]);

            //recombflag_user = 1;
            //recomb_boost = 1000.0;
            //recomb_boost_inverse = 0.0001;

            //random = new RanPark(update->ranmaster->uniform());
            //double seed = update->ranmaster->uniform();
            //random->reset(seed, comm->me, 100);
        }
Example #15
0
        public Collide(SPARTA sparta, int narg, string[] arg)
        {
            this.sparta = sparta;
            int n = arg[0].Length + 1;

            style = string.Copy(arg[0]);

            n     = arg[1].Length + 1;
            mixID = string.Copy(arg[1]);

            random = new RanPark(sparta.update.ranmaster.uniform());
            double seed = sparta.update.ranmaster.uniform();

            random.reset(seed, sparta.comm.me, 100);

            ngroups = 0;

            npmax = 0;
            plist = null;

            nglocal = nglocalmax = 0;

            ngroup   = null;
            maxgroup = null;
            glist    = null;
            gpair    = null;

            maxdelete = 0;
            dellist   = null;

            vre_first      = 1;
            vre_start      = 1;
            vre_every      = 0;
            remainflag     = 1;
            vremax         = null;
            vremax_initial = null;
            remain         = null;
            rotstyle       = (int)Enum1.SMOOTH;
            vibstyle       = (int)Enum1.NONE;
            nearcp         = 0;
            nearlimit      = 10;

            recomb_ijflag = null;

            ambiflag    = 0;
            maxelectron = 0;
            elist       = null;
        }
Example #16
0
            public VarReader(SPARTA sparta,string str,string file,int flag)
            {
                this.sparta = sparta;
                me = sparta.comm.me;
                style = flag;

                if (me == 0)
                {
                    fp = new FileStream( file, FileMode.Open,FileAccess.Read);
                    if (fp == null)
                    {
                        string strstr=string.Format( "Cannot open file variable file {0}", file);
                        sparta.error.one(strstr);
                    }
                }
                else fp = null;
            }
Example #17
0
        public bigint invoked_per_surf;      // ditto for compute_per_surf()

        public Compute(SPARTA sparta, int narg, string[] arg)
        {
            if (narg < 2)
            {
                sparta.error.all("Illegal compute command");
            }

            // compute ID and style
            // ID must be all alphanumeric chars or underscores

            int n = arg[0].Length + 1;

            id = string.Copy(arg[0]);

            for (int i = 0; i < n - 1; i++)
            {
                if (char.IsLetterOrDigit(id[i]) && id[i] != '_')
                {
                    sparta.error.all("Compute ID must be alphanumeric or underscore characters");
                }
            }

            //n = strlen(arg[1]) + 1;
            style = string.Copy(arg[1]);

            // set child class defaults

            scalar_flag              = vector_flag = array_flag = 0;
            per_particle_flag        = per_grid_flag = per_surf_flag = 0;
            post_process_grid_flag   = 0;
            size_per_grid_extra_cols = 0;
            surf_tally_flag          = boundary_tally_flag = 0;

            timeflag = 0;
            ntime    = maxtime = 0;
            tlist    = null;

            invoked_scalar       = invoked_vector = invoked_array = -1;
            invoked_per_particle = invoked_per_grid = invoked_per_surf = -1;

            kokkos_flag = 0;
            copymode    = 0;
        }
Example #18
0
        public Fix(SPARTA sparta, int narg, string[] arg)
        {
            this.sparta = sparta;
            // fix ID and style
            // ID must be all alphanumeric chars or underscores

            int n = arg[0].Length + 1;

            id = string.Copy(arg[0]);

            for (int i = 0; i < n - 1; i++)
            {
                if (!char.IsLetterOrDigit(id[i]) && id[i] != '_')
                {
                    sparta.error.all("Fix ID must be alphanumeric or underscore characters");
                }
            }

            n     = arg[1].Length + 1;
            style = string.Copy(arg[1]);

            // set child class defaults

            time_depend       = 0;
            gridmigrate       = 0;
            flag_add_particle = flag_gas_react = flag_surf_react = 0;

            scalar_flag       = vector_flag = array_flag = 0;
            per_particle_flag = per_grid_flag = per_surf_flag = 0;

            // mask settings - same as in modify.cpp

            START_OF_STEP = 1;
            END_OF_STEP   = 2;

            kokkosable = 0;
            copymode   = 0;

            execution_space = (int)ExecutionSpace.Host;
            datamask_read   = SpartaMasks.ALL_MASK;
            datamask_modify = SpartaMasks.ALL_MASK;
        }
Example #19
0
        public Modify(SPARTA sparta)
        {
            this.sparta     = sparta;
            nfix            = maxfix = 0;
            n_start_of_step = n_end_of_step = 0;

            fix   = null;
            fmask = null;
            list_start_of_step = list_end_of_step = null;

            end_of_step_every = null;
            list_pergrid      = null;
            list_add_particle = null;
            list_gas_react    = null;
            list_surf_react   = null;
            list_timeflag     = null;

            ncompute = maxcompute = 0;
            compute  = null;
        }
Example #20
0
        public double pushvalue;        // new position to push to

        public Surf(SPARTA sparta)
        {
            this.sparta          = sparta;
            exist                = 0;
            surf_collision_check = 1;

            gnames      = new string[MAXGROUP];
            bitmask     = new int[MAXGROUP];
            inversemask = new int[MAXGROUP];

            for (int i = 0; i < MAXGROUP; i++)
            {
                bitmask[i] = 1 << i;
            }
            for (int i = 0; i < MAXGROUP; i++)
            {
                inversemask[i] = bitmask[i] ^ ~0;
            }

            ngroup = 1;
            int n = "all".Length + 1;

            gnames[0] = string.Copy("all");

            npoint = nline = ntri = 0;
            //pts = null;
            //lines = null;
            //tris = null;
            pushflag = 1;

            nlocal  = 0;
            mysurfs = null;

            nsc = maxsc = 0;
            sc  = null;

            nsr = maxsr = 0;
            sr  = null;

            tally_comm = (int)Enum1.TALLYAUTO;
        }
Example #21
0
        public int[] uni2orig;         // proc I in universe uworld is
        // proc uni2orig[I] in original communicator

        public Universe(SPARTA sparta, MPI_Comm communicator)
        {
            version = Version.SPARTA_VERSION;

            uworld = uorig = communicator;
            sparta.mpi.MPI_Comm_rank(uworld, ref me);
            sparta.mpi.MPI_Comm_size(uworld, ref nprocs);

            //uscreen = stdout;
            ulogfile = null;

            existflag       = 0;
            nworlds         = 0;
            procs_per_world = null;
            root_proc       = null;

            int[] uni2orig = new int[nprocs];
            for (int i = 0; i < nprocs; i++)
            {
                uni2orig[i] = i;
            }
        }
Example #22
0
        public SurfReact(SPARTA sparta, int narg, string[] args)
        {
            this.sparta = sparta;
            string[] arg = new string[narg];
            Array.Copy(args, 1, arg, 0, narg);

            // ID and style
            // ID must be all alphanumeric chars or underscores

            int n = arg[0].Length + 1;

            id = string.Copy(arg[0]);

            for (int i = 0; i < n - 1; i++)
            {
                if (!char.IsLetterOrDigit(id[i]) && id[i] != '_')
                {
                    sparta.error.all("Surf_react ID must be alphanumeric or underscore characters");
                }
            }

            n     = arg[0].Length + 1;
            style = string.Copy(arg[0]);

            vector_flag = 1;
            size_vector = 2;

            nsingle = ntotal = 0;

            // surface reaction data structs

            nlist = maxlist = 0;
            rlist = null;

            reactions = null;
            indices   = null;
        }
Example #23
0
        /* ---------------------------------------------------------------------- */

        public Variable(SPARTA sparta)
        {
            this.sparta = sparta;
            sparta.mpi.MPI_Comm_rank(sparta.world, ref me);

            nvar = maxvar = 0;
            names = null;
            style = null;
            num = null;
            which = null;
            pad = null;
            reader = null;
            data = null;
            dvalue = null;

            eval_in_progress = null;

            randomequal = null;
            randomparticle = null;

            //precedence[Enum3.DONE] = 0;
            //precedence[OR] = 1;
            //precedence[AND] = 2;
            //precedence[EQ] = precedence[NE] = 3;
            //precedence[LT] = precedence[LE] = precedence[GT] = precedence[GE] = 4;
            //precedence[ADD] = precedence[SUBTRACT] = 5;
            //precedence[MULTIPLY] = precedence[DIVIDE] = precedence[MODULO] = 6;
            //precedence[CARAT] = 7;
            //precedence[UNARY] = precedence[NOT] = 8;

            // local storage of compute vector_grid values
            // stored when a grid-style variable compute uses post_process_grid_flag

            maxvec_storage = 0;
            vec_storage = null;
            maxlen_storage = null;
        }
Example #24
0
        public Output(SPARTA sparta)
        {
            this.sparta = sparta;
            stats       = new Stats(sparta);

            stats_every = 0;
            var_stats   = null;

            ndump      = 0;
            max_dump   = 0;
            every_dump = null;
            next_dump  = null;
            last_dump  = null;
            var_dump   = null;
            ivar_dump  = null;
            dump       = null;

            restart_flag         = restart_flag_single = restart_flag_double = 0;
            restart_every_single = restart_every_double = 0;
            last_restart         = -1;
            restart1             = restart2a = restart2b = null;
            var_restart_single   = var_restart_double = null;
            restart = null;
        }
Example #25
0
 public Run(SPARTA sparta)
 {
     this.sparta = sparta;
 }
Example #26
0
 public RanMars(SPARTA sparta)
 {
     this.sparta = sparta;
     initflag    = 0;
     u           = null;
 }
Example #27
0
 public Timer(SPARTA sparta)
 {
     this.sparta = sparta;
     array       = new double[(int)Enum1.TIME_N];
 }
Example #28
0
 public Finish(SPARTA sparta)
 {
     this.sparta = sparta;
 }
Example #29
0
 public Error(SPARTA sparta)
 {
     this.sparta = sparta;
 }
Example #30
0
 public CreateParticles(SPARTA sparta)
 {
     this.sparta = sparta;
 }