示例#1
0
        private static Tuple <Model, IModelReader> CreateModel3(double C1, double C2, IDynamicMaterial commonDynamicMaterialProperties, double b, double[] l, double lambdag)
        {
            double poissonV    = 0.2;
            double muLame      = 2 * C1;
            double bulkModulus = 2 * muLame * (1 + poissonV) / (3 * (1 - 2 * poissonV));
            string filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "9hexa.mphtxt");
            var    modelReader = new ComsolMeshReader1(filename, C1, C2, 1, commonDynamicMaterialProperties, lambdag);
            Model  model       = modelReader.CreateModelFromFile();
            //Boundary Conditions
            var lx = l[0];
            var ly = l[1];
            var lz = l[2];
            var distributedLoad = new DistributedLoad(lx, ly, lz);
            //var flux2 = new FluxLoad(f2);
            //var dir1 = new DirichletDistribution(list => {
            //    return Vector.CreateWithValue(list.Count, b1);
            //});
            //var dir2 = new DirichletDistribution(list => {
            //    return Vector.CreateWithValue(list.Count, b2);
            //});
            //var weakDirichlet1 = new WeakDirichlet(dir1, k);
            //var weakDirichlet2 = new WeakDirichlet(dir2, k);

            //var dirichletFactory1 = new SurfaceLoadElementFactory(weakDirichlet1);
            //var dirichletFactory2 = new SurfaceLoadElementFactory(weakDirichlet2);
            var distributedLoadFactory = new SurfaceLoadElementFactory(distributedLoad);

            //var fluxFactory2 = new SurfaceLoadElementFactory(flux2);
            //var boundaryFactory3D = new SurfaceBoundaryFactory3D(0,
            //    new ConvectionDiffusionMaterial(k, new double[] { 0, 0, 0 }, 0));


            int[] boundaryIDs = new int[] { 0, 5 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    foreach (Node node in nodes)
                    {
                        node.Constraints.Add(new Constraint()
                        {
                            Amount = b,
                            DOF    = StructuralDof.TranslationX
                        });
                        node.Constraints.Add(new Constraint()
                        {
                            Amount = b,
                            DOF    = StructuralDof.TranslationY
                        });
                        node.Constraints.Add(new Constraint()
                        {
                            Amount = b,
                            DOF    = StructuralDof.TranslationZ
                        });
                    }
                }
            }
            return(new Tuple <Model, IModelReader>(model, modelReader));
        }
