Пример #1
0
        public static Mesh Triangulate(this SectionDefinition sec, Polygon polygon)
        {
            var options = new ConstraintOptions();

            options.ConformingDelaunay = true;
            var quality = new QualityOptions()
            {
                MinimumAngle = sec.SolutionSettings.MinimumAngle,
                MaximumAngle = sec.SolutionSettings.MaximumAngle,
                MaximumArea  = sec.SolutionSettings.MaximumArea
            };

            //=======temp meshing to find some data
            var dummyMesh = (Mesh)polygon.Triangulate();

            if (sec.SolutionSettings.MaximumArea == 0.0)
            {
                //auto calc
                var area = CalculateMeshArea(dummyMesh);
                quality.MaximumArea = sec.SolutionSettings.Roughness * area;
            }
            //\=========

            var mesh = (Mesh)polygon.Triangulate(options, quality);


            return(mesh);
        }
Пример #2
0
 public Response <SectionDefinition> CreateSection([FromBody] SectionDefinition section)
 {
     return(GetResponse(() =>
     {
         return new EditorService(User).CreateSection(section);
     }));
 }
Пример #3
0
        private void GeomAnalysis(SectionDefinition sec, Mesh mesh)
        {
            foreach (var item in mesh.Triangles)
            {
                var mat = sec.Contours.First(c => c.Material?.Id == item.Label).Material;
                var e   = mat.elastic_modulus;
                var g   = mat.shear_modulus;

                var(area, qx, qy, ixx, iyy, ixy) = _fea.geometric_properties(item.GetTriCoords());

                sec.Output.SectionProperties.Area  += area;
                sec.Output.SectionProperties.ea    += area * e;
                sec.Output.SectionProperties.ga    += area * g;
                sec.Output.SectionProperties.qx    += qx * e;
                sec.Output.SectionProperties.qy    += qy * e;
                sec.Output.SectionProperties.ixx_g += ixx * e;
                sec.Output.SectionProperties.iyy_g += iyy * e;
                sec.Output.SectionProperties.ixy_g += ixy * e;
            }

            sec.Output.SectionProperties.nu_eff = sec.Output.SectionProperties.ea / (
                2 * sec.Output.SectionProperties.ga) - 1;
            calculate_elastic_centroid(sec);
            calculate_centroidal_properties(sec, mesh);
        }
Пример #4
0
        private void calculate_elastic_centroid(SectionDefinition sec)
        {
            SectionProperties sectionProperties = sec.Output.SectionProperties;

            sectionProperties.cx = sectionProperties.qy / sectionProperties.ea;
            sectionProperties.cy = sectionProperties.qx / sectionProperties.ea;
        }
Пример #5
0
        public void CustomSec3_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(CustomSec3_Test));

            sec.SolutionSettings = new SolutionSettings(0.002);

            sec.Contours.Add(new SectionContour(helper.CreateRectangle(300, 180), false, defaultMat));

            var c1 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c1.ShiftPoints(30, 30);
            var c2 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c2.ShiftPoints(150, 30);
            var c3 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c3.ShiftPoints(150, 270);
            var c4 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c4.ShiftPoints(30, 270);

            sec.Contours.Add(c1);
            sec.Contours.Add(c2);
            sec.Contours.Add(c3);
            sec.Contours.Add(c4);

            _solver.Solve(sec);
            Compare(nameof(CustomSec3_Test), sec);
        }
Пример #6
0
        private void ProcessSectionDef(SectionDefinition directive)
        {
            this.builder.Append("private void ");
            this.builder.Append(directive.Name);
            this.builder.Append('(');

            for (int i = 0; i < directive.Parameters.Count; i++)
            {
                KeyValuePair <string, string> p = directive.Parameters[i];
                this.builder.Append(p.Value);
                this.builder.Append(' ');
                this.builder.Append(p.Key);
            }

            if (directive.Parameters.Count == 0)
            {
                this.builder.Append("string _spaces_, string writerKey");
            }
            else
            {
                this.builder.Append(", string _spaces_, string writerKey");
            }

            this.builder.AppendLine(") {");
            ProcessSectionDirectives(directive.Directives);
            this.builder.AppendLine("}");
            this.builder.AppendLine();
        }
