private void UpdateTemperature(int timeStep)
        {
            for (int i = 0; i < linearSystems.Length; i++)
            {
                foreach (ILinearSystem linearSystem in linearSystems[i].Values)
                {
                    int id = linearSystem.Subdomain.ID;
                    temperature[i][id].CopyFrom(linearSystem.Solution);
                    //temperature[i][id].AddIntoThis(linearSystem.Solution);
                    if ((timeStep + 1) % 1 == 0)
                    {
                        string path0 = @"C:\Users\cluster\Desktop\MSolve-ImmunoMech\MSolve-ImmunoMech\ISAAR.MSolve.Tests\Results";
                        //string path1 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput\temperature0.txt";
                        //string path = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                        var path2  = Path.Combine(path0, $"temperature{i}-{timeStep}.txt");
                        var writer = new LinearAlgebra.Output.FullVectorWriter()
                        {
                            ArrayFormat = Array1DFormat.PlainVertical
                        };
                        writer.WriteToFile(temperature[i][id], path2);
                        //writer.WriteToFile(temperature[id][0], path1);

                        //File.AppendAllLines(path1, new string[] { temperature[id][0].ToString() }, Encoding.UTF8);
                        //File.AppendAllLines(path2, new string[] { temperature[id][340].ToString() }, Encoding.UTF8);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void UpdateUnknown(int timeStep)
        {
            foreach (ILinearSystem linearSystem in linearSystems.Values)
            {
                int id = linearSystem.Subdomain.ID;
                unknown[id].CopyFrom(linearSystem.Solution);
                unknown[id].AddIntoThis(linearSystem.Solution);
                if ((timeStep + 1) % 1 == 0)
                {
                    string path0 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                    //string path1 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput\temperature0.txt";
                    //string path = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                    var path2  = Path.Combine(path0, $"unknown-{timeStep}.txt");
                    var writer = new LinearAlgebra.Output.FullVectorWriter()
                    {
                        ArrayFormat = Array1DFormat.PlainVertical
                    };
                    writer.WriteToFile(unknown[id], path2);
                    //writer.WriteToFile(temperature[id][0], path1);

                    //File.AppendAllLines(path1, new string[] { temperature[id][0].ToString() }, Encoding.UTF8);
                    //File.AppendAllLines(path2, new string[] { temperature[id][340].ToString() }, Encoding.UTF8);
                }
            }
        }
Ejemplo n.º 3
0
        private void UpdateTemperature(int timeStep)
        {
            for (int i = 0; i < linearSystems.Length; i++)
            {
                foreach (ILinearSystem linearSystem in linearSystems[i].Values)
                {
                    int id = linearSystem.Subdomain.ID;
                    temperature[i][id].CopyFrom(linearSystem.Solution);
                    //temperature[i][id].AddIntoThis(linearSystem.Solution);
                    if ((timeStep + 1) % 1 == 0)
                    {
                        var path0  = Path.Combine(Directory.GetCurrentDirectory(), $"MSolveOutput");
                        var path   = Path.Combine(path0, $"temperature{i}-{timeStep}.txt");
                        var writer = new LinearAlgebra.Output.FullVectorWriter()
                        {
                            ArrayFormat = Array1DFormat.PlainVertical
                        };
                        writer.WriteToFile(temperature[i][id], path);
                        //writer.WriteToFile(temperature[id][0], path1);

                        //File.AppendAllLines(path1, new string[] { temperature[id][0].ToString() }, Encoding.UTF8);
                        //File.AppendAllLines(path2, new string[] { temperature[id][340].ToString() }, Encoding.UTF8);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void UpdateVelocityAndAcceleration(int timeStep)
        {
            var externalVelocities    = provider.GetVelocitiesOfTimeStep(timeStep);
            var externalAccelerations = provider.GetAccelerationsOfTimeStep(timeStep);

            foreach (ILinearSystem linearSystem in linearSystems.Values)
            {
                int id = linearSystem.Subdomain.ID;
                u[id].CopyFrom(v[id]); //TODO: this copy can be avoided by pointing to v[id] and then v[id] = null;
                //v[id].CopyFrom(linearSystem.Solution);
                v[id].CopyFrom(ChildAnalyzer.Responses[id]);
                IVector vv = v2[id].Add(externalAccelerations[id]);

                // v2 = a0 * (v - u) - a2 * v1 - a3 * vv
                v2[id] = v[id].Subtract(u[id]);
                v2[id].LinearCombinationIntoThis(a0, v1[id], -a2);
                v2[id].AxpyIntoThis(vv, -a3);

                // v1 = v1 + externalVelocities + a6 * vv + a7 * v2
                v1[id].AddIntoThis(externalVelocities[id]);
                v1[id].AxpyIntoThis(vv, a6);
                v1[id].AxpyIntoThis(v2[id], a7);

                if ((timeStep + 1) % 1 == 0)
                {
                    var path2  = Path.Combine(path0, $"displacement{timeStep}.txt");
                    var writer = new LinearAlgebra.Output.FullVectorWriter()
                    {
                        ArrayFormat = Array1DFormat.PlainVertical
                    };
                    writer.WriteToFile(v[id], path2);
                }
            }
        }
        private void UpdateVelocityAndAcceleration(int timeStep)
        {
            for (int i = 0; i < linearSystems.Length; i++)
            {
                //InitializeInternal();
                //foreach (ILinearSystem linearSystem in linearSystems[i].Values)
                //{
                //    linearSystem.Reset(); // Necessary to define the linear system's size
                //}
                //providers[i].
                var externalVelocities    = providers[i].GetVelocitiesOfTimeStep(timeStep);
                var externalAccelerations = providers[i].GetAccelerationsOfTimeStep(timeStep);
                foreach (ILinearSystem linearSystem in linearSystems[i].Values)
                {
                    int id = linearSystem.Subdomain.ID;
                    //temperature[i][id].CopyFrom(linearSystem.Solution);
                    //temperature[i][id].AddIntoThis(linearSystem.Solution);
                    u[i][id].CopyFrom(v[i][id]); //TODO: this copy can be avoided by pointing to v[id] and then v[id] = null;
                    v[i][id].CopyFrom(linearSystem.Solution);

                    IVector vv = v2[i][id].Add(externalAccelerations[id]);

                    // v2 = a0 * (v - u) - a2 * v1 - a3 * vv
                    v2[i][id] = v[i][id].Subtract(u[i][id]);
                    v2[i][id].LinearCombinationIntoThis(a0, v1[i][id], -a2);
                    v2[i][id].AxpyIntoThis(vv, -a3);

                    // v1 = v1 + externalVelocities + a6 * vv + a7 * v2
                    v1[i][id].AddIntoThis(externalVelocities[id]);
                    v1[i][id].AxpyIntoThis(vv, a6);
                    v1[i][id].AxpyIntoThis(v2[i][id], a7);
                    if ((timeStep + 1) % 1 == 0)
                    {
                        string path0 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                        //string path1 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput\temperature0.txt";
                        //string path = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                        var path2 = Path.Combine(path0, $"v{i}-{timeStep}.txt");
                        //var path2 = Path.Combine(path0, $"temperature{i}-{timeStep}.txt");
                        var writer = new LinearAlgebra.Output.FullVectorWriter()
                        {
                            ArrayFormat = Array1DFormat.PlainVertical
                        };
                        writer.WriteToFile(v[i][id], path2);
                        //writer.WriteToFile(temperature[i][id], path2);
                        //writer.WriteToFile(temperature[id][0], path1);

                        //File.AppendAllLines(path1, new string[] { temperature[id][0].ToString() }, Encoding.UTF8);
                        //File.AppendAllLines(path2, new string[] { temperature[id][340].ToString() }, Encoding.UTF8);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void UpdateVelocityAndAcceleration(int timeStep)
        {
            var externalVelocities    = provider.GetVelocitiesOfTimeStep(timeStep);
            var externalAccelerations = provider.GetAccelerationsOfTimeStep(timeStep);

            foreach (ILinearSystem linearSystem in linearSystems.Values)
            {
                int id = linearSystem.Subdomain.ID;
                u[id].CopyFrom(v[id]); //TODO: this copy can be avoided by pointing to v[id] and then v[id] = null;
                //v[id].CopyFrom(linearSystem.Solution);
                v[id].CopyFrom(ChildAnalyzer.Responses[id]);
                IVector vv = v2[id].Add(externalAccelerations[id]);

                // v2 = a0 * (v - u) - a2 * v1 - a3 * vv
                v2[id] = v[id].Subtract(u[id]);
                v2[id].LinearCombinationIntoThis(a0, v1[id], -a2);
                v2[id].AxpyIntoThis(vv, -a3);

                // v1 = v1 + externalVelocities + a6 * vv + a7 * v2
                v1[id].AddIntoThis(externalVelocities[id]);
                v1[id].AxpyIntoThis(vv, a6);
                v1[id].AxpyIntoThis(v2[id], a7);

                if ((timeStep + 1) % 1 == 0)
                {
                    string path0 = Path.Combine(Directory.GetCurrentDirectory(), "MsolveOutput");
                    //string path0 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                    //string path1 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput\temperature0.txt";
                    //string path = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                    var path2  = Path.Combine(path0, $"displacement{timeStep}.txt");
                    var writer = new LinearAlgebra.Output.FullVectorWriter()
                    {
                        ArrayFormat = Array1DFormat.PlainVertical
                    };
                    writer.WriteToFile(v[id], path2);
                    //writer.WriteToFile(temperature[id][0], path1);

                    //File.AppendAllLines(path1, new string[] { temperature[id][0].ToString() }, Encoding.UTF8);
                    //File.AppendAllLines(path2, new string[] { temperature[id][340].ToString() }, Encoding.UTF8);
                }
            }
        }
Ejemplo n.º 7
0
        private void UpdateTemperature(int timeStep)
        {
            foreach (ILinearSystem linearSystem in linearSystems.Values)
            {
                int id = linearSystem.Subdomain.ID;
                temperature[BDForder][id].CopyFrom(linearSystem.Solution);
                for (int i = 0; i < BDForder; i++)
                {
                    temperature[i][id].CopyFrom(temperature[i + 1][id]);
                }
                if ((timeStep + 1) % 1 == 0)
                {
                    //string path0 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                    ////string path1 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput\temperature0.txt";
                    ////string path = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                    //var path2 = Path.Combine(path0, $"temperature{timeStep}.txt");
                    //var writer = new LinearAlgebra.Output.FullVectorWriter() { ArrayFormat = Array1DFormat.PlainVertical };
                    //writer.WriteToFile(temperature[BDForder][id], path2);
                    ////writer.WriteToFile(temperature[id][0], path1);

                    ////File.AppendAllLines(path1, new string[] { temperature[id][0].ToString() }, Encoding.UTF8);
                    ////File.AppendAllLines(path2, new string[] { temperature[id][340].ToString() }, Encoding.UTF8);
                    string path0 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                    //string path1 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput\temperature0.txt";
                    //string path = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
                    var path2  = Path.Combine(path0, $"temperature{timeStep}.txt");
                    var writer = new LinearAlgebra.Output.FullVectorWriter()
                    {
                        ArrayFormat = Array1DFormat.PlainHorizontal
                    };
                    writer.WriteToFile(temperature[BDForder][id], path2);
                    //writer.WriteToFile(temperature[id][0], path1);

                    //File.AppendAllLines(path1, new string[] { temperature[id][0].ToString() }, Encoding.UTF8);
                    //File.AppendAllLines(path2, new string[] { temperature[id][340].ToString() }, Encoding.UTF8);
                }
            }
        }