Пример #1
0
        public static void begin()
        {
            _initializing = true;
            //色々初期化
            nParticles  = __initialParticles.Count;
            DOF         = dimension * nParticles;
            __particles = new matrix(nParticles, FriedChiken.dimension).zeros();
            index       = new matrixINT(nParticles, dimension);
            for (int i = 0; i < nParticles; i++)
            {
                for (int k = 0; k < dimension; k++)
                {
                    __particles[i, k] = __initialParticles[i][k] /* +(r.NextDouble() - 0.5) * 0.0001*/;
                    index[i, k]       = __index[i][k];
                }
            }
            //initializing masking vector
            __mask  = new vector(DOF).zeros();
            numCond = 0;
            foreach (particleSystem p in particleSystems)
            {
                p.copy(FriedChiken.__particles);
                p.begin();
            }
            if (fixX)
            {
                for (int i = 0; i < nParticles; i++)
                {
                    __mask[index[i, 0]] = 1;
                }
            }
            if (fixY)
            {
                for (int i = 0; i < nParticles; i++)
                {
                    __mask[index[i, 1]] = 1;
                }
            }
            if (fixZ)
            {
                for (int i = 0; i < nParticles; i++)
                {
                    __mask[index[i, 2]] = 1;
                }
            }
            if (numCond > 0)
            {
                FriedChiken.residual = new vector(numCond).zeros();
                FriedChiken.jacobian = new matrix(numCond, DOF).zeros();
            }
            else
            {
                FriedChiken.residual = null;
                FriedChiken.jacobian = null;
            }
            FriedChiken.gradient = new vector(DOF).zeros();
            FriedChiken.load     = new vector(DOF).zeros();
            FriedChiken.omega    = new vector(DOF).zeros();
            FriedChiken.reaction = new vector(DOF).zeros();
            FriedChiken.x        = new vector(DOF).zeros();
            __particles.DecomposeTo(FriedChiken.x);
            FriedChiken.q   = new vector(DOF).zeros();
            FriedChiken.r   = new vector(DOF).zeros();
            FriedChiken._q  = new vector(DOF).zeros();
            FriedChiken._r  = new vector(DOF).zeros();
            FriedChiken.__q = new vector(DOF).zeros();
            FriedChiken.__r = new vector(DOF).zeros();
            _initializing   = false;
            _isInit         = true;

            Random r = new Random(0);

            for (int i = 0; i < nParticles; i++)
            {
                for (int k = 0; k < dimension; k++)
                {
                    __particles[i, k] = __particles[i, k] + (r.NextDouble() - 0.5) * 0.001;
                }
            }
            __particles.DecomposeTo(FriedChiken.x);
        }