Пример #7
0
        public static void WritePoly(this SectionDefinition sec, string filename)
        {
            var          poly = sec.BuildPolygon();
            TriangleFile fne  = new TriangleFile();

            fne.Write(poly, filename);
        }
Пример #8
0
        public void Solve(SectionDefinition sec, Mesh mesh)
        {
            _sec  = sec;
            _mesh = mesh;

            calculate_plastic_properties(sec, _mesh);
        }
Пример #9
0
        public void CompundSec_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(CompundSec_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);

            (List <Point2D> outer, List <Point2D> inner) = helper.CreateRhsShape(150, 100, 6, 15, 8);
            sec.Contours.Add(new SectionContour(outer, false, defaultMat));
            sec.Contours.Add(new SectionContour(inner, true, defaultMat));

            List <Point2D> points = new List <Point2D>();

            points.Add(new Point2D(0, 0));
            points.Add(new Point2D(50, 0));
            points.Add(new Point2D(25, 50));
            var triangle = new SectionContour(points, false, defaultMat);

            triangle.ShiftPoints(25, 150);
            sec.Contours.Add(triangle);

            var angle = new SectionContour(helper.CreateAngleShape(100, 100, 6, 8, 5, 8), false, defaultMat);

            angle.ShiftPoints(100, 25);
            sec.Contours.Add(angle);

            _solver.Solve(sec);
            Compare(nameof(CompundSec_Test), sec);
        }
Пример #10
0
        public void CustomSec1_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(CustomSec1_Test));

            sec.SolutionSettings = new SolutionSettings(0.002);

            List <Point2D> boundary = new List <Point2D>();

            boundary.Add(new Point2D(0, 0));
            boundary.Add(new Point2D(180, 0));
            boundary.Add(new Point2D(180, 120));
            boundary.Add(new Point2D(120, 120));
            boundary.Add(new Point2D(180, 300));
            boundary.Add(new Point2D(0, 300));

            List <Point2D> hole = new List <Point2D>();

            hole.Add(new Point2D(60, 60));
            hole.Add(new Point2D(120, 60));
            hole.Add(new Point2D(120, 120));
            hole.Add(new Point2D(60, 120));

            sec.Contours.Add(new SectionContour(boundary, false, defaultMat));
            sec.Contours.Add(new SectionContour(hole, true, null));

            _solver.Solve(sec);
            Compare(nameof(CustomSec1_Test), sec);
        }
Пример #11
0
        /// <summary>
        /// Calculates the locations of the extreme fibres along and perpendicular to the axis specified by 'angle'
        /// </summary>
        /// <param name="angle">Angle(in radians) along which to calculate the extreme fibre locations</param>
        /// <returns>The location of the extreme fibres parallel(u) and perpendicular(v) to the axis * (u_min, u_max, v_min, v_max) *</returns>
        private (double u_min, double u_max, double v_min, double v_max) calculate_extreme_fibres
            (SectionDefinition sec, Mesh mesh, double angle)
        {
            var u_max      = 0.0;
            var u_min      = 0.0;
            var v_max      = 0.0;
            var v_min      = 0.0;
            var initialise = true;

            foreach (var pt in mesh.Vertices)
            {
                var x = pt.X;
                var y = pt.Y;
                // determine the coordinate of the point wrt the principal axis
                var(u, v) = _fea.principal_coordinate(angle, x, y);

                //// initialise min, max variables
                if (initialise)
                {
                    u_max      = u;
                    u_min      = u;
                    v_max      = v;
                    v_min      = v;
                    initialise = false;
                }

                //// update the mins and maxs where necessary
                u_max = Math.Max(u_max, u);
                u_min = Math.Min(u_min, u);
                v_max = Math.Max(v_max, v);
                v_min = Math.Min(v_min, v);
            }

            return(u_min, u_max, v_min, v_max);
        }
