Skip to content

Commit 5cf2188

Browse files
committed
hexa test update
1 parent 679e09a commit 5cf2188

10 files changed

Lines changed: 282 additions & 29 deletions

File tree

BriefFiniteElementNet.Common/Matrix.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,5 +766,16 @@ public static void ScaleRow(this DenseColumnMajorStorage<double> matrix, int i,
766766
values[j * rows + i] *= constant;
767767
}
768768
}
769+
770+
public static void FillMatrixRowise(this DenseColumnMajorStorage<double> matrix, params double[] values)
771+
{
772+
for (var i = 0; i < values.Length; i++)
773+
{
774+
var row = i / matrix.ColumnCount;
775+
var col = i % matrix.ColumnCount;
776+
777+
matrix[row, col] = values[i];
778+
}
779+
}
769780
}
770781
}

BriefFiniteElementNet.CustomElements/Elements/HexahedralTest.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace BriefFiniteElementNet.Elements
1313
/// Represents a hexahedral with isotropic material.
1414
/// </summary>
1515
[Serializable]
16-
[Obsolete("not fully implemented yet")]
16+
[Obsolete("really obsolete")]
1717
public class HexahedralElement : Element
1818
{
1919
public HexahedralElement() : base(8)
@@ -407,13 +407,13 @@ public virtual Matrix GetJMatrixAt(Element targetElement, params double[] isoCoo
407407

408408
var buf = new Matrix(3, 3);
409409

410-
buf.FillRow(0, (J11 * x1 + J12 * x2 + J13 * x3 + J14 * x4 + J15 * x5 + J16 * x6 + J17 * x7 + J18 * x8),
410+
buf.SetRow(0, (J11 * x1 + J12 * x2 + J13 * x3 + J14 * x4 + J15 * x5 + J16 * x6 + J17 * x7 + J18 * x8),
411411
(J11 * y1 + J12 * y2 + J13 * y3 + J14 * y4 + J15 * y5 + J16 * y6 + J17 * y7 + J18 * y8),
412412
(J11 * z1 + J12 * z2 + J13 * z3 + J14 * z4 + J15 * z5 + J16 * z6 + J17 * z7 + J18 * z8));
413-
buf.FillRow(1, (J21 * x1 + J22 * x2 + J23 * x3 + J24 * x4 + J25 * x5 + J26 * x6 + J27 * x7 + J28 * x8),
413+
buf.SetRow(1, (J21 * x1 + J22 * x2 + J23 * x3 + J24 * x4 + J25 * x5 + J26 * x6 + J27 * x7 + J28 * x8),
414414
(J21 * y1 + J22 * y2 + J23 * y3 + J24 * y4 + J25 * y5 + J26 * y6 + J27 * y7 + J28 * y8),
415415
(J21 * z1 + J22 * z2 + J23 * z3 + J24 * z4 + J25 * z5 + J26 * z6 + J27 * z7 + J28 * z8));
416-
buf.FillRow(2, (J31 * x1 + J32 * x2 + J33 * x3 + J34 * x4 + J35 * x5 + J36 * x6 + J37 * x7 + J38 * x8),
416+
buf.SetRow(2, (J31 * x1 + J32 * x2 + J33 * x3 + J34 * x4 + J35 * x5 + J36 * x6 + J37 * x7 + J38 * x8),
417417
(J31 * y1 + J32 * y2 + J33 * y3 + J34 * y4 + J35 * y5 + J36 * y6 + J37 * y7 + J38 * y8),
418418
(J31 * z1 + J32 * z2 + J33 * z3 + J34 * z4 + J35 * z5 + J36 * z6 + J37 * z7 + J38 * z8));
419419
//buf.FillRow(1, J21, J22, J23, J24, J25, J26, J27, J28);
@@ -566,6 +566,7 @@ public override Force[] GetGlobalEquivalentNodalLoads(ElementalLoad load)
566566
}
567567
public Force[] GetGlobalEquivalentNodalLoads(Element targetElement, ElementalLoad load)
568568
{
569+
/*
569570
if (load is UniformBodyLoad3D)
570571
{
571572
//p.263 of Structural Analysis with the Finite Element Method Linear Statics, ISBN: 978-1-4020-8733-2
@@ -584,7 +585,7 @@ public Force[] GetGlobalEquivalentNodalLoads(Element targetElement, ElementalLoa
584585
return new[] { f, f, f, f, f, f, f, f };
585586
}
586587
587-
588+
*/
588589
throw new NotImplementedException();
589590
}
590591

BriefFiniteElementNet.TestConsole/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void Main(string[] args)
3636
{
3737
Console.Title = "BFE tests & temporary codes";
3838

39-
new BriefFiniteElementNet.Validation.Case_03.Validator().Validate();
39+
new BriefFiniteElementNet.Validation.Case_06.Validator().Validate();
4040

4141
//Validation.GithubIssues.Issue100.Run();
4242

BriefFiniteElementNet.Validation/AbaqusInputFileReader.cs

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.IO;
66
using System.Linq;
77
using System.Text;
8+
using System.Text.RegularExpressions;
89
using System.Threading.Tasks;
910
using System.Windows.Controls;
1011

@@ -34,6 +35,8 @@ public static Model AbaqusInputToBFE(string pathToInputFile)
3435
{
3536
string[] split;
3637
selectedInputVariable selectedVar = selectedInputVariable.Nodes;
38+
string selectedVarInfo = "";//selectedVar + info
39+
3740
string input = sr.ReadLine();
3841
while (input != null)
3942
{
@@ -47,6 +50,7 @@ public static Model AbaqusInputToBFE(string pathToInputFile)
4750
break;
4851
case "*Element":
4952
selectedVar = selectedInputVariable.Elements;
53+
selectedVarInfo = input;
5054
break;
5155
case "*Nset":
5256
selectedVar = selectedInputVariable.NodeSet;
@@ -84,12 +88,17 @@ public static Model AbaqusInputToBFE(string pathToInputFile)
8488
}
8589
case selectedInputVariable.Elements:
8690
{
87-
element = ReadTetraElement(input, delimiter, buf.Nodes);
88-
if (element != null)
91+
var elm = ReadElement(input, delimiter, buf.Nodes, selectedVarInfo);
92+
93+
//if (elm is TetrahedronElement tet)
94+
// tet.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.25);
95+
96+
//element = ReadTetraElement(input, delimiter, buf.Nodes);
97+
if (elm != null)
8998
{
90-
element.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.25);
91-
element.FixNodeOrder();
92-
buf.Elements.Add(element);
99+
//elm.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.25);
100+
//element.FixNodeOrder();
101+
buf.Elements.Add(elm);
93102
}
94103
break;
95104
}
@@ -192,6 +201,70 @@ private static Node ReadNode(string nodeline, char delimiter)
192201
}
193202
return node;
194203
}
204+
205+
206+
/// <summary>
207+
/// Reads an element from an Abaqus input file
208+
/// </summary>
209+
/// <param name="elementline">A line with the element props</param>
210+
/// <param name="delimiter">The separator char</param>
211+
/// <param name="nodes">A list of nodes - starts at 0 -> = node-1</param>
212+
/// <returns>An element</returns>
213+
private static HexahedralElement ReadHexaElement(string elementline, char delimiter, NodeCollection nodes)
214+
{
215+
var elm = new HexahedralElement();
216+
string[] split;
217+
int elementNr;//, nodeNr1, nodeNr2, nodeNr3, nodeNr4;
218+
try
219+
{
220+
var spl = elementline.Split(delimiter).Select(int.Parse).ToArray();
221+
222+
var elmNum = spl[0];//element number
223+
224+
var nodeIdxs = spl.Skip(1).ToArray();//index of connected nodes
225+
226+
227+
//subtract 1. The nodes are numbered from 1-> end and are stored as 0-> end-1
228+
229+
for (var i = 0; i < 8; i++)
230+
{
231+
elm.Nodes[i] = nodes[nodeIdxs[i ] - 1];
232+
}
233+
234+
elm.label = elmNum.ToString();
235+
}
236+
catch (Exception ex)
237+
{
238+
throw new Exception("Something went wrong with reading the nodes! Error with line: " + elementline, ex);
239+
}
240+
241+
return elm;
242+
}
243+
244+
245+
private static Element ReadElement(string elementline, char delimiter, NodeCollection nodes,string elementInfo)
246+
{
247+
var patt = @"^\*Element, type=(\S+)$";
248+
249+
var mtch = Regex.Match(elementInfo, patt);
250+
251+
if (!mtch.Success)
252+
throw new Exception();
253+
254+
var elmType = mtch.Groups[1].Value;
255+
256+
switch(elmType)
257+
{
258+
case "C3D8":
259+
return ReadHexaElement(elementline, delimiter, nodes);
260+
case "C3D4":
261+
return ReadTetraElement(elementline, delimiter, nodes);
262+
263+
default:
264+
throw new NotImplementedException("undefined ABAQUS element: " + elmType);
265+
}
266+
}
267+
195268
/// <summary>
196269
/// Reads an element from an Abaqus input file
197270
/// </summary>
@@ -201,7 +274,7 @@ private static Node ReadNode(string nodeline, char delimiter)
201274
/// <returns>An element</returns>
202275
private static TetrahedronElement ReadTetraElement(string elementline, char delimiter, NodeCollection nodes)
203276
{
204-
TetrahedronElement elm = new TetrahedronElement();
277+
var elm = new TetrahedronElement();
205278
string[] split;
206279
int elementNr;//, nodeNr1, nodeNr2, nodeNr3, nodeNr4;
207280
try

BriefFiniteElementNet.Validation/BriefFiniteElementNet.Validation.csproj

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<Compile Include="Case_03\Validator.cs" />
6666
<Compile Include="Case_04\Validator.cs" />
6767
<Compile Include="Case_05\Validator.cs" />
68+
<Compile Include="Case_06\Validator.cs" />
6869
<Compile Include="EqualDofValidator.cs" />
6970
<Compile Include="GithubIssues\Issue100.cs" />
7071
<Compile Include="GithubIssues\Issue101.cs" />
@@ -129,21 +130,19 @@
129130
<None Include="Case_02\Intro.md" />
130131
<None Include="Case_02\Abaqus comparison\Model1_BFE_Abaqus.csv" />
131132
<None Include="Case_01\stress &amp; displacement.rpt" />
132-
133-
<None Include="Case_03\Abaqus output\Bottom_Center.rpt" />
134-
<None Include="Case_03\Abaqus output\Side_Center.rpt" />
135-
<None Include="Case_03\Abaqus output\Top_Center.rpt" />
136133
<None Include="Case_03\Job-10.inp" />
137-
<None Include="Case_06\Abaqus data\Displacements" />
138-
<None Include="Case_06\Abaqus data\Job-11.inp" />
139-
134+
<Content Include="Case_06\Displacements">
135+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
136+
</Content>
137+
<Content Include="Case_06\Job-11.inp">
138+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
139+
</Content>
140140
<None Include="Case_03\output\Bottom_Center.rpt" />
141141
<None Include="Case_03\output\Side_Center.rpt" />
142142
<None Include="Case_03\output\Top_Center.rpt" />
143143
<None Include="Case_03\Job-10.inp">
144144
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
145145
</None>
146-
147146
<None Include="OpenseesTclGenerator\Readme.md" />
148147
<None Include="packages.config" />
149148
<None Include="Readme.md" />
@@ -172,18 +171,11 @@
172171
</ProjectReference>
173172
</ItemGroup>
174173
<ItemGroup>
175-
176-
<Content Include="Case_03\Abaqus output\Paths.png" />
177-
<Content Include="Case_03\Abaqus output\U.png" />
178-
<Content Include="Case_03\Abaqus output\U1.png" />
179-
<Content Include="Case_03\Abaqus output\U2.png" />
180-
<Content Include="Case_03\Abaqus output\U3.png" />
181174
<Content Include="Case_06\Abaqus data\S_Mises.png" />
182175
<Content Include="Case_06\Abaqus data\U_1.png" />
183176
<Content Include="Case_06\Abaqus data\U_2.png" />
184177
<Content Include="Case_06\Abaqus data\U_3.png" />
185178
<Content Include="Case_06\Abaqus data\U_Mag.png" />
186-
187179
<Content Include="Case_03\output\NodalDisp.txt">
188180
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
189181
</Content>
@@ -192,7 +184,6 @@
192184
<Content Include="Case_03\output\U1.png" />
193185
<Content Include="Case_03\output\U2.png" />
194186
<Content Include="Case_03\output\U3.png" />
195-
196187
<Content Include="Data\Brick8-1n\br1.jpg" />
197188
<Content Include="Data\Brick8-1n\br2.jpg" />
198189
<Content Include="Data\Brick8-1n\Elements-Nodes.txt" />

BriefFiniteElementNet.Validation/Case_03/Validator.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ public ValidationResult Validate()
2323
string RunningPath = AppDomain.CurrentDomain.BaseDirectory;
2424
string FileName = string.Format("Case_03\\Job-10.inp", Path.GetFullPath(Path.Combine(RunningPath, @"..\..\")));
2525
var abaqusModel = AbaqusInputFileReader.AbaqusInputToBFE(FileName);
26+
27+
foreach (var elm in abaqusModel.Elements)
28+
{
29+
if (elm is TetrahedronElement hx)
30+
{
31+
hx.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.25);
32+
}
33+
34+
}
35+
2636
//comparison
2737
var val = new ValidationResult();
2838
var span = val.Span = new HtmlTag("span");

BriefFiniteElementNet.Validation/Case_06/Abaqus data/Displacements renamed to BriefFiniteElementNet.Validation/Case_06/Displacements

File renamed without changes.

BriefFiniteElementNet.Validation/Case_06/Abaqus data/Job-11.inp renamed to BriefFiniteElementNet.Validation/Case_06/Job-11.inp

File renamed without changes.

0 commit comments

Comments
 (0)