示例#2
0
        private static Tuple <Model, ComsolMeshReader> CreateModel()
        {
            string           filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "mesh1.mphtxt");
            ComsolMeshReader modelReader = new ComsolMeshReader(filename);
            Model            model       = modelReader.CreateModelFromFile();
            //Boundary Conditions
            var flux = new FluxLoad(10);
            var dir1 = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, 0));
            });
            var dir2 = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, 1));
            });
            var weakDirichlet1 = new WeakDirichlet(dir1, modelReader.diffusionCeoff);
            var weakDirichlet2 = new WeakDirichlet(dir2, modelReader.diffusionCeoff);

            var dirichletFactory1 = new SurfaceLoadElementFactory(weakDirichlet1);
            var dirichletFactory2 = new SurfaceLoadElementFactory(weakDirichlet2);
            var fluxFactory       = new SurfaceLoadElementFactory(flux);

            int[] boundaryIDs = new int[] { 2, 7, 8, 9 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (Element element in modelReader.elementBoundaries[boundaryID])
                {
                    IReadOnlyList <Node> nodes = (IReadOnlyList <Node>)element.Nodes;
                    var dirichletElement1      = dirichletFactory1.CreateElement(CellType.Tri3, nodes);
                    model.SurfaceLoads.Add(dirichletElement1);
                    //var surfaceElement = new SurfaceLoadElement();
                    //element.ID = TriID;
                    //surfaceElement.ElementType = DirichletElement1;
                    //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //model.ElementsDictionary.Add(TriID, surfaceElement);

                    //model.NodesDictionary[surfaceElement.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 100 });
                }
            }
            boundaryIDs = new int[] { 0, 1, 3, 4, 6 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (Element element in modelReader.elementBoundaries[boundaryID])
                {
                    IReadOnlyList <Node> nodes = (IReadOnlyList <Node>)element.Nodes;
                    var dirichletElement2      = dirichletFactory2.CreateElement(CellType.Tri3, nodes);
                    model.SurfaceLoads.Add(dirichletElement2);
                }
            }

            return(new Tuple <Model, ComsolMeshReader>(model, modelReader));
        }
        private static Tuple <Model, IModelReader> CreateStructuralModel(double C1, double C2, IDynamicMaterial commonDynamicMaterialProperties, double b, double[] l, double lg)
        {
            string filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "9hexa.mphtxt");
            double poisonRatio = .45;
            double bulkModulus = 4 * C1 * (1 + poisonRatio) / 3 / (1 - 2 * poisonRatio);
            var    modelReader = new ComsolMeshReader1(filename, C1, C2, bulkModulus, commonDynamicMaterialProperties, lg);
            Model  model       = modelReader.CreateModelFromFile();
            //Boundary Conditions
            var lx = l[0];
            var ly = l[1];
            var lz = l[2];
            var distributedLoad        = new DistributedLoad(lx, ly, lz);
            var distributedLoadFactory = new SurfaceLoadElementFactory(distributedLoad);


            int[] boundaryIDs = new int[] { 0 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    foreach (Node node in nodes)
                    {
                        node.Constraints.Add(new Constraint()
                        {
                            Amount = b,
                            DOF    = StructuralDof.TranslationX
                        });
                        //node.Constraints.Add(new Constraint()
                        //{
                        //    Amount = b,
                        //    DOF = StructuralDof.TranslationY
                        //});
                        //node.Constraints.Add(new Constraint()
                        //{
                        //    Amount = b,
                        //    DOF = StructuralDof.TranslationZ
                        //});
                    }
                }
            }
            boundaryIDs = new int[] { 1 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    foreach (Node node in nodes)
                    {
                        //node.Constraints.Add(new Constraint()
                        //{
                        //    Amount = b,
                        //    DOF = StructuralDof.TranslationX
                        //});
                        node.Constraints.Add(new Constraint()
                        {
                            Amount = b,
                            DOF    = StructuralDof.TranslationY
                        });
                        //node.Constraints.Add(new Constraint()
                        //{
                        //    Amount = b,
                        //    DOF = StructuralDof.TranslationZ
                        //});
                    }
                }
            }
            boundaryIDs = new int[] { 2 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    foreach (Node node in nodes)
                    {
                        //node.Constraints.Add(new Constraint()
                        //{
                        //    Amount = b,
                        //    DOF = StructuralDof.TranslationX
                        //});
                        //node.Constraints.Add(new Constraint()
                        //{
                        //    Amount = b,
                        //    DOF = StructuralDof.TranslationY
                        //});
                        node.Constraints.Add(new Constraint()
                        {
                            Amount = b,
                            DOF    = StructuralDof.TranslationZ
                        });
                    }
                }
            }
            boundaryIDs = new int[] { 5 };
            int QuadID = model.ElementsDictionary.Count + 1;

            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    foreach (Node node in nodes)
                    {
                        model.Loads.Add(new Load()
                        {
                            Node = node, DOF = StructuralDof.TranslationX, Amount = +250.0
                        });
                    }

                    //var distributedLoadElement = distributedLoadFactory.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(distributedLoadElement);
                }
            }
            return(new Tuple <Model, IModelReader>(model, modelReader));
        }
        private static Tuple <Model, IModelReader> CreateConvectionDiffusionModel2(double k, double[] U, double L, double b, double f, double bl)
        {
            string filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "9hexa.mphtxt");
            var    modelReader = new ComsolMeshReader2(filename, k, U, L);
            Model  model       = modelReader.CreateModelFromFile();
            var    material    = new ConvectionDiffusionMaterial(k, U, L);
            //Boundary Conditions
            var flux1 = new FluxLoad(f);
            var dir1  = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, b));
            });
            //var dir2 = new DirichletDistribution(list =>
            //{
            //    return Vector.CreateWithValue(list.Count, b2);
            //});
            var weakDirichlet1 = new WeakDirichlet(dir1, k);
            //var weakDirichlet2 = new WeakDirichlet(dir2, k);

            var dirichletFactory1 = new SurfaceLoadElementFactory(weakDirichlet1);
            //var dirichletFactory2 = new SurfaceLoadElementFactory(weakDirichlet2);
            var fluxFactory1      = new SurfaceLoadElementFactory(flux1);
            var boundaryFactory3D = new SurfaceBoundaryFactory3D(0,
                                                                 new ConvectionDiffusionMaterial(k, new double[] { 0, 0, 0 }, 0));


            int[] domainIDs = new int[] { 0, };
            foreach (int domainID in domainIDs)
            {
                foreach (Element element in modelReader.elementDomains[domainID])
                {
                    ////IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
                    //var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(fluxElement1);
                    var bodyLoadElementCellType = element.ElementType.CellType;
                    var nodes                  = (IReadOnlyList <Node>)element.Nodes;
                    var domainLoad             = new ConvectionDiffusionDomainLoad(material, bl, ThermalDof.Temperature);
                    var bodyLoadElementFactory = new BodyLoadElementFactory(domainLoad, model);
                    var bodyLoadElement        = bodyLoadElementFactory.CreateElement(CellType.Hexa8, nodes);
                    model.BodyLoads.Add(bodyLoadElement);
                    //var surfaceElement = new SurfaceLoadElement();
                    //element.ID = TriID;
                    //surfaceElement.ElementType = DirichletElement1;
                    //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //model.ElementsDictionary.Add(TriID, surfaceElement);

                    //model.NodesDictionary[surfaceElement.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 100 });
                }
            }
            //foreach (Node node in model.Nodes)
            //{
            //    model.Loads.Add(new Load() { Amount = bl[node.ID], Node = node, DOF = ThermalDof.Temperature });
            //}

            int[] boundaryIDs = new int[] { 0, };
            int   QuadID      = model.ElementsDictionary.Count + 1;

            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    //var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(fluxElement1);
                    //var dirichletElement1 = dirichletFactory1.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(dirichletElement1);
                    //var SurfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Quad4, nodes);
                    //var element = new Element();
                    //element.ID = QuadID;
                    //element.ElementType = SurfaceBoundaryElement;
                    //model.SubdomainsDictionary[0].Elements.Add(element);
                    //model.ElementsDictionary.Add(QuadID, element);
                    //foreach (Node node in nodes)
                    //{
                    //    element.AddNode(node);
                    //}
                    //QuadID += 1;
                }
            }
            boundaryIDs = new int[] { 5 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    //var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(fluxElement1);
                    //var bodyLoadElement = bodyLoadElementFactory.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(bodyLoadElement);
                    //var SurfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Quad4, nodes);
                    //var element = new Element();
                    //element.ID = QuadID;
                    //element.ElementType = SurfaceBoundaryElement;
                    //model.SubdomainsDictionary[0].Elements.Add(element);
                    //model.ElementsDictionary.Add(QuadID, element);
                    //foreach (Node node in nodes)
                    //{
                    //    element.AddNode(node);
                    //}
                    //QuadID += 1;
                }
            }
            return(new Tuple <Model, IModelReader>(model, modelReader));
        }