Пример #12
0
        public void TwoSectionDefinition()
        {
            AtParser parser = new AtParser();

            parser.Reader = new StringReader(
                @"line1
@section sec
line2
@end_section
@section sec2
line3
line4
@end_section
");

            Intruder parserIntruder = new Intruder(parser);

            parserIntruder.CallMethod <object>("InitParsing");
            parserIntruder.CallMethod <object>("BuildAst");

            AtTemplateAst     ast      = parserIntruder.ReadField <AtTemplateAst>("ast");
            SectionDefinition section1 = (SectionDefinition)ast.Body.Directives[1];
            SectionDefinition section2 = (SectionDefinition)ast.Body.Directives[2];

            Assert.That(section1.Name, Is.EqualTo("sec"));
            Assert.That(section1.Directives.Count, Is.EqualTo(1));

            Assert.That(section2.Name, Is.EqualTo("sec2"));
            Assert.That(section2.Directives.Count, Is.EqualTo(2));
        }
Пример #13
0
        public static void WriteMesh(this SectionDefinition sec, string filename)
        {
            var          poly = sec.BuildPolygon();
            var          mesh = sec.Triangulate(poly);
            TriangleFile fne  = new TriangleFile();

            fne.Write(mesh, filename);
        }
Пример #14
0
        public void CeeSection_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(CeeSection_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);
            sec.Contours.Add(new SectionContour(helper.CreateCeeShape(200, 100, 75, 5, 10, 10), false, defaultMat));
            _solver.Solve(sec);
            Compare(nameof(CeeSection_Test), sec);
        }
Пример #15
0
        public void MonoISection_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(MonoISection_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);
            sec.Contours.Add(new SectionContour(helper.CreateMonoISection(150, 100, 20, 30, 15, 300, 250, 50, 20, 25, 10), false, defaultMat));
            _solver.Solve(sec);
            Compare(nameof(MonoISection_Test), sec);
        }
Пример #16
0
        private void Write(SectionDefinition sec, string folder)
        {
            var    secName  = !string.IsNullOrWhiteSpace(sec.Name) ? sec.Name : "unnamed";
            string fileName = System.IO.Path.Combine(folder, secName);

            sec.WritePoly(fileName + "_poly.poly");
            sec.WriteMesh(fileName + "_mesh");
            sec.Write(fileName + ".txt");
        }
Пример #17
0
        public void CircleSec_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(CircleSec_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);
            sec.Contours.Add(new SectionContour(helper.CreateCircle(25, 64), false, defaultMat));
            _solver.Solve(sec);
            Compare(nameof(CircleSec_Test), sec);
        }
Пример #18
0
 public Section(
     ContentItem contentItem,
     SectionDefinition definition,
     IReadOnlyDictionary <Path, ContentItem> contentItems)
 {
     _contentItem = contentItem;
     Definition   = definition;
     ContentItems = contentItems;
 }
Пример #19
0
        public void Ehs_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(Ehs_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);
            sec.Contours.Add(new SectionContour(helper.CreateEllipse(1, 150.0 / 2.0, 75.0 / 2.0, 100), false, defaultMat));
            sec.Contours.Add(new SectionContour(helper.CreateEllipse(1, 150.0 / 2.0 - 4.0, 75.0 / 2.0 - 4.0, 100), true, defaultMat));
            _solver.Solve(sec);
            Compare(nameof(Ehs_Test), sec);
        }
Пример #20
0
        public void AngleSec_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(AngleSec_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);
            sec.Contours.Add(new SectionContour(helper.CreateAngleShape(100, 100, 6, 8, 5, 8), false, defaultMat));
            sec.ShiftPoints(100, 25);
            _solver.Solve(sec);
            Compare(nameof(AngleSec_Test), sec);
        }
Пример #21
0
        public void ISec_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(ISec_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);
            SectionMaterial steel = new SectionMaterial("Steel", 1, 200e3, 0.3, 500);

            sec.Contours.Add(new SectionContour(helper.CreateIShape(304, 165, 10.2, 6.1, 11.4, 8), false, steel));
            _solver.Solve(sec);
            Compare(nameof(ISec_Test), sec);
        }
Пример #22
0
        public RowHeaderPageFormatBuilder AddSectionDefinition(string[] rowStrings)
        {
            if (rowStrings.Length != _rowDefinitions.Count)
            {
                throw new InvalidOperationException("Number of row strings in section definition must be equal to number of defined rows");
            }
            var secDef = new SectionDefinition {
                Sections = rowStrings.ToList()
            };

            _sectionDefinitions.Add(secDef);
            return(this);
        }
