public void SetUpFrame() { var material = new Material(youngModulus: 200, density: 0, thermalExpansionCoefficient: 0); var section = new SectionProperties(area: 600, momentOfInteria: 6000); var node1 = new PinNode(new Point(0, 0)); var node2 = new FreeNode(new Point(6, 0)); var node3 = new FixedNode(new Point(6, -6)); var nodes = new Node[] { node1, node2, node3 }; var span1 = new Span( leftNode: node1, rightNode: node2, material: material, section: section ); var span2 = new Span( leftNode: node2, rightNode: node3, material: material, section: section ); var spans = new Span[] { span1, span2 }; node2.ConcentratedForces.Add(new NormalLoad(value: 5)); _frame = new Frame(spans, nodes); _frame.CalculationEngine.Calculate(); }
public void SetUpBeam() { var material = new Concrete(youngModulus: 30); var section = new RectangleSection(width: 300, height: 500); var node1 = new FixedNode(); var node2 = new FreeNode(); var nodes = new Node[] { node1, node2 }; var span1 = new Span( leftNode: node1, length: 10, rightNode: node2, material: material, section: section ); var spans = new Span[] { span1 }; var pointLoad1 = new NormalLoad(value: 100, position: 3); span1.PointLoads.Add(pointLoad1); var pointLoad2 = new ShearLoad(value: -100, position: 5); span1.PointLoads.Add(pointLoad2); node2.ConcentratedForces.Add(new NormalLoad(value: 150)); _beam = new Beam(spans, nodes); _beam.Calculate(); }
public void SetUpBeam() { var material = new Concrete(youngModulus: 30, withReinforcement: false); var section = new RectangleSection(width: 300, height: 500); var node1 = new FreeNode(); var node2 = new PinNode(); var nodes = new Node[] { node1, node2 }; var span1 = new Span( leftNode: node1, length: 10, rightNode: node2, material: material, section: section, includeSelfWeight: false ); var spans = new Span[] { span1 }; var pointLoad1 = new ShearLoad(value: -200, position: 5); span1.PointLoads.Add(pointLoad1); _beam = new Beam(spans, nodes, includeSelfWeight: false); }
public void SetUpBeam() { var material = new Concrete(youngModulus: 30, withReinforcement: false); var section1 = new RectangleSection(width: 300, height: 500); var section2 = new RectangleSection(width: 200, height: 300); var node1 = new FixedNode(); var node2 = new FreeNode(); var node3 = new SupportedNode(); var node4 = new SupportedNode(); var nodes = new Node[] { node1, node2, node3, node4 }; var span1 = new Span( leftNode: node1, length: 6, rightNode: node2, material: material, section: section1, includeSelfWeight: false ); var span2 = new Span( leftNode: node2, length: 4, rightNode: node3, material: material, section: section2, includeSelfWeight: false ); var span3 = new Span( leftNode: node3, length: 10, rightNode: node4, material: material, section: section2, includeSelfWeight: false ); var spans = new Span[] { span1, span2, span3 }; node2.ConcentratedForces.Add(new ShearLoad(value: -200)); node3.ConcentratedForces.Add(new BendingMoment(value: 90)); var startLoad = new LoadData(value: -30, position: 0); var endLoad = new LoadData(value: 0, position: 6); span1.ContinousLoads.Add(ContinousShearLoad.Create(startLoad, endLoad)); var pointLoad = new ShearLoad(value: -150, position: 5); span3.PointLoads.Add(pointLoad); _beam = new Beam(spans, nodes, includeSelfWeight: false); _beam.CalculationEngine.Calculate(); }
internal void Dispose() { Bucket[] table = this.table; for (int i = 0; i < table.Length; i++) { for (Bucket b = table[i]; b != null; b = b.Next) { GC.ReRegisterForFinalize(b.WeakRef); } } for (FreeNode b = freeList; b != null; b = b.Next) { GC.ReRegisterForFinalize(b.WeakRef); } }
internal unsafe void CreateAndInsert(PhysicalHeap *inHeap, UIntPtr addr, UIntPtr pages) { DebugStub.Assert(MemoryManager.IsPageAligned(addr), "PhysicalHeap.CreateAndInsert non page-aligned addr={0:x}", __arglist(addr)); FreeNode *node = FreeNode.Create(inHeap, addr, pages); DebugStub.Assert(MemoryManager.IsPageAligned(node->bytes), "PhysicalHeap.CreateAndInsert non page-sized node->bytes={0:x}", __arglist(node->bytes)); InsertBySize(node); }
public void SetUpBeam() { var material = new Concrete(youngModulus: 30, withReinforcement: false); var section = new RectangleSection(width: 300, height: 500); var node1 = new SupportedNode(); var node2 = new SupportedNode(); var node3 = new FreeNode(); var nodes = new Node[] { node1, node2, node3 }; var span1 = new Span( leftNode: node1, length: 15, rightNode: node2, material: material, section: section, includeSelfWeight: false ); var span2 = new Span( leftNode: node2, length: 5, rightNode: node3, material: material, section: section, includeSelfWeight: false ); var spans = new Span[] { span1, span2 }; node3.ConcentratedForces.Add(new BendingMoment(value: 30)); var startLoad1 = new LoadData(value: -60, position: 0); var endLoad1 = new LoadData(value: -60, position: 15); span1.ContinousLoads.Add(ContinousShearLoad.Create(startLoad1, endLoad1)); var startLoad2 = new LoadData(value: -60, position: 0); var endLoad2 = new LoadData(value: -60, position: 5); span2.ContinousLoads.Add(ContinousShearLoad.Create(startLoad2, endLoad2)); _beam = new Beam(spans, nodes, includeSelfWeight: false); _beam.CalculationEngine.Calculate(); }
public void SetUpBeam() { var material1 = new Concrete(youngModulus: 30, withReinforcement: false); var material2 = new Concrete(youngModulus: 33, withReinforcement: false); var section = new RectangleSection(width: 300, height: 500); var node1 = new FixedNode(); var node2 = new FreeNode(); var node3 = new SupportedNode(); var nodes = new Node[] { node1, node2, node3 }; var span1 = new Span( leftNode: node1, length: 10, rightNode: node2, material: material1, section: section, includeSelfWeight: false ); var span2 = new Span( leftNode: node2, length: 5, rightNode: node3, material: material2, section: section, includeSelfWeight: false ); var spans = new Span[] { span1, span2 }; var upDownTemperatureLoad = UpDownTemperatureDifferenceLoad.Create( span1, upperTemperature: 20, lowerTemperature: 0); span1.ContinousLoads.Add(upDownTemperatureLoad); var alongTemperatureLoad = AlongTemperatureDifferenceLoad.Create( span1, temperatureDifference: 10); span1.ContinousLoads.Add(alongTemperatureLoad); _beam = new Beam(spans, nodes, includeSelfWeight: false); _beam.CalculationEngine.Calculate(); }
private void Rehash() { count = 0; for (int i = 0; i < table.Length; i++) { for (Bucket b = table[i]; b != null; b = b.Next) { if (b.Key != null) { count++; } } } Bucket[] newTable = new Bucket[GetPrime(count * 2)]; for (int i = 0; i < table.Length; i++) { for (Bucket b = table[i]; b != null; b = b.Next) { TKey key = b.Key; if (key != null) { int index = GetHashCode(key) % newTable.Length; WeakReference weakRef = AllocWeakRef(key); newTable[index] = new Bucket(weakRef, b.Value, newTable[index]); } else { // don't cache an infinite amount, // busy loop garbage allocation benchmarking shows that 8K is enough with current gen0 size if (freeCount < 8192) { WeakReference weakRef = b.WeakRef; b.Clear(); freeList = new FreeNode(weakRef, freeList); freeCount++; } else { GC.ReRegisterForFinalize(b.WeakRef); b.Clear(); } } } } this.table = newTable; }
private WeakReference AllocWeakRef(TKey key) { WeakReference weakRef; if (freeList != null) { weakRef = freeList.WeakRef; freeList = freeList.Next; freeCount--; weakRef.Target = key; } else { weakRef = new WeakReference(key, true); GC.SuppressFinalize(weakRef); } return(weakRef); }
public void SetUpBeam() { var material = new Concrete(youngModulus: 30, withReinforcement: false); var section1 = new RectangleSection(width: 300, height: 500); var section2 = new RectangleSection(width: 300, height: 700); var node1 = new FixedNode(); var node2 = new FreeNode(); var node3 = new FixedNode(); var nodes = new Node[] { node1, node2, node3 }; var span1 = new Span( leftNode: node1, length: 10, rightNode: node2, material: material, section: section1, includeSelfWeight: false ); var span2 = new Span( leftNode: node2, length: 10, rightNode: node3, material: material, section: section2, includeSelfWeight: false ); var spans = new Span[] { span1, span2 }; var pointLoad = new ShearLoad(value: -100, position: 5); span1.PointLoads.Add(pointLoad); _beam = new Beam(spans, nodes, includeSelfWeight: false); _beam.CalculationEngine.Calculate(); }
public void SetUpBeam() { var material = new Concrete(youngModulus: 30); var section = new RectangleSection(width: 300, height: 500); var node1 = new FreeNode(); var node2 = new PinNode(); var node3 = new PinNode(); var node4 = new SupportedNode(); var nodes = new Node[] { node1, node2, node3, node4 }; var span1 = new Span( leftNode: node1, length: 5, rightNode: node2, material: material, section: section ); var span2 = new Span( leftNode: node2, length: 10, rightNode: node3, material: material, section: section ); var span3 = new Span( leftNode: node3, length: 5, rightNode: node4, material: material, section: section ); var spans = new Span[] { span1, span2, span3 }; var upDownTemperatureLoad = UpDownTemperatureDifferenceLoad.Create( span3, upperTemperature: -20, lowerTemperature: 5); span3.ContinousLoads.Add(upDownTemperatureLoad); var alongTemperatureLoad1 = AlongTemperatureDifferenceLoad.Create( span1, temperatureDifference: -50); span1.ContinousLoads.Add(alongTemperatureLoad1); var alongTemperatureLoad2 = AlongTemperatureDifferenceLoad.Create( span2, temperatureDifference: 10); span2.ContinousLoads.Add(alongTemperatureLoad2); var startLoad = new LoadData(value: -50, position: 0); var endLoad = new LoadData(value: -50, position: 10); span2.ContinousLoads.Add(ContinousShearLoad.Create(startLoad, endLoad)); var pointLoad = new ShearLoad(value: -100, position: 2); span3.PointLoads.Add(pointLoad); _beam = new Beam(spans, nodes); _beam.Calculate(); }
public void SetUpBeam() { var material = new Concrete(youngModulus: 33, withReinforcement: false); var section = new RectangleSection(width: 300, height: 500); var node1 = new FreeNode(); var node2 = new SupportedNode(); var node3 = new SupportedNode(); var node4 = new SupportedNode(); var node5 = new FreeNode(); var nodes = new Node[] { node1, node2, node3, node4, node5 }; var span1 = new Span( leftNode: node1, length: 5, rightNode: node2, material: material, section: section, includeSelfWeight: false ); var span2 = new Span( leftNode: node2, length: 5, rightNode: node3, material: material, section: section, includeSelfWeight: false ); var span3 = new Span( leftNode: node3, length: 5, rightNode: node4, material: material, section: section, includeSelfWeight: false ); var span4 = new Span( leftNode: node4, length: 5, rightNode: node5, material: material, section: section, includeSelfWeight: false ); var spans = new Span[] { span1, span2, span3, span4 }; node5.ConcentratedForces.Add(new BendingMoment(value: -50)); var startLoad1 = new LoadData(value: -10, position: 0); var endLoad1 = new LoadData(value: -30, position: 5); span1.ContinousLoads.Add(ContinousShearLoad.Create(startLoad1, endLoad1)); var startLoad2 = new LoadData(value: -10, position: 0); var endLoad2 = new LoadData(value: -10, position: 5); span4.ContinousLoads.Add(ContinousShearLoad.Create(startLoad2, endLoad2)); var startLoad3 = new LoadData(value: 0, position: 0); var endLoad3 = new LoadData(value: -20, position: 5); span4.ContinousLoads.Add(ContinousShearLoad.Create(startLoad3, endLoad3)); var pointLoad1 = new ShearLoad(value: -150, position: 4); span2.PointLoads.Add(pointLoad1); var pointLoad2 = new ShearLoad(value: -100, position: 2); span3.PointLoads.Add(pointLoad2); var pointLoad3 = new ShearLoad(value: -50, position: 4); span3.PointLoads.Add(pointLoad3); _beam = new Beam(spans, nodes, includeSelfWeight: false); _beam.CalculationEngine.Calculate(); }
protected static void Process(StreamReader filestream) { int i = 0; //filestream.ReadLine(); filestream.ReadLine(); Document Doc = TFlex.Application.ActiveDocument; NFGetGeom.Doc = Doc; Page p = new Page(Doc); p.Name = "NFResult"; p.FontStyle.Italic = true; int contour_count = 0; string line = ""; string[] split; NFPolyline Poly = new NFPolyline(); double y_offset = 0; do { line = filestream.ReadLine(); split = line.Split(' '); bool processing = false; double first_x = -1.337; double first_y = -1.337; if (line != null && split.Length == 2) { processing = true; contour_count++; NFGetGeom.Msg("Contour: " + contour_count); do { line = filestream.ReadLine(); split = line.Split(' '); if (split.Length > 1) { if (split.Length == 3) { int bulge = 0; Int32.TryParse(split[2].ToString(), out bulge); NFGetGeom.Msg(line); double x = 0, y = 0; Double.TryParse(split[0].ToString().Replace('.', ','), out x); Double.TryParse(split[1].ToString().Replace('.', ','), out y); if (contour_count == 1) { y_offset = Math.Max(y_offset, y); } else { y = y_offset - y; } if (first_x == -1.337) { first_x = x; first_y = y; } Poly.AddPoint(x, y); } if (split.Length == 5) { NFGetGeom.Msg("ARC: " + line); double x = 0, y = 0, radius = 0, ang1 = 0, ang2 = 0; Double.TryParse(split[0].ToString().Replace('.', ','), out x); Double.TryParse(split[1].ToString().Replace('.', ','), out y); Double.TryParse(split[2].ToString().Replace('.', ','), out radius); Double.TryParse(split[3].ToString().Replace('.', ','), out ang1); Double.TryParse(split[4].ToString().Replace('.', ','), out ang2); radius = radius / 2; double x1 = Math.Cos(-ang1 / 180 * Math.PI) * radius + x + radius; double y1 = Math.Sin(-ang1 / 180 * Math.PI) * radius + y + radius; double x2 = Math.Cos((-ang1 - ang2 / 2) / 180 * Math.PI) * radius + x + radius; double y2 = Math.Sin((-ang1 - ang2 / 2) / 180 * Math.PI) * radius + y + radius; double x3 = Math.Cos((-ang1 - ang2) / 180 * Math.PI) * radius + x + radius; double y3 = Math.Sin((-ang1 - ang2) / 180 * Math.PI) * radius + y + radius; y1 = y_offset - y1; y2 = y_offset - y2; y3 = y_offset - y3; FreeNode fn1 = new FreeNode(Doc, x1, y1); FreeNode fn2 = new FreeNode(Doc, x2, y2); FreeNode fn3 = new FreeNode(Doc, x3, y3); if (first_x == -1.337) { first_x = x1; first_y = y1; } if (Poly.count > 0) { Poly.AddPoint(x1, y1); Poly.Draw(Doc, p); Poly = new NFPolyline(); } Poly.AddPoint(x3, y3); ThreePointArcOutline Arc = new ThreePointArcOutline(Doc, fn1, fn2, fn3); Arc.Page = p; } } } while (line != null & split.Length > 1); } if (processing & Poly.count > 0) { NFGetGeom.Msg("INIT POLYLINE"); Poly.AddPoint(first_x, first_y); Poly.Draw(Doc, p); Poly = new NFPolyline(); } if (filestream.EndOfStream) { break; } } while (true); }
protected static void Process(StreamReader filestream) { Document Doc = TFlex.Application.ActiveDocument; NFUtils.Doc = Doc; Page p = new Page(Doc); p.Name = "NFResult"; p.FontStyle.Italic = true; int contour_count = 0; string line = ""; NFPolyline Poly = new NFPolyline(); double y_offset = 0; do { line = filestream.ReadLine(); var split = line.Split(' ').ToList(); bool processing = false; double?firstX = null; double?firstY = null; if (line != null && split.Count == 2) { processing = true; contour_count++; NFUtils.Msg("Contour: " + contour_count); do { line = filestream.ReadLine(); split = line.Split(' ').ToList(); if (split.Count > 1) { if (split.Count == 3) { int bulge; int.TryParse(split[2], out bulge); NFUtils.Msg(line); double x, y; double.TryParse(split[0].Replace('.', ','), out x); double.TryParse(split[1].Replace('.', ','), out y); if (contour_count == 1) { y_offset = Math.Max(y_offset, y); } else { y = y_offset - y; } if (firstX == null) { firstX = x; firstY = y; } Poly.AddPoint(x, y); } if (split.Count == 5) { NFUtils.Msg($"ARC: {line}"); double x, y, radius, ang1, ang2; double.TryParse(split[0].Replace('.', ','), out x); double.TryParse(split[1].Replace('.', ','), out y); double.TryParse(split[2].Replace('.', ','), out radius); double.TryParse(split[3].Replace('.', ','), out ang1); double.TryParse(split[4].Replace('.', ','), out ang2); radius = radius / 2; double x1 = Math.Cos(-ang1 / 180 * Math.PI) * radius + x + radius; double y1 = Math.Sin(-ang1 / 180 * Math.PI) * radius + y + radius; double x2 = Math.Cos((-ang1 - ang2 / 2) / 180 * Math.PI) * radius + x + radius; double y2 = Math.Sin((-ang1 - ang2 / 2) / 180 * Math.PI) * radius + y + radius; double x3 = Math.Cos((-ang1 - ang2) / 180 * Math.PI) * radius + x + radius; double y3 = Math.Sin((-ang1 - ang2) / 180 * Math.PI) * radius + y + radius; y1 = y_offset - y1; y2 = y_offset - y2; y3 = y_offset - y3; FreeNode fn1 = new FreeNode(Doc, x1, y1); FreeNode fn2 = new FreeNode(Doc, x2, y2); FreeNode fn3 = new FreeNode(Doc, x3, y3); if (firstX == null) { firstX = x1; firstY = y1; } if (Poly.count > 0) { Poly.AddPoint(x1, y1); Poly.Draw(Doc, p); Poly = new NFPolyline(); } Poly.AddPoint(x3, y3); ThreePointArcOutline Arc = new ThreePointArcOutline(Doc, fn1, fn2, fn3); Arc.Page = p; } } } while (line != null & split.Count > 1); } if (processing & Poly.count > 0) { NFUtils.Msg("INIT POLYLINE"); Poly.AddPoint(firstX ?? 0, firstY ?? 0); Poly.Draw(Doc, p); Poly = new NFPolyline(); } if (filestream.EndOfStream) { break; } } while (true); }
public unsafe void Free(UIntPtr addr, UIntPtr bytes, Process process) { if (addr == UIntPtr.Zero) { // Silently accept freeing null return; } // We always hand out memory in page-size chunks, so round up what // the caller thinks their block size is bytes = MemoryManager.PagePad(bytes); // Our blocks always start on page boundaries DebugStub.Assert(MemoryManager.IsPageAligned(addr)); ushort tag = process != null ? (ushort)process.ProcessId : KernelPage; bool iflag = Lock(); try { CheckConsistency(); UIntPtr numPages = MemoryManager.PagesFromBytes(bytes); VerifyOwner(addr, numPages, tag); FreeNode *nextBlock = null; FreeNode *prevBlock = null; if ((addr + bytes) < heapLimit) { fixed(PhysicalHeap *thisPtr = &this) { nextBlock = FreeNode.GetNodeAt(thisPtr, addr + bytes); } } if (addr > startAddr) { fixed(PhysicalHeap *thisPtr = &this) { prevBlock = LastNode.GetNodeFromLast(thisPtr, addr - MemoryManager.PageSize); } } // Don't mark pages as free until we're done discovering the // previous and next blocks, or the attempt to discover // the previous and next blocks gets confused to find itself // adjacent to a free block. SetPages(addr, numPages, FreePage); // Coalesce with the preceding region if (prevBlock != null) { addr = (UIntPtr)prevBlock; bytes += prevBlock->bytes; freeList.Remove(prevBlock); } // Coalesce with the following region if (nextBlock != null) { bytes += nextBlock->bytes; freeList.Remove(nextBlock); } // Blocks should always be integral numbers of pages DebugStub.Assert(MemoryManager.IsPageAligned(bytes)); // Create the free node. fixed(PhysicalHeap *thisPtr = &this) { freeList.CreateAndInsert(thisPtr, addr, bytes / MemoryManager.PageSize); } CheckConsistency(); } finally { Unlock(iflag); } }
public void SetUpBeam() { var material = new Concrete(youngModulus: 30); var section = new RectangleSection(width: 300, height: 500); var node1 = new FixedNode(); var node2 = new FreeNode(); var node3 = new FreeNode(); var node4 = new SupportedNode(); var node5 = new SupportedNode(); var nodes = new Node[] { node1, node2, node3, node4, node5 }; var span1 = new Span( leftNode: node1, length: 5, rightNode: node2, material: material, section: section ); var span2 = new Span( leftNode: node2, length: 7, rightNode: node3, material: material, section: section ); var span3 = new Span( leftNode: node3, length: 5, rightNode: node4, material: material, section: section ); var span4 = new Span( leftNode: node4, length: 3, rightNode: node5, material: material, section: section ); var spans = new Span[] { span1, span2, span3, span4 }; node2.ConcentratedForces.Add(new BendingMoment(value: 56)); node3.ConcentratedForces.Add(new ShearLoad(value: 100)); var startLoad1 = new LoadData(value: -15, position: 1); var endLoad1 = new LoadData(value: -25, position: 5); span1.ContinousLoads.Add(ContinousShearLoad.Create(startLoad1, endLoad1)); var startLoad2 = new LoadData(value: -25, position: 0); var endLoad2 = new LoadData(value: 25, position: 4); span3.ContinousLoads.Add(ContinousShearLoad.Create(startLoad2, endLoad2)); var pointLoad1 = new ShearLoad(value: -150, position: 3.4); span2.PointLoads.Add(pointLoad1); var pointLoad2 = new ShearLoad(value: -50, position: 1.5); span4.PointLoads.Add(pointLoad2); _beam = new Beam(spans, nodes); _beam.Calculate(); }
internal FreeNode(WeakReference weakRef, FreeNode next) { this.WeakRef = weakRef; this.Next = next; }
public void SetUp() { _freeNode = new FreeNode(); }
public void SetUpBeam() { var material = new Concrete(youngModulus: 30); var section1 = new RectangleSection(width: 300, height: 500); var section2 = new RectangleSection(width: 200, height: 300); var node1 = new FixedNode(); var node2 = new FreeNode(); var node3 = new SupportedNode(); var node4 = new FixedNode(); var nodes = new Node[] { node1, node2, node3, node4 }; var span1 = new Span( leftNode: node1, length: 6, rightNode: node2, material: material, section: section1 ); var span2 = new Span( leftNode: node2, length: 4, rightNode: node3, material: material, section: section2 ); var span3 = new Span( leftNode: node3, length: 10, rightNode: node4, material: material, section: section2 ); var spans = new Span[] { span1, span2, span3 }; node2.ConcentratedForces.Add(new ShearLoad(value: -200)); node2.ConcentratedForces.Add(new BendingMoment(value: 150)); var startLoad1 = new LoadData(value: 0, position: 0); var endLoad1 = new LoadData(value: -30, position: 2.5); var startLoad2 = new LoadData(value: -30, position: 2.5); var endLoad2 = new LoadData(value: -30, position: 7.5); var startLoad3 = new LoadData(value: -30, position: 7.5); var endLoad3 = new LoadData(value: 0, position: 10); span3.ContinousLoads.Add(ContinousShearLoad.Create(startLoad1, endLoad1)); span3.ContinousLoads.Add(ContinousShearLoad.Create(startLoad2, endLoad2)); span3.ContinousLoads.Add(ContinousShearLoad.Create(startLoad3, endLoad3)); var pointLoad = new ShearLoad(value: -150, position: 3); span1.PointLoads.Add(pointLoad); _beam = new Beam(spans, nodes); _beam.Calculate(); }