Exemple #1
0
        public BidirectionalMesh2D(IReadOnlyList <TNode> vertices, IReadOnlyList <TElement> faces, IDomain2DBoundary boundary)
        {
            this.Nodes    = vertices;
            this.Elements = faces;
            this.boundary = boundary;

            // Connect cells to vertices
            var connectivity = new Dictionary <TNode, HashSet <TElement> >();

            foreach (var cell in Elements)
            {
                foreach (var vertex in cell.Nodes)
                {
                    bool exists = connectivity.TryGetValue(vertex, out HashSet <TElement> vertexCells);
                    if (exists)
                    {
                        vertexCells.Add(cell);
                    }
                    else
                    {
                        vertexCells = new HashSet <TElement>();
                        vertexCells.Add(cell);
                        connectivity.Add(vertex, vertexCells);
                    }
                }
            }
            this.nodeConnectivity = connectivity;
        }
Exemple #2
0
        private static (XModel model, IMesh2D <XNode, XContinuumElement2D> mesh) CreateModel(string meshPath)
        {
            // Mesh generation
            var reader = new GmshReader <XNode>(meshPath);

            (IReadOnlyList <XNode> nodes, IReadOnlyList <CellConnectivity <XNode> > elementConnectivities) = reader.CreateMesh(
                (id, x, y, z) => new XNode(id, x, y, z));

            // Nodes
            var model = new XModel();

            foreach (XNode node in nodes)
            {
                model.Nodes.Add(node);
            }

            // Integration rules
            var integration = new IntegrationForCrackPropagation2D(
                new RectangularSubgridIntegration2D <XContinuumElement2D>(8, GaussLegendre2D.GetQuadratureWithOrder(2, 2)),
                new RectangularSubgridIntegration2D <XContinuumElement2D>(8, GaussLegendre2D.GetQuadratureWithOrder(2, 2)));
            var jIntegration =
                new RectangularSubgridIntegration2D <XContinuumElement2D>(8, GaussLegendre2D.GetQuadratureWithOrder(4, 4));

            // Elements
            var material = HomogeneousElasticMaterial2D.CreateMaterialForPlaneStrain(2.1E7, 0.3);
            var factory  = new XContinuumElement2DFactory(integration, jIntegration, material);
            var cells    = new XContinuumElement2D[elementConnectivities.Count];

            for (int e = 0; e < cells.Length; ++e)
            {
                XContinuumElement2D element = factory.CreateElement(e, CellType.Quad4, elementConnectivities[e].Vertices);
                cells[e] = element;
                model.Elements.Add(element);
            }

            // Mesh usable for crack-mesh interaction
            //var boundary = new FilletBoundary();
            IDomain2DBoundary boundary = null;

            model.Boundary = boundary;
            var mesh = new BidirectionalMesh2D <XNode, XContinuumElement2D>(model.Nodes, cells, boundary);

            return(model, mesh);
        }
 public SimpleMesh2D(IReadOnlyList <TNode> vertices, IReadOnlyList <TElement> faces, IDomain2DBoundary boundary)
 {
     this.Nodes    = vertices;
     this.Elements = faces;
     this.boundary = boundary;
 }