GenerateMeshFromGmsh(string path) { using (var reader = new GmshReader <Node>(path)) { return(reader.CreateMesh((id, x, y, z) => new Node(id: id, x: x, y: y, z: z))); } }
private static (IReadOnlyList <Node> nodes, IReadOnlyList <CellConnectivity <Node> > elements) GenerateMeshFromGmsh(string path) { using (var reader = new GmshReader <Node>(path)) { return(reader.CreateMesh((id, x, y, z) => new Node(id: id, x: x, y: y, z: z))); } }
private static void SolveDynamicLinearWall() { // Some values string workingDirectory = @"C:\Users\Serafeim\Desktop\Presentation"; double thickness = 0.1; double youngModulus = 2E6; double poissonRatio = 0.3; // Initialize model PreprocessorModel model = PreprocessorModel.Create2DPlaneStress(thickness); // Materials ElasticMaterial2D material = new ElasticMaterial2D(StressState2D.PlaneStress) { YoungModulus = youngModulus, PoissonRatio = poissonRatio }; DynamicMaterial dynamicProperties = new DynamicMaterial(25, 0.05, 0.05, true); // Read mesh from GMSH file string meshPath = workingDirectory + "\\wall.msh"; IReadOnlyList <Node> nodes; IReadOnlyList <CellConnectivity <Node> > elements; using (var reader = new GmshReader <Node>(meshPath)) { (nodes, elements) = reader.CreateMesh((id, x, y, z) => new Node(id: id, x: x, y: y, z: z)); } model.AddMesh2D(nodes, elements, material, dynamicProperties); // Prescribed displacements double tol = 1E-10; IEnumerable <Node> constrainedNodes = nodes.Where(node => Math.Abs(node.Y) <= tol); model.ApplyPrescribedDisplacements(constrainedNodes, StructuralDof.TranslationX, 0.0); model.ApplyPrescribedDisplacements(constrainedNodes, StructuralDof.TranslationY, 0.0); // Loads string accelerogramPath = workingDirectory + "\\elcentro_NS.txt"; Dictionary <IDofType, double> magnifications = new Dictionary <IDofType, double> { { StructuralDof.TranslationX, 1.0 } }; model.SetGroundMotion(accelerogramPath, magnifications, 0.02, 53.74); // Define output OutputRequests output = new OutputRequests(workingDirectory + "\\Plots"); output.Displacements = true; output.Strains = true; output.Stresses = true; output.StressesVonMises = true; // Set up the simulation procedure Job job = new Job(model); job.Procedure = Job.ProcedureOptions.DynamicImplicit; job.Integrator = Job.IntegratorOptions.Linear; job.Solver = Job.SolverOptions.DirectSkyline; job.FieldOutputRequests = output; // Run the simulation job.Submit(); }
private static void SolveStaticLinearWall() { // Some values string workingDirectory = @"C:\Users\Serafeim\Desktop\Presentation"; double height = 3.5; double thickness = 0.1; double youngModulus = 2E6; double poissonRatio = 0.3; double horizontalLoad = 1000.0; // Initialize model PreprocessorModel model = PreprocessorModel.Create2DPlaneStress(thickness); // Materials ElasticMaterial2D material = new ElasticMaterial2D(StressState2D.PlaneStress) { YoungModulus = youngModulus, PoissonRatio = poissonRatio }; // Read mesh from GMSH file string meshPath = workingDirectory + "\\wall.msh"; IReadOnlyList <Node> nodes; IReadOnlyList <CellConnectivity <Node> > elements; using (var reader = new GmshReader <Node>(meshPath)) { (nodes, elements) = reader.CreateMesh((id, x, y, z) => new Node(id: id, x: x, y: y, z: z)); } model.AddMesh2D(nodes, elements, material); // Prescribed displacements double tol = 1E-10; IEnumerable <Node> constrainedNodes = nodes.Where(node => Math.Abs(node.Y) <= tol); model.ApplyPrescribedDisplacements(constrainedNodes, StructuralDof.TranslationX, 0.0); model.ApplyPrescribedDisplacements(constrainedNodes, StructuralDof.TranslationY, 0.0); // Loads Node[] loadedNodes = nodes.Where( node => (Math.Abs(node.Y - height) <= tol) && ((Math.Abs(node.X) <= tol))).ToArray(); if (loadedNodes.Length != 1) { throw new Exception("Only 1 node was expected at the top left corner"); } model.ApplyNodalLoad(loadedNodes[0], StructuralDof.TranslationX, horizontalLoad); // Define output OutputRequests output = new OutputRequests(workingDirectory + "\\Plots"); output.Displacements = true; output.Strains = true; output.Stresses = true; output.StressesVonMises = true; // Set up the simulation procedure Job job = new Job(model); job.Procedure = Job.ProcedureOptions.Static; job.Integrator = Job.IntegratorOptions.Linear; job.Solver = Job.SolverOptions.DirectSkyline; job.FieldOutputRequests = output; // Run the simulation job.Submit(); }
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 (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); }