示例#5
0
        private static Tuple <Model, ComsolMeshReader2> CreateModel(double k, double[] U, double L)
        {
            string            filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "mesh.mphtxt");
            ComsolMeshReader2 modelReader = new ComsolMeshReader2(filename, k, U, L);
            Model             model       = modelReader.CreateModelFromFile();
            //Boundary Conditions
            var flux1 = new FluxLoad(6.9e08);
            var flux2 = new FluxLoad(10);
            var dir1  = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, 1));
            });
            var dir2 = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, 0));
            });
            var weakDirichlet1 = new WeakDirichlet(dir1, k);
            var weakDirichlet2 = new WeakDirichlet(dir2, k);

            var dirichletFactory1 = new SurfaceLoadElementFactory(weakDirichlet1);
            var dirichletFactory2 = new SurfaceLoadElementFactory(weakDirichlet2);
            var fluxFactory1      = new SurfaceLoadElementFactory(flux1);
            var fluxFactory2      = new SurfaceLoadElementFactory(flux2);
            var boundaryFactory3D = new SurfaceBoundaryFactory3D(0,
                                                                 new ConvectionDiffusionMaterial(k, new double[] { 0, 0, 0 }, 0));


            int[] boundaryIDs = new int[] { 0, 1, 2 };
            //int numberOfQuadElements = 0;
            //for ( int i = 0; i<boundaryIDs.Length; i++)
            //{
            //    numberOfQuadElements += modelReader.quadBoundaries[boundaryIDs[i]].Count;
            //}
            int TriID = model.ElementsDictionary.Count + 1;

            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.triBoundaries[boundaryID])
                {
                    //var fluxElement1 = fluxFactory1.CreateElement(CellType.Tri3, nodes);
                    //model.SurfaceLoads.Add(fluxElement1);
                    var dirichletElement1 = dirichletFactory1.CreateElement(CellType.Tri3, nodes);
                    model.SurfaceLoads.Add(dirichletElement1);
                    var SurfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Tri3, nodes);
                    var element = new Element();
                    element.ID          = TriID;
                    element.ElementType = SurfaceBoundaryElement;
                    model.SubdomainsDictionary[0].Elements.Add(element);
                    model.ElementsDictionary.Add(TriID, element);
                    foreach (Node node in nodes)
                    {
                        element.AddNode(node);
                    }
                    TriID += 1;
                    // var surfaceElement = new SurfaceLoadElement();
                    //element.ID = TriID;
                    //surfaceElement.ElementType = DirichletElement1;
                    //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //model.ElementsDictionary.Add(TriID, surfaceElement);

                    //model.NodesDictionary[surfaceElement.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 100 });
                }
            }
            boundaryIDs = new int[] { 5 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    //        //IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
                    //        //var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    //        //model.SurfaceLoads.Add(fluxElement1);
                    var dirichletElement2 = dirichletFactory2.CreateElement(CellType.Quad4, nodes);
                    model.SurfaceLoads.Add(dirichletElement2);
                    var SurfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Quad4, nodes);
                    var element = new Element();
                    element.ID          = TriID;
                    element.ElementType = SurfaceBoundaryElement;
                    model.SubdomainsDictionary[0].Elements.Add(element);
                    model.ElementsDictionary.Add(TriID, element);
                    foreach (Node node in nodes)
                    {
                        element.AddNode(node);
                    }
                    TriID += 1;
                    //        // var surfaceElement = new SurfaceLoadElement();
                    //        //element.ID = TriID;
                    //        //surfaceElement.ElementType = DirichletElement1;
                    //        //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //        //model.ElementsDictionary.Add(TriID, surfaceElement);

                    //        //model.NodesDictionary[surfaceElement.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 100 });
                }
            }

            //boundaryIDs = new int[] { 1, 2, 3, 4 };
            //foreach (int boundaryID in boundaryIDs)
            //{
            //    foreach (Element element in modelReader.elementBoundaries[boundaryID])
            //    {
            //        IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
            //        var fluxElement = fluxFactory.CreateElement(CellType.Quad4, nodes);
            //        model.SurfaceLoads.Add(fluxElement);
            //    }
            //}

            return(new Tuple <Model, ComsolMeshReader2>(model, modelReader));
        }
