Exemple #1
0
        private static IVectorView SolveModel(Model model, IModelReader modelReader)
        {
            var builder = new SkylineSolver.Builder();
            //builder.IsMatrixPositiveDefinite = false;
            var          solver   = builder.BuildSolver(model);
            const double timestep = 1;
            const double time     = 100;

            var provider             = new ProblemStructural(model, solver);
            var increments           = 2;
            var childAnalyzerBuilder = new LoadControlAnalyzer.Builder(model, solver, provider, increments);

            childAnalyzerBuilder.ResidualTolerance             = 1E-6;
            childAnalyzerBuilder.MaxIterationsPerIncrement     = 50;
            childAnalyzerBuilder.NumIterationsForMatrixRebuild = 1;
            LoadControlAnalyzer childAnalyzer = childAnalyzerBuilder.Build();

            //var parentAnalyzerBuilder = new NewmarkDynamicAnalyzer.Builder(model, solver, provider, childAnalyzer, timestep, time);
            //parentAnalyzerBuilder.SetNewmarkParametersForConstantAcceleration();
            //NewmarkDynamicAnalyzer parentAnalyzer = parentAnalyzerBuilder.Build();
            var parentAnalyzer = new NewmarkDynamicAnalyzer(UpdateNewmarkModel, model, solver,
                                                            provider, childAnalyzer, timestep, time, .25, .5);


            parentAnalyzer.Initialize();
            for (int i = 0; i < time / timestep; i++)
            {
                //lambdag = .01 * i + 1;
                parentAnalyzer.SolveTimestep(i);
            }

            return(solver.LinearSystems[subdomainID].Solution);
        }
Exemple #2
0
 /// <summary>
 /// Creates a new instance of the <see cref="ModelRepository"/> type.
 /// </summary>
 /// <param name="modelFactories">
 /// A collection that contains all registered <see cref="IModelFactory"/> implementations.
 /// </param>
 /// <param name="modelReader">
 /// A <see cref="IModelReader"/> implementation for loading persisted <see cref="IModel"/>s from disk.
 /// </param>
 public ModelRepository(
     IEnumerable <IModelFactory> modelFactories,
     IModelReader modelReader)
 {
     ModelFactories = modelFactories?.ToDictionary(f => f.Id) ?? new Dictionary <Guid, IModelFactory>();
     ModelReader    = modelReader;
 }
Exemple #3
0
 public static Model Load(IModelReader source)
 {
     var m = new Model(source.Words, source.Size);
     WordVector wv;
     while (null != (wv = source.ReadVector()))
     {
         m.AddVector(wv);
     }
     return m;
 }
Exemple #4
0
        public static Model Load(IModelReader source)
        {
            var        m = new Model(source.Words, source.Size);
            WordVector wv;

            while (null != (wv = source.ReadVector()))
            {
                m.AddVector(wv);
            }
            return(m);
        }
 public FileExporter(
     IModelReader <TRead> modelReader,
     IValueSerializer <TRead, TSerialized> valueSerializer,
     IDataWriter <TSerialized> fileWriter,
     IFileStreamer fileStreamer
     )
 {
     _modelReader     = modelReader;
     _valueSerializer = valueSerializer;
     _DataWriter      = fileWriter;
     _fileStreamer    = fileStreamer;
 }
Exemple #6
0
        /// <summary>
        /// Creates new package reader with specified IModelReader
        /// </summary>
        public PackageReader(IModelReader reader)
        {
            Reader = reader;

            _descriptors = new Dictionary <int, PackageDescriptor>();
        }
Exemple #7
0
 public WorkshopReader(IModelReader reader, IMapper mapper)
 {
     _reader = reader;
     _mapper = mapper;
 }
Exemple #8
0
 public static Model Load(IModelReader source)
 {
     return(source.Open());
 }
 public static void RegisterReader(IModelReader p_pReader)
 {
     sm_ListOfReaders.Add(p_pReader);
 }