Пример #23
0
        public override string GetStepParameters()
        {
            var parameters = new List <string>();

            parameters.Add(LongitudinalStartPosition != null ? LongitudinalStartPosition.ToStepValue() : "$");
            parameters.Add(LongitudinalEndPosition != null ? LongitudinalEndPosition.ToStepValue() : "$");
            parameters.Add(TransversePosition != null ? TransversePosition.ToStepValue() : "$");
            parameters.Add(ReinforcementRole.ToStepValue());
            parameters.Add(SectionDefinition != null ? SectionDefinition.ToStepValue() : "$");
            parameters.Add(CrossSectionReinforcementDefinitions != null ? CrossSectionReinforcementDefinitions.ToStepValue() : "$");

            return(string.Join(", ", parameters.ToArray()));
        }
Пример #24
0
        Operation IParser.Parse(string[] lines)
        {
            Operation operation = new Operation();

            lines = Utilities.Trim(lines);

            // Remember the name of the section we are in
            SectionDefinition currentSection = null;

            for (int i = 0; i < lines.Length; i++)
            {
                try
                {
                    string line = lines[i];
                    if (line.Length == 0)
                    {
                        continue;
                    }

                    // Check if the line denotes a section start. In this case, skip this line but remember the section.
                    SectionDefinition newSection = null;
                    if (IsLineSectionMarker(line, out newSection))
                    {
                        currentSection = newSection;
                        continue;
                    }

                    // Check if we currently are in no section (this is the case when there is some jabber at the beginning we don't care about).
                    if (currentSection == null)
                    {
                        continue;
                    }

                    AreaDefinition area = null;
                    if (!IsLineAreaRelevant(line, currentSection, out area))
                    {
                        continue;
                    }

                    AreaLineInformation value = new AreaLineInformation(area, line);
                    WriteValueToOperation(value.Value, area, operation);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Warning, this, "Error while parsing line '{0}'. The error message was: {1}", i, ex.Message);
                }
            }

            return(operation);
        }
Пример #25
0
        private void Compare(string testName, SectionDefinition sec)
        {
            if (_writefiles)
            {
                Write(sec, _meshFileFolder);
            }

            JObject actual = BuildTestData(sec, testName);

            var     expected     = System.IO.File.ReadAllText($@"..\..\ExpectedData\{testName}.txt");
            JObject expectedJson = JsonConvert.DeserializeObject <JObject>(expected);

            Compare(expectedJson, actual);
        }
Пример #26
0
        private JObject BuildTestData(SectionDefinition sec, string testName, bool replaceExpected = false)
        {
            string  data   = JsonConvert.SerializeObject(sec.Output.SectionProperties);
            JObject actual = JsonConvert.DeserializeObject <JObject>(data);

            if (replaceExpected)
            {
                System.IO.File.WriteAllText($@"..\..\ExpectedData\{testName}.txt", JsonConvert.SerializeObject(actual, Formatting.Indented,
                                                                                                               new JsonSerializerSettings
                {
                    FloatParseHandling = FloatParseHandling.Double
                }));
            }
            return(actual);
        }
Пример #27
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting...");


            Stopwatch sw = new Stopwatch();

            sw.Start();

            Solver _solver = new Solver();
            ShapeGeneratorHelper helper = new ShapeGeneratorHelper();

            SectionMaterial defaultMat = new SectionMaterial("dummy", 1, 1.0, 0.0, 1.0);

            SectionDefinition sec = new SectionDefinition();

            sec.SolutionSettings = new SolutionSettings(0.002);

            sec.Contours.Add(new SectionContour(helper.CreateRectangle(300, 180), false, defaultMat));

            var c1 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c1.ShiftPoints(30, 30);
            var c2 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c2.ShiftPoints(150, 30);
            var c3 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c3.ShiftPoints(150, 270);
            var c4 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c4.ShiftPoints(30, 270);

            sec.Contours.Add(c1);
            sec.Contours.Add(c2);
            sec.Contours.Add(c3);
            sec.Contours.Add(c4);

            _solver.Solve(sec);

            Console.WriteLine(sec.Output.SectionProperties.j.ToString());

            sw.Stop();

            Console.WriteLine("Elapsed={0}", sw.Elapsed);

            Console.ReadLine();
        }