示例#6
0
        private static Tuple <Model, ComsolMeshReader2> CreateModel(double k, double[] U, double L, double b1, double b2, double f1, double f2, double[] bl)
        {
            string            filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "9hexa.mphtxt");
            ComsolMeshReader2 modelReader = new ComsolMeshReader2(filename, k, U, L);
            Model             model       = modelReader.CreateModelFromFile();
            //Boundary Conditions
            var flux1 = new FluxLoad(f1);
            var flux2 = new FluxLoad(f2);
            var dir1  = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, b1));
            });
            var dir2 = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, b2));
            });
            var weakDirichlet1 = new WeakDirichlet(dir1, k);
            var weakDirichlet2 = new WeakDirichlet(dir2, k);

            var dirichletFactory1 = new SurfaceLoadElementFactory(weakDirichlet1);
            var dirichletFactory2 = new SurfaceLoadElementFactory(weakDirichlet2);
            var fluxFactory1      = new SurfaceLoadElementFactory(flux1);
            var fluxFactory2      = new SurfaceLoadElementFactory(flux2);
            var boundaryFactory3D = new SurfaceBoundaryFactory3D(0,
                                                                 new ConvectionDiffusionMaterial(k, new double[] { 0, 0, 0 }, 0));

            foreach (Node node in model.Nodes)
            {
                model.Loads.Add(new Load()
                {
                    Amount = bl[node.ID], Node = node, DOF = ThermalDof.Temperature
                });
            }


            int[] boundaryIDs = new int[] { 0, };
            int   QuadID      = model.ElementsDictionary.Count + 1;

            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    model.SurfaceLoads.Add(fluxElement1);
                    var dirichletElement1 = dirichletFactory1.CreateElement(CellType.Quad4, nodes);
                    model.SurfaceLoads.Add(dirichletElement1);
                    var SurfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Quad4, nodes);
                    var element = new Element();
                    element.ID          = QuadID;
                    element.ElementType = SurfaceBoundaryElement;
                    model.SubdomainsDictionary[0].Elements.Add(element);
                    model.ElementsDictionary.Add(QuadID, element);
                    foreach (Node node in nodes)
                    {
                        element.AddNode(node);
                    }
                    QuadID += 1;
                }
            }
            boundaryIDs = new int[] { 5 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    model.SurfaceLoads.Add(fluxElement1);
                    var dirichletElement2 = dirichletFactory2.CreateElement(CellType.Quad4, nodes);
                    model.SurfaceLoads.Add(dirichletElement2);
                    var SurfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Quad4, nodes);
                    var element = new Element();
                    element.ID          = QuadID;
                    element.ElementType = SurfaceBoundaryElement;
                    model.SubdomainsDictionary[0].Elements.Add(element);
                    model.ElementsDictionary.Add(QuadID, element);
                    foreach (Node node in nodes)
                    {
                        element.AddNode(node);
                    }
                    QuadID += 1;
                }
            }
            return(new Tuple <Model, ComsolMeshReader2>(model, modelReader));
        }