Exemple #10
0
        private static void RunTest()
        {
            Model        model       = CreateModel1(1, 1, new DynamicMaterial(0.001, 0, 0, true), 0, new double[] { 0, 0, 200 }, lambdag).Item1;;
            IModelReader modelReader = CreateModel1(1, 1, new DynamicMaterial(.001, 0, 0, true), 0, new double[] { 0, 0, 200 }, lambdag).Item2;
            //string path0 = @"C:\Users\Ody\Documents\Marie Curie\comsolModels\MsolveOutput";
            string path3 = Path.Combine(Directory.GetCurrentDirectory(), "HyperElastiGrowthCantilever.vtu");
            //var path2 = Path.Combine(path0, $"nodes.txt");

            IVectorView solution = SolveModel(model, modelReader);

            var numberOfPoints = model.Nodes.Count;
            var numberOfCells  = model.Elements.Count;

            using (StreamWriter outputFile = new StreamWriter(path3))
            {
                outputFile.WriteLine("<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">");
                outputFile.WriteLine("  <UnstructuredGrid>");
                outputFile.WriteLine($"     <Piece NumberOfPoints=\"{numberOfPoints}\" NumberOfCells=\"{numberOfCells}\">");
                outputFile.WriteLine("          <Points>");

                outputFile.WriteLine("              <DataArray type=\"Float64\" Name=\"position\" NumberOfComponents=\"3\" format =\"ascii\">");
                for (int i = 0; i < numberOfPoints; i++)
                {
                    outputFile.WriteLine($"{model.Nodes[i].X} {model.Nodes[i].Y} {model.Nodes[i].Z} ");
                }
                outputFile.WriteLine("              </DataArray>");

                outputFile.WriteLine("          </Points>");
                outputFile.WriteLine("          <PointData>");

                outputFile.WriteLine("              <DataArray type=\"Int32\" Name=\"node_ID\" NumberOfComponents=\"1\" format=\"ascii\">");
                for (int i = 0; i < numberOfPoints; i++)
                {
                    outputFile.WriteLine($"{i + 1}");
                }
                outputFile.WriteLine("              </DataArray>");

                outputFile.WriteLine("              <DataArray type=\"Float64\" Name=\"displacement\" NumberOfComponents=\"1\" format=\"ascii\">");
                for (int i = 0; i < 4; i++)
                {
                    outputFile.WriteLine($"{0} ");
                }
                for (int i = 0; i < numberOfPoints - 4; i++)
                {
                    outputFile.WriteLine($"{Displacements[3 * (i + 1) - 1]} ");
                }
                outputFile.WriteLine("              </DataArray>");
                outputFile.WriteLine("          </PointData>");
                outputFile.WriteLine("          <CellData>");
                outputFile.WriteLine("              <DataArray type=\"Int32\" Name=\"element_ID\" NumberOfComponents=\"1\" format=\"ascii\">");
                for (int i = 0; i < numberOfCells; i++)
                {
                    outputFile.WriteLine($"{i + 1}");
                }
                outputFile.WriteLine("              </DataArray>");
                outputFile.WriteLine("          </CellData>");
                outputFile.WriteLine("          <Cells>");

                outputFile.WriteLine("              <DataArray type=\"Int32\" Name=\"connectivity\">");
                for (int i = 0; i < numberOfCells; i++)
                {
                    for (int j = 0; j < model.Elements[i].Nodes.Count; j++)
                    {
                        outputFile.Write($"{model.Elements[i].Nodes[j].ID} ");
                    }
                    outputFile.WriteLine("");
                }
                outputFile.WriteLine("              </DataArray>");

                outputFile.WriteLine("              <DataArray type=\"Int32\" Name=\"offsets\" NumberOfComponents=\"1\" format=\"ascii\">");
                var offset = 0;
                for (int i = 0; i < numberOfCells; i++)
                {
                    offset += model.Elements[i].Nodes.Count;
                    outputFile.WriteLine($"{offset} ");
                }
                outputFile.WriteLine("              </DataArray>");

                outputFile.WriteLine("              <DataArray type=\"Int32\" Name =\"types\" NumberOfComponents =\"1\" format=\"ascii\">");
                for (int i = 0; i < numberOfCells; i++)
                {
                    if (model.Elements[i].Nodes.Count == 8)
                    {
                        outputFile.WriteLine($"{12} ");
                    }
                    else
                    {
                        outputFile.WriteLine($"{9} ");
                    }
                }
                outputFile.WriteLine("              </DataArray>");
                outputFile.WriteLine("          </Cells>");
                outputFile.WriteLine("      </Piece>");
                outputFile.WriteLine("  </UnstructuredGrid>");
                outputFile.WriteLine("</VTKFile>");
            }

            Assert.True(CompareResults(solution));
        }
Exemple #11
0
 public JobReader(IModelReader reader, IMapper mapper)
 {
     _reader = reader;
     _mapper = mapper;
 }
Exemple #12
0
 public CustomerReader(IModelReader reader, IMapper mapper)
 {
     _reader = reader;
     _mapper = mapper;
 }
Exemple #13
0
 public ApplicationController(IModelReader modelReader)
 {
     _modelReader = modelReader;
 }
Exemple #14
0
 public CustomModelRW()
 {
     _writer = new CustomModelWriter();
     _reader = new CustomModelReader();
 }
Exemple #15
0
 public ProjectReader(IModelReader reader, IMapper mapper)
 {
     _reader = reader;
     _mapper = mapper;
 }
Exemple #16
0
 public DefaultModelRW()
 {
     _writer = new TwinoModelWriter();
     _reader = new TwinoModelReader();
 }