Пример #28
0
        public void WithParameters(string code, int paramCount)
        {
            AtParser parser = new AtParser();

            parser.Reader = new StringReader(code);

            Intruder parserIntruder = new Intruder(parser);

            parserIntruder.CallMethod <object>("InitParsing");
            parserIntruder.CallMethod <object>("BuildAst");

            AtTemplateAst     ast     = parserIntruder.ReadField <AtTemplateAst>("ast");
            SectionDefinition section = (SectionDefinition)ast.Body.Directives[0];

            Assert.That(section.Name, Is.EqualTo("Foo"));
            Assert.That(section.Parameters.Count, Is.EqualTo(paramCount));
        }
Пример #29
0
        public static Polygon BuildPolygon(this SectionDefinition sec)
        {
            Polygon _polygon = new Polygon();
            int     i        = 0;

            foreach (var contour in sec.Contours)
            {
                _polygon.Add(new Contour(contour.Points.Select(p =>
                                                               new Vertex(p.X, p.Y)
                {
                    ID = i++
                })));
            }

            CreatedRegions(sec, _polygon);

            return(_polygon);
        }
Пример #30
0
        public void CompositeSec_Test()
        {
            //Note that because of using more than one material, some output need to be mapped to eq. material (e.g. Sx output represents Mpx and Sx= Mpx/fy)

            SectionMaterial steel  = new SectionMaterial("Steel", 1, 200e3, 0.3, 500);
            var             timber = new SectionMaterial("Timber", 2, 8e3, 0.35, 20);

            SectionDefinition sec = new SectionDefinition(nameof(CompositeSec_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);
            sec.Contours.Add(new SectionContour(helper.CreateIShape(304, 165, 10.2, 6.1, 11.4, 8), false, steel));
            var panel = new SectionContour(helper.CreateRectangle(50, 600), false, timber);

            panel.ShiftPoints(-217.5, 304);
            sec.Contours.Add(panel);

            _solver.Solve(sec);
            Compare(nameof(CompositeSec_Test), sec);
        }
Пример #31
0
 private bool IsLineAreaRelevant(string line, SectionDefinition currentSection, out AreaDefinition area)
 {
     area = currentSection.GetArea(line);
     return area != null;
 }
Пример #32
0
 private bool IsLineSectionMarker(string line, out SectionDefinition currentSection)
 {
     currentSection = _controlInformation.GetSection(line);
     return currentSection != null;
 }
Пример #33
0
            internal SectionData(SectionDefinition definition)
            {
                Assertions.AssertNotNull(definition, "definition");

                Definition = definition;

                Lines = new List<string>();
                InitializeParsers();
            }
        /// <summary>
        /// Saves the parser definition to a file.
        /// </summary>
        /// <param name="fileName">The file to save the parser definition to.</param>
        public void Save(string fileName)
        {
            Assertions.AssertNotEmpty(fileName, "fileName");

            ControlInformation ci = new ControlInformation();
            ci.FaxName = this.ParserName;

            foreach (SectionDefinitionViewModel svm in this.Sections)
            {
                SectionDefinition sd = new SectionDefinition();
                sd.SectionString = new GenericParserString(svm.Name);

                foreach (SectionParserDefinitionViewModel spvm in svm.Aspects)
                {
                    SectionParserDefinition spd = new SectionParserDefinition();
                    spd.Type = spvm.Type;
                    spvm.Parser.OnSave(spd.Options);

                    sd.Parsers.Add(spd);
                }

                foreach (AreaDefinitionViewModel avm in svm.Areas)
                {
                    AreaDefinition ad = new AreaDefinition();
                    ad.AreaString = new GenericParserString(avm.Name);
                    ad.MapToPropertyExpression = avm.MapToPropertyExpression;

                    sd.Areas.Add(ad);
                }

                ci.Sections.Add(sd);
            }

            ci.Save(fileName);
        }