示例#7
0
        private static Tuple <Model, IModelReader> CreateStructuralModel(double[] C1, double[] C2, IDynamicMaterial[] commonDynamicMaterialProperties, double b, double[] l, double lambdag)
        {
            double[] poissonV       = new double[C1.Length];
            double[] muLame         = new double[C1.Length];
            double[] bulkModulusnew = new double[C1.Length];
            for (int i = 0; i < C1.Length; i++)
            {
                poissonV[i]       = 0.2;
                muLame[i]         = 2 * C1[i];
                bulkModulusnew[i] = 2 * muLame[i] * (1 + poissonV[i]) / (3 * (1 - 2 * poissonV[i]));
            }
            string filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "125HexaHyperelasticCube.mphtxt");
            var    modelReader = new ComsolMeshReader1(filename, C1, C2, bulkModulusnew, commonDynamicMaterialProperties, new double[] { lambdag, 1 });
            Model  model       = modelReader.CreateModelFromFile();
            //Boundary Conditions
            var lx = l[0];
            var ly = l[1];
            var lz = l[2];
            var distributedLoad = new DistributedLoad(lx, ly, lz);
            //var flux2 = new FluxLoad(f2);
            //var dir1 = new DirichletDistribution(list => {
            //    return Vector.CreateWithValue(list.Count, b1);
            //});
            //var dir2 = new DirichletDistribution(list => {
            //    return Vector.CreateWithValue(list.Count, b2);
            //});
            //var weakDirichlet1 = new WeakDirichlet(dir1, k);
            //var weakDirichlet2 = new WeakDirichlet(dir2, k);

            //var dirichletFactory1 = new SurfaceLoadElementFactory(weakDirichlet1);
            //var dirichletFactory2 = new SurfaceLoadElementFactory(weakDirichlet2);
            var distributedLoadFactory = new SurfaceLoadElementFactory(distributedLoad);

            //var fluxFactory2 = new SurfaceLoadElementFactory(flux2);
            //var boundaryFactory3D = new SurfaceBoundaryFactory3D(0,
            //    new ConvectionDiffusionMaterial(k, new double[] { 0, 0, 0 }, 0));


            int[] boundaryIDs = new int[] { 0 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (Node node in modelReader.nodeBoundaries[boundaryID])
                {
                    node.Constraints.Add(new Constraint()
                    {
                        Amount = b,
                        DOF    = StructuralDof.TranslationX
                    });
                    //node.Constraints.Add(new Constraint()
                    //{
                    //    Amount = b,
                    //    DOF = StructuralDof.TranslationY
                    //});
                    //node.Constraints.Add(new Constraint()
                    //{
                    //    Amount = b,
                    //    DOF = StructuralDof.TranslationZ
                    //});
                }
            }
            boundaryIDs = new int[] { 1 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (Node node in modelReader.nodeBoundaries[boundaryID])
                {
                    //node.Constraints.Add(new Constraint()
                    //{
                    //    Amount = b,
                    //    DOF = StructuralDof.TranslationX
                    //});
                    node.Constraints.Add(new Constraint()
                    {
                        Amount = b,
                        DOF    = StructuralDof.TranslationY
                    });
                    //node.Constraints.Add(new Constraint()
                    //{
                    //    Amount = b,
                    //    DOF = StructuralDof.TranslationZ
                    //});
                }
            }
            boundaryIDs = new int[] { 2 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (Node node in modelReader.nodeBoundaries[boundaryID])
                {
                    //node.Constraints.Add(new Constraint()
                    //{
                    //    Amount = b,
                    //    DOF = StructuralDof.TranslationX
                    //});
                    //node.Constraints.Add(new Constraint()
                    //{
                    //    Amount = b,
                    //    DOF = StructuralDof.TranslationY
                    //});
                    node.Constraints.Add(new Constraint()
                    {
                        Amount = b,
                        DOF    = StructuralDof.TranslationZ
                    });
                }
            }
            boundaryIDs = new int[] { 3 };
            int QuadID = model.ElementsDictionary.Count + 1;

            //foreach (int boundaryID in boundaryIDs)
            //{
            //    foreach (IReadOnlyList<Node> nodes in modelReader.quadBoundaries[boundaryID])
            //    {
            //        //var distributedLoadElement = distributedLoadFactory.CreateElement(CellType.Quad4, nodes);
            //        //model.SurfaceLoads.Add(distributedLoadElement);
            //        //var dirichletElement2 = dirichletFactory2.CreateElement(CellType.Quad4, nodes);
            //        //model.SurfaceLoads.Add(dirichletElement2);
            //        //var SurfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Quad4, nodes);
            //        //var element = new Element();
            //        //element.ID = QuadID;
            //        //element.ElementType = SurfaceBoundaryElement;
            //        //model.SubdomainsDictionary[0].Elements.Add(element);
            //        //model.ElementsDictionary.Add(QuadID, element);
            //        //foreach (Node node in nodes)
            //        //{
            //        //    element.AddNode(node);
            //        //}
            //        //QuadID += 1;
            //        foreach (Node node in nodes)
            //        {
            //            model.Loads.Add(new Load() { Node = node, DOF = StructuralDof.TranslationZ, Amount = +100.0 });
            //        }
            //    }
            //}
            //int[] nodeIDs = new int[] { 1, 2, 3, 4 };
            int[] nodeIDs = new int[] { 0, 5, 10, 40 };
            foreach (int nodeID in nodeIDs)
            {
                model.Loads.Add(new Load()
                {
                    Node = model.NodesDictionary[nodeID], DOF = StructuralDof.TranslationZ, Amount = +lz
                });
            }
            return(new Tuple <Model, IModelReader>(model, modelReader));
        }
        private static Model CreateModel()
        {
            IList <IList <Node> >    nodeBoundaries;
            IList <IList <Element> > elementBoundaries;
            double density = 1.0;

            double[] U = { 2, 2, 2 };
            double   k = 1.0;
            double   L = .0;
            var      elementFactory3D  = new ConvectionDiffusionElement3DFactory(new ConvectionDiffusionMaterial(k, U, L));
            var      boundaryFactory3D = new SurfaceBoundaryFactory3D(0, new ConvectionDiffusionMaterial(k, U, L));
            var      model             = new Model();

            model.SubdomainsDictionary[0] = new Subdomain(0);
            elementBoundaries             = new List <IList <Element> >();
            nodeBoundaries = new List <IList <Node> >();
            for (int i = 0; i < 10; i++)
            {
                elementBoundaries.Add(new List <Element>());
                nodeBoundaries.Add(new List <Node>());
            }

            double[,] nodeData = new double[, ] {
                { 0, 0, 0 },
                { 0, 1, 0 },
                { 0, 1, 1 },
                { 0, 0, 1 },
                { 1, 0, 0 },
                { 1, 1, 0 },
                { 1, 1, 1 },
                { 1, 0, 1 }
            };

            for (int nNode = 0; nNode < nodeData.GetLength(0); nNode++)
            {
                model.NodesDictionary.Add(nNode, new Node(id: nNode, x: nodeData[nNode, 0], y: nodeData[nNode, 1], z: nodeData[nNode, 2]));
            }
            IReadOnlyList <Node> nodes = new List <Node>
            {
                model.NodesDictionary[0],
                model.NodesDictionary[1],
                model.NodesDictionary[2],
                model.NodesDictionary[3],
                model.NodesDictionary[4],
                model.NodesDictionary[5],
                model.NodesDictionary[6],
                model.NodesDictionary[7],
            };
            IList <IReadOnlyList <Node> > face = new List <IReadOnlyList <Node> >();

            //face = new List<IReadOnlyList<Node>>();
            for (int i = 0; i < 6; i++)
            {
                face.Add(new List <Node>());
            }

            face[0] = new List <Node>
            {
                model.NodesDictionary[0],
                model.NodesDictionary[1],
                model.NodesDictionary[2],
                model.NodesDictionary[3],
            };
            face[1] = new List <Node>
            {
                model.NodesDictionary[4],
                model.NodesDictionary[5],
                model.NodesDictionary[6],
                model.NodesDictionary[7],
            };
            face[2] = new List <Node>
            {
                model.NodesDictionary[0],
                model.NodesDictionary[1],
                model.NodesDictionary[5],
                model.NodesDictionary[4],
            };
            face[3] = new List <Node>
            {
                model.NodesDictionary[1],
                model.NodesDictionary[2],
                model.NodesDictionary[6],
                model.NodesDictionary[5],
            };
            face[4] = new List <Node>
            {
                model.NodesDictionary[2],
                model.NodesDictionary[6],
                model.NodesDictionary[7],
                model.NodesDictionary[3],
            };
            face[5] = new List <Node>
            {
                model.NodesDictionary[0],
                model.NodesDictionary[4],
                model.NodesDictionary[7],
                model.NodesDictionary[3],
            };
            int[] elementData = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };// the last line will not be used. We assign only one element

            var Hexa8   = elementFactory3D.CreateElement(CellType.Hexa8, nodes);
            var element = new Element();

            element.ID          = 0;
            element.ElementType = Hexa8;
            for (int j = 0; j < 8; j++)
            {
                element.NodesDictionary.Add(elementData[j], model.NodesDictionary[elementData[j]]);
            }
            model.SubdomainsDictionary[0].Elements.Add(element);
            model.ElementsDictionary.Add(0, element);

            var flux1 = new FluxLoad(1);
            var flux2 = new FluxLoad(10);
            var dir1  = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, 0));
            });
            var dir2 = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, 10));
            });
            var weakDirichlet1 = new WeakDirichlet(dir1, k);
            var weakDirichlet2 = new WeakDirichlet(dir2, k);

            var dirichletFactory1 = new SurfaceLoadElementFactory(weakDirichlet1);
            var dirichletFactory2 = new SurfaceLoadElementFactory(weakDirichlet2);
            var fluxFactory1      = new SurfaceLoadElementFactory(flux1);
            var fluxFactory2      = new SurfaceLoadElementFactory(flux2);

            //foreach (int i in new int[] { 1 })
            //{
            //    var Quad = boundaryFactory3D.CreateElement(CellType.Quad4, face[i - 1]);
            //    var faceElement = new Element();
            //    faceElement.ID = i;
            //    faceElement.ElementType = Quad;
            //    foreach (Node node in face[i - 1])
            //    {
            //        faceElement.AddNode(node);
            //    }
            //    model.SubdomainsDictionary[0].Elements.Add(faceElement);
            //    model.ElementsDictionary.Add(i, faceElement);

            //    var dirichletElement = dirichletFactory1.CreateElement(CellType.Quad4, face[i - 1]);
            //    //var fluxElement = fluxFactory.CreateElement(CellType.Quad4, face[i - 1]);

            //    model.SurfaceLoads.Add(dirichletElement);
            //    //model.SurfaceLoads.Add(fluxElement);
            //}

            foreach (int i in new int[] { 0 })
            {
                //var Quad = boundaryFactory3D.CreateElement(CellType.Quad4, face[i]);
                //var faceElement = new Element();
                //faceElement.ID = 1;
                //faceElement.ElementType = Quad;
                //foreach (Node node in face[i])
                //{
                //    faceElement.AddNode(node);
                //}
                //model.SubdomainsDictionary[0].Elements.Add(faceElement);
                //model.ElementsDictionary.Add(1, faceElement);

                //var dirichletElement = dirichletFactory2.CreateElement(CellType.Quad4, face[i]);
                //model.SurfaceLoads.Add(dirichletElement);

                var fluxElement = fluxFactory1.CreateElement(CellType.Quad4, face[i]);
                model.SurfaceLoads.Add(fluxElement);
            }

            foreach (int i in new int[] { 1 })
            {
                //var Quad = boundaryFactory3D.CreateElement(CellType.Quad4, face[i]);
                //var faceElement = new Element();
                //faceElement.ID = 2;
                //faceElement.ElementType = Quad;
                //foreach (Node node in face[i])
                //{
                //    faceElement.AddNode(node);
                //}
                //model.SubdomainsDictionary[0].Elements.Add(faceElement);
                //model.ElementsDictionary.Add(2, faceElement);

                //var dirichletElement = dirichletFactory2.CreateElement(CellType.Quad4, face[i]);
                //model.SurfaceLoads.Add(dirichletElement);

                var fluxElement = fluxFactory2.CreateElement(CellType.Quad4, face[i]);
                model.SurfaceLoads.Add(fluxElement);
            }

            //constraints
            //foreach (int i in new int[] { 4, 5, 6, 7 })
            //{
            //    model.NodesDictionary[i].Constraints.Add(new Constraint()
            //    {
            //        Amount = 0,
            //        DOF = ThermalDof.Temperature
            //    });
            //}

            //// loads
            //Load load1;
            //foreach (int i in new int[] {0, 1, 2, 3})
            //{
            //    load1 = new Load()
            //    {
            //        Node = model.NodesDictionary[i],
            //        DOF = ThermalDof.Temperature,
            //        Amount = 12.5
            //    };
            //    model.Loads.Add(load1);
            //}


            return(model);
        }
        private static Tuple <Model, IModelReader> CreateStructuralModel(double C1, double C2, IDynamicMaterial commonDynamicMaterialProperties, double b, double[] l)
        {
            string filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "9hexa.mphtxt");
            var    modelReader = new ComsolMeshReader1(filename, C1, C2, 1, commonDynamicMaterialProperties);
            Model  model       = modelReader.CreateModelFromFile();
            //Boundary Conditions
            var lx = l[0];
            var ly = l[1];
            var lz = l[2];
            var distributedLoad = new DistributedLoad(lx, ly, lz);
            //var flux2 = new FluxLoad(f2);
            //var dir1 = new DirichletDistribution(list => {
            //    return Vector.CreateWithValue(list.Count, b1);
            //});
            //var dir2 = new DirichletDistribution(list => {
            //    return Vector.CreateWithValue(list.Count, b2);
            //});
            //var weakDirichlet1 = new WeakDirichlet(dir1, k);
            //var weakDirichlet2 = new WeakDirichlet(dir2, k);

            //var dirichletFactory1 = new SurfaceLoadElementFactory(weakDirichlet1);
            //var dirichletFactory2 = new SurfaceLoadElementFactory(weakDirichlet2);
            var distributedLoadFactory = new SurfaceLoadElementFactory(distributedLoad);

            //var fluxFactory2 = new SurfaceLoadElementFactory(flux2);
            //var boundaryFactory3D = new SurfaceBoundaryFactory3D(0,
            //    new ConvectionDiffusionMaterial(k, new double[] { 0, 0, 0 }, 0));


            int[] boundaryIDs = new int[] { 0, };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    foreach (Node node in nodes)
                    {
                        node.Constraints.Add(new Constraint()
                        {
                            Amount = b,
                            DOF    = StructuralDof.TranslationX
                        });
                        node.Constraints.Add(new Constraint()
                        {
                            Amount = b,
                            DOF    = StructuralDof.TranslationY
                        });
                        node.Constraints.Add(new Constraint()
                        {
                            Amount = b,
                            DOF    = StructuralDof.TranslationZ
                        });
                    }
                }
            }
            boundaryIDs = new int[] { 5 };
            int QuadID = model.ElementsDictionary.Count + 1;

            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    var distributedLoadElement = distributedLoadFactory.CreateElement(CellType.Quad4, nodes);
                    model.SurfaceLoads.Add(distributedLoadElement);
                    //var dirichletElement2 = dirichletFactory2.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(dirichletElement2);
                    //var SurfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Quad4, nodes);
                    //var element = new Element();
                    //element.ID = QuadID;
                    //element.ElementType = SurfaceBoundaryElement;
                    //model.SubdomainsDictionary[0].Elements.Add(element);
                    //model.ElementsDictionary.Add(QuadID, element);
                    //foreach (Node node in nodes)
                    //{
                    //    element.AddNode(node);
                    //}
                    //QuadID += 1;
                }
            }
            return(new Tuple <Model, IModelReader>(model, modelReader));
        }
