示例#1
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);
        }
        private void CreateMesh()
        {
            Model.Subdomains.Add(subdomainID, new XSubdomain(subdomainID));

            // 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
            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(E, v);
            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);
                Model.Subdomains[subdomainID].Elements.Add(Model.Elements[e]);
            }

            // Mesh usable for crack-mesh interaction
            var boundary = new HolesBoundary();

            Model.Boundary = boundary;
            Mesh           = new BidirectionalMesh2D <XNode, XContinuumElement2D>(Model.Nodes, cells, boundary);
        }
        private static XContinuumElement2D CreateMaterialInterfaceElement()
        {
            XNode[] nodes = new XNode[]
            {
                new XNode(0, 20.0, 0.0),
                new XNode(1, 40.0, 0.0),
                new XNode(2, 40.0, 20.0),
                new XNode(3, 20.0, 20.0),
            };

            var                 point1         = new CartesianPoint(30.0, 0.0);
            var                 point2         = new CartesianPoint(30.0, 20.0);
            PolyLine2D          discontinuity  = new PolyLine2D(point1, point2);
            MaterialInterface2D enrichmentItem = new MaterialInterface2D(discontinuity);

            double E1       = 2E6;
            double E2       = 0.5 * E1;
            double v        = 0.3;
            var    material = BiElasticMaterial2D.CreateMaterialForPlainStrain(E1, v, E2, v, enrichmentItem);

            var integrationStrategy = new RectangularSubgridIntegration2D <XContinuumElement2D>(
                2, GaussLegendre2D.GetQuadratureWithOrder(2, 2));

            //var integrationStrategy = new IntegrationForCrackPropagation2D(GaussLegendre2D.Order2x2,
            //    new RectangularSubgridIntegration2D<XContinuumElement2D>(2, GaussLegendre2D.Order2x2));
            var factory = new XContinuumElement2DFactory(integrationStrategy, integrationStrategy, material);
            var element = factory.CreateElement(0, CellType.Quad4, nodes);

            //discontinuity.ElementIntersections.Add(element, new CartesianPoint2D[] { point1, point2 });

            //OBSOLETE: Elements access their enrichments from nodes now.
            //enrichmentItem.EnrichElement(element);
            enrichmentItem.EnrichNode(nodes[0]);
            enrichmentItem.EnrichNode(nodes[1]);
            enrichmentItem.EnrichNode(nodes[2]);
            enrichmentItem.EnrichNode(nodes[3]);

            return(element);
        }