private static Tuple <Model, IModelReader> CreateCancerTransportModel(double[] k, double[][] U, double[] TumcElement) { string filename = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "mesh.mphtxt"); var modelReader = new ComsolMeshReader2(filename, k, U, L); Model model = modelReader.CreateModelFromFile(); var materials = new ConvectionDiffusionMaterial[] { new ConvectionDiffusionMaterial(k[0], U[0], L[0]), new ConvectionDiffusionMaterial(k[1], U[1], L[1]) }; if (TumcElement == null) { TumcElement = new double[model.Elements.Count]; for (int i = 0; i < model.Elements.Count; i++) { TumcElement[i] = 0.96; } } double[] f = new double[model.Elements.Count]; int domainID = 1; foreach (Element element in modelReader.elementDomains[domainID]) { f[element.ID] = 1; var nodes = (IReadOnlyList <Node>)element.Nodes; var domainLoad = new ConvectionDiffusionDomainLoad(materials[domainID], f[element.ID], ThermalDof.Temperature); var bodyLoadElementFactory = new BodyLoadElementFactory(domainLoad, model); var bodyLoadElement = bodyLoadElementFactory.CreateElement(CellType.Tet4, nodes); model.BodyLoads.Add(bodyLoadElement); } return(new Tuple <Model, IModelReader>(model, modelReader)); }
private static Tuple <Model, IModelReader> CreateGrowthModel(double k, double[] U, double L, double[] lgr) { string filename = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "mesh.mphtxt"); var modelReader = new ComsolMeshReader2(filename, new double[] { k, k }, new double[][] { U, U }, new double[] { L, 0 }); Model model = modelReader.CreateModelFromFile(); if (lgr == null) { lgr = new double[model.Elements.Count]; for (int i = 0; i < model.Elements.Count; i++) { lgr[i] = 1; } } if (c_oxElement == null) { c_oxElement = new double[model.Elements.Count]; for (int i = 0; i < model.Elements.Count; i++) { c_oxElement[i] = 0;/* 0.9673;*/ } } var materialODE = new ConvectionDiffusionMaterial(k, U, L); double[] Grox = new double[model.Elements.Count]; double[] fg = new double[model.Elements.Count]; int[] domainIDs = new int[] { 0, }; foreach (int domainID in domainIDs) { foreach (Element element in modelReader.elementDomains[domainID]) { Grox[element.ID] = (loxc[domainID] * cvox * c_oxElement[element.ID]) / (cvox * c_oxElement[element.ID] + Koxc[domainID]); fg[element.ID] = 24d * 3600d * Grox[element.ID] * lgr[element.ID] / 3d; var nodes = (IReadOnlyList <Node>)element.Nodes; var domainLoad = new ConvectionDiffusionDomainLoad(materialODE, fg[element.ID], ThermalDof.Temperature); var bodyLoadElementFactory = new BodyLoadElementFactory(domainLoad, model); var bodyLoadElement = bodyLoadElementFactory.CreateElement(CellType.Tet4, nodes); model.BodyLoads.Add(bodyLoadElement); } } return(new Tuple <Model, IModelReader>(model, modelReader)); }
private static Tuple <Model, IModelReader> CreateOxygenTransportModel(double[] k, double[][] U, double[] L, double[] coxElement) { string filename = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "mesh.mphtxt"); var modelReader = new ComsolMeshReader2(filename, k, U, L); Model model = modelReader.CreateModelFromFile(); var materials = new ConvectionDiffusionMaterial[] { new ConvectionDiffusionMaterial(k[0], U[0], L[0]), new ConvectionDiffusionMaterial(k[1], U[1], L[1]) }; if (coxElement == null) { coxElement = new double[model.Elements.Count]; for (int i = 0; i < model.Elements.Count; i++) { coxElement[i] = 0;/* 0.9673;*/ } } double[] fox = new double[model.Elements.Count]; int[] domainIDs = new int[] { 0, 1 }; foreach (int domainID in domainIDs) { foreach (Element element in modelReader.elementDomains[domainID]) { if (domainID == 0) { fox[element.ID] = (Dox[domainID] / Lwv * 7e3 - ((Aox[domainID] * coxElement[element.ID]) / (kox[domainID] + coxElement[element.ID] * cvox)) * 0.3) * (24d * 3600d); } else { fox[element.ID] = Dox[domainID] / Lwv * 7e3 * (24d * 3600d); } var nodes = (IReadOnlyList <Node>)element.Nodes; var domainLoad = new ConvectionDiffusionDomainLoad(materials[domainID], fox[element.ID], ThermalDof.Temperature); var bodyLoadElementFactory = new BodyLoadElementFactory(domainLoad, model); var bodyLoadElement = bodyLoadElementFactory.CreateElement(CellType.Tet4, nodes); model.BodyLoads.Add(bodyLoadElement); } } 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)); }
private static Tuple <Model, IModelReader> CreateOxygenTransportModel(double[] k, double[][] U, double[] L, double[] cox) { string filename = Path.Combine(Directory.GetCurrentDirectory(), "InputFiles", "TumorGrowthModel", "mesh.mphtxt"); var modelReader = new ComsolMeshReader2(filename, k, U, L); Model model = modelReader.CreateModelFromFile(); var materials = new ConvectionDiffusionMaterial[] { new ConvectionDiffusionMaterial(k[0], U[0], L[0]), new ConvectionDiffusionMaterial(k[1], U[1], L[1]) }; //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)); if (cox == null) { cox = new double[model.Nodes.Count]; for (int i = 0; i < model.Nodes.Count; i++) { cox[i] = 0;/* 0.9673;*/ } } double[] fox = new double[model.Elements.Count]; int[] domainIDs = new int[] { 0, 1 }; var coxElement = new double[model.Elements.Count]; foreach (var e in model.Elements) { coxElement[e.ID] = 0; for (int i = 0; i < e.Nodes.Count; i++) { coxElement[e.ID] += cox[i] / (e.Nodes.Count); } } foreach (int domainID in domainIDs) { //foreach (Element element in modelReader.nodeDomains[domainID]) //{ // if (domainID == 0) // { // fox[element.ID] = (Dox[domainID]/Lwv * (1 - coxElement[element.ID])-((Aox[domainID]* coxElement[element.ID])/(kox[domainID]+ coxElement[element.ID]*cvox))*0.3)*(24d * 3600d); // } // else // { // fox[element.ID] = Dox[domainID] / Lwv * (1 - cox[element.ID])*(24d*3600d); // } // model.Loads.Add(new Load() { Node = element, DOF = ThermalDof.Temperature, Amount = fox[element.ID] }); //} 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); if (domainID == 0) { fox[element.ID] = (Dox[domainID] / Lwv * 7e3 - ((Aox[domainID] * coxElement[element.ID]) / (kox[domainID] + coxElement[element.ID] * cvox)) * 0.3) * (24d * 3600d); } else { fox[element.ID] = Dox[domainID] / Lwv * 7e3 * (24d * 3600d); } var nodes = (IReadOnlyList <Node>)element.Nodes; var domainLoad = new ConvectionDiffusionDomainLoad(materials[domainID], fox[element.ID], ThermalDof.Temperature); var bodyLoadElementFactory = new BodyLoadElementFactory(domainLoad, model); var bodyLoadElement = bodyLoadElementFactory.CreateElement(CellType.Tet4, 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)); }
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)); }
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)); }