示例#10
0
        private static Tuple <Model, ComsolMeshReader2> CreateModel(double k, double[] U, double L)
        {
            string            filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "fullModel.mphtxt");
            ComsolMeshReader2 modelReader = new ComsolMeshReader2(filename, new double[] { k }, new double[][] { U }, new double[] { L });
            Model             model       = modelReader.CreateModelFromFile();
            //Boundary Conditions
            var bodyLoad = new ConvectionDiffusionDomainLoad(new ConvectionDiffusionMaterial(k, U, L), 1, ThermalDof.Temperature);
            var flux1    = new FluxLoad(1);
            var flux2    = new FluxLoad(10);
            var dir1     = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, 1));
            });
            var dir2 = new DirichletDistribution(list => {
                return(Vector.CreateWithValue(list.Count, 0));
            });
            var weakDirichlet1 = new WeakDirichlet(dir1, k);
            var weakDirichlet2 = new WeakDirichlet(dir2, k);

            var bodyLoadElementFactory = new BodyLoadElementFactory(bodyLoad, model);
            var dirichletFactory1      = new SurfaceLoadElementFactory(weakDirichlet1);
            var dirichletFactory2      = new SurfaceLoadElementFactory(weakDirichlet2);
            var fluxFactory1           = new SurfaceLoadElementFactory(flux1);
            var fluxFactory2           = new SurfaceLoadElementFactory(flux2);
            var boundaryFactory3D      = new SurfaceBoundaryFactory3D(0,
                                                                      new ConvectionDiffusionMaterial(k, new double[] { 0, 0, 0 }, 0));

            int[] domainIDs = new int[] { 0, };
            foreach (int domainID in domainIDs)
            {
                foreach (Element element in modelReader.elementDomains[domainID])
                {
                    //IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
                    //var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(fluxElement1);
                    //var bodyLoadElementCellType = element.ElementType.CellType;
                    //var nodes = (IReadOnlyList<Node>)element.Nodes;
                    //var bodyLoadElement = bodyLoadElementFactory.CreateElement(CellType.Hexa8, nodes);
                    //model.BodyLoads.Add(bodyLoadElement);
                    // var surfaceElement = new SurfaceLoadElement();
                    //element.ID = TriID;
                    //surfaceElement.ElementType = DirichletElement1;
                    //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //model.ElementsDictionary.Add(TriID, surfaceElement);

                    //model.NodesDictionary[surfaceElement.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 100 });
                }
            }

            //foreach (Node node in model.Nodes)
            //{
            //    model.Loads.Add(new Load() { Amount = .25, Node = node, DOF = ThermalDof.Temperature });
            //}

            int[] boundaryIDs = new int[] { 0, 1, 2, 3, 4, 7 };
            int   TriID       = model.ElementsDictionary.Count + 1;

            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.triBoundaries[boundaryID])
                {
                    //IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
                    //var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(fluxElement1);
                    var dirichletElement1 = dirichletFactory1.CreateElement(CellType.Tri3, nodes);
                    model.SurfaceLoads.Add(dirichletElement1);
                    var surfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Tri3, nodes);
                    var element = new Element();
                    element.ID          = TriID;
                    element.ElementType = surfaceBoundaryElement;
                    model.SubdomainsDictionary[0].Elements.Add(element);
                    model.ElementsDictionary.Add(TriID, element);
                    foreach (Node node in nodes)
                    {
                        element.AddNode(node);
                    }
                    TriID += 1;
                    // var surfaceElement = new SurfaceLoadElement();
                    //element.ID = TriID;
                    //surfaceElement.ElementType = DirichletElement1;
                    //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //model.ElementsDictionary.Add(TriID, surfaceElement);

                    //model.NodesDictionary[surfaceElement.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 100 });
                }
            }
            boundaryIDs = new int[] { 6, 8, 9 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.triBoundaries[boundaryID])
                {
                    //IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
                    //var fluxElement2 = fluxFactory2.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(fluxElement2);
                    var dirichletElement2 = dirichletFactory2.CreateElement(CellType.Tri3, nodes);
                    model.SurfaceLoads.Add(dirichletElement2);
                    var surfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Tri3, nodes);
                    var element = new Element();
                    element.ID          = TriID;
                    element.ElementType = surfaceBoundaryElement;
                    model.SubdomainsDictionary[0].Elements.Add(element);
                    model.ElementsDictionary.Add(TriID, element);
                    foreach (Node node in nodes)
                    {
                        element.AddNode(node);
                    }
                    TriID += 1;
                    // var surfaceElement = new SurfaceLoadElement();
                    //element.ID = TriID;
                    //surfaceElement.ElementType = DirichletElement1;
                    //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //model.ElementsDictionary.Add(TriID, surfaceElement);

                    //model.NodesDictionary[surfaceElement.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 100 });
                }
            }

            //boundaryIDs = new int[] { 1, 2, 3, 4 };
            //foreach (int boundaryID in boundaryIDs)
            //{
            //    foreach (Element element in modelReader.elementBoundaries[boundaryID])
            //    {
            //        IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
            //        var fluxElement = fluxFactory.CreateElement(CellType.Quad4, nodes);
            //        model.SurfaceLoads.Add(fluxElement);
            //    }
            //}

            return(new Tuple <Model, ComsolMeshReader2>(model, modelReader));
        }
示例#11
0
        private static Tuple <Model, ComsolMeshReader3> CreateModel(double C1, double C0)
        {
            string            filename    = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "9hexa.mphtxt");
            ComsolMeshReader3 modelReader = new ComsolMeshReader3(filename, C1, C0);
            Model             model       = modelReader.CreateModelFromFile();
            //Boundary Conditions
            var bodyLoad = new ODEDomainLoad(new ODEMaterial(C1, C0), 1, ThermalDof.Temperature);
            var flux1    = new FluxLoad(1);
            var flux2    = new FluxLoad(10);
            var bodyLoadElementFactory = new BodyLoadElementFactory(bodyLoad, model);
            var fluxFactory1           = new SurfaceLoadElementFactory(flux1);
            var fluxFactory2           = new SurfaceLoadElementFactory(flux2);

            int[] domainIDs = new int[] { 0, };
            foreach (int domainID in domainIDs)
            {
                foreach (Element element in modelReader.elementDomains[domainID])
                {
                    //IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
                    //var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(fluxElement1);
                    //var bodyLoadElementCellType = element.ElementType.CellType;
                    var nodes           = (IReadOnlyList <Node>)element.Nodes;
                    var bodyLoadElement = bodyLoadElementFactory.CreateElement(CellType.Hexa8, nodes);
                    model.BodyLoads.Add(bodyLoadElement);
                    //var surfaceElement = new SurfaceLoadElement();
                    //element.ID = TriID;
                    //surfaceElement.ElementType = DirichletElement1;
                    //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //model.ElementsDictionary.Add(TriID, surfaceElement);

                    //model.NodesDictionary[surfaceElement.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 100 });
                }
            }
            int[] boundaryIDs = new int[] { 0, };
            int   QuadID      = model.ElementsDictionary.Count + 1;

            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    //IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
                    //var fluxElement1 = fluxFactory1.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(fluxElement1);
                    //var dirichletElement1 = dirichletFactory1.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(dirichletElement1);
                    //var surfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Quad4, nodes);
                    //var element = new Element();
                    //element.ID = QuadID;
                    //element.ElementType = surfaceBoundaryElement;
                    //model.SubdomainsDictionary[0].Elements.Add(element);
                    //model.ElementsDictionary.Add(QuadID, element);
                    //foreach (Node node in nodes)
                    //{
                    //    element.AddNode(node);
                    //}
                    //QuadID += 1;
                    // var surfaceElement = new SurfaceLoadElement();
                    //element.ID = TriID;
                    //surfaceElement.ElementType = DirichletElement1;
                    //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //model.ElementsDictionary.Add(TriID, surfaceElement);
                }
                //foreach (Node node in modelReader.nodeBoundaries[boundaryID])
                //{
                //    model.NodesDictionary[node.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 0 });
                //}
            }
            boundaryIDs = new int[] { 5 };
            foreach (int boundaryID in boundaryIDs)
            {
                foreach (IReadOnlyList <Node> nodes in modelReader.quadBoundaries[boundaryID])
                {
                    //IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
                    //var fluxElement2 = fluxFactory2.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(fluxElement2);
                    //var dirichletElement2 = dirichletFactory2.CreateElement(CellType.Quad4, nodes);
                    //model.SurfaceLoads.Add(dirichletElement2);
                    //var surfaceBoundaryElement = boundaryFactory3D.CreateElement(CellType.Quad4, nodes);
                    //var element = new Element();
                    //element.ID = QuadID;
                    //element.ElementType = surfaceBoundaryElement;
                    //model.SubdomainsDictionary[0].Elements.Add(element);
                    //model.ElementsDictionary.Add(QuadID, element);
                    //foreach (Node node in nodes)
                    //{
                    //    element.AddNode(node);
                    //}
                    //QuadID += 1;
                    // var surfaceElement = new SurfaceLoadElement();
                    //element.ID = TriID;
                    //surfaceElement.ElementType = DirichletElement1;
                    //model.SubdomainsDictionary[0].Elements.Add(dirichletElement1);
                    //model.ElementsDictionary.Add(TriID, surfaceElement);
                }
                //foreach (Node node in modelReader.nodeBoundaries[boundaryID])
                //{
                //    model.NodesDictionary[node.ID].Constraints.Add(new Constraint() { DOF = ThermalDof.Temperature, Amount = 0 });
                //}
            }

            //boundaryIDs = new int[] { 1, 2, 3, 4 };
            //foreach (int boundaryID in boundaryIDs)
            //{
            //    foreach (Element element in modelReader.elementBoundaries[boundaryID])
            //    {
            //        IReadOnlyList<Node> nodes = (IReadOnlyList<Node>)element.Nodes;
            //        var fluxElement = fluxFactory.CreateElement(CellType.Quad4, nodes);
            //        model.SurfaceLoads.Add(fluxElement);
            //    }
            //}

            return(new Tuple <Model, ComsolMeshReader3>(model, modelReader));
        }