Skip to content

Commit

Permalink
Revert "Revert "Shear modulus and thermal coefficient value fix""
Browse files Browse the repository at this point in the history
This reverts commit 85da751.
  • Loading branch information
johannaisak authored and Fraser Greenroyd committed Jul 7, 2023
1 parent 447df1a commit 0813718
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 4 deletions.
138 changes: 138 additions & 0 deletions GSA_Adapter/CRUD/ReadResultsElements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
using System.Collections.Generic;
using System.Linq;
using BH.Engine.Adapters.GSA;
using BH.oM.Structure.Results;

namespace BH.Adapter.GSA
{
Expand Down Expand Up @@ -218,6 +219,99 @@ private bool GetExtractionParameters(NodeResultRequest request, out ResHeader he

/***************************************************/

private bool GetExtractionParameters(MeshResultRequest request, out ResHeader header, out ForceConverter converter, out string axis, out double unitFactor, out int divisions, out int flags)
{
axis = Output_Axis.Local;
divisions = 0;
flags = 0;

double[] unitFactors = GetUnitFactors();

switch (request.LayerPosition)
{
case -1:
flags = (int)Output_Init_Flags.OP_INIT_2D_BOTTOM;
break;
case 0:
flags = (int)Output_Init_Flags.OP_INIT_2D_MIDDLE;
break;
case 1:
flags = (int)Output_Init_Flags.OP_INIT_2D_TOP;
break;
case 2:
converter = null;
header = ResHeader.REF_ACC;
unitFactor = unitFactors[(int)UnitType.FORCE];
flags = 0;
Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported");
return false;
case 3:
converter = null;
header = ResHeader.REF_ACC;
unitFactor = unitFactors[(int)UnitType.FORCE];
flags = 0;
Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported");
return false;
case 4:
converter = null;
header = ResHeader.REF_ACC;
unitFactor = unitFactors[(int)UnitType.FORCE];
flags = 0;
Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported");
return false;
case 5:
converter = null;
header = ResHeader.REF_ACC;
unitFactor = unitFactors[(int)UnitType.FORCE];
flags = 0;
Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported");
return false;
}

switch (request.ResultType)
{
case MeshResultType.Forces:
converter = null;
header = ResHeader.REF_FORCE_EL2D_DRV;
unitFactor = unitFactors[(int)UnitType.FORCE];
Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported");
return false;
case MeshResultType.Displacements:
converter = null;
header = ResHeader.REF_DISP_EL2D;
unitFactor = unitFactors[(int)UnitType.LENGTH];
Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported");
return false;
case MeshResultType.MeshModeShape:
converter = null;
header = ResHeader.REF_ACC;
unitFactor = 1;
Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported");
return false;
case MeshResultType.Stresses:
converter = Convert.FromGsaMeshStress;
header = ResHeader.REF_STRESS_EL2D_DRV;
unitFactor = unitFactors[(int)UnitType.STRESS];
break;
case MeshResultType.VonMises:
converter = null;
header = ResHeader.REF_ACC;
unitFactor = 1;
Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported");
return false;
default:
converter = null;
header = ResHeader.REF_ACC;
unitFactor = 1;
Engine.Base.Compute.RecordError("Result of type " + request.ResultType + " is not yet supported");
return false;
}

return true;
}

/***************************************************/

private bool IGetExtractionParameters(IResultRequest request, out ResHeader header, out ForceConverter converter, out string axis, out double unitFactor, out int divisions, out int flags)
{
return GetExtractionParameters(request as dynamic, out header, out converter, out axis, out unitFactor, out divisions, out flags);
Expand Down Expand Up @@ -375,6 +469,50 @@ private List<int> GetAllIds(NodeResultRequest request)
}


/***************************************************/

private List<int> GetAllIds(MeshResultRequest request)
{
string allBars = m_gsaCom.GwaCommand("GET_ALL, EL.2").ToString();
string[] barArr = string.IsNullOrWhiteSpace(allBars) ? new string[0] : allBars.Split('\n');

List<int> ids = new List<int>();
bool containsDummies = false;
foreach (string gsaBar in barArr)
{

string[] arr = gsaBar.Split(',');

string index = arr[1];

//Check that the element type is a mesh
switch (arr[4])
{
case "TRI3":
case "TRI6":
case "QUAD4":
case "QUAD8":
break;
default:
continue;
}

//Check if dummy
if (arr.Last().ToUpper() == "DUMMY")
{
containsDummies = true;
continue;
}

ids.Add(int.Parse(index));
}

if (containsDummies)
Engine.Base.Compute.RecordNote("Model contains 'dummy'-elements. The elements with this tag do not contain any results and will not have any results extracted.");

return ids;
}

/***************************************************/

static public int[] CreateIntSequence(int maxId)
Expand Down
11 changes: 11 additions & 0 deletions GSA_Adapter/Convert/FromGsa/Properties/SectionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public static ISectionProperty FromGsaSectionProperty(string gsaString, Dictiona
else
{
secName = secName.TrimEnd((".0").ToCharArray());

if (desc[1].Contains("CHS"))
{
description = "STD" + splitChar + secType + splitChar;
Expand All @@ -144,6 +145,16 @@ public static ISectionProperty FromGsaSectionProperty(string gsaString, Dictiona

Engine.Base.Compute.RecordNote("Section of type: " + secName + " not found in the library. Custom section will be used");
}
else if (desc[1].Contains("CHS"))
{
description = "STD%" + secType + "%";
string trim = desc[2].TrimStart(secType.ToCharArray());
string[] arr = trim.Split('x');

description += arr[0] + "%" + arr[1];

Engine.Base.Compute.RecordNote("Section of type: " + secName + " not found in the library. Custom section will be used");
}
else
{
message += "Catalogue section of type " + secName + " not found in library\n";
Expand Down
26 changes: 26 additions & 0 deletions GSA_Adapter/Convert/FromGsa/Results/Results.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,32 @@ public static BarStrain FromGsaBarStrain(GsaResults results, int id, string load

/***************************************************/

public static MeshStress FromGsaMeshStress(GsaResults results, int id, string loadCase, int divisions, double timeStep = 0, int mode = -1)
{
return new MeshStress(
id,
0,
0,
loadCase,
mode,
timeStep,
MeshResultLayer.Lower,
-1,
MeshResultSmoothingType.None,
oM.Geometry.Basis.XY,
results.dynaResults[0],
results.dynaResults[1],
results.dynaResults[2],
results.dynaResults[4],
results.dynaResults[3],
results.dynaResults[6],
results.dynaResults[5],
results.dynaResults[7]
);
}

/***************************************************/

public static GlobalReactions FromGsaGlobalReactions(string id, string force, string moment)
{
string[] fArr = force.Split(',');
Expand Down
8 changes: 4 additions & 4 deletions GSA_Adapter/GSA_Adapter.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTarget="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand All @@ -20,7 +20,7 @@
<DefineConstants>DEBUG;TRACE;GSA_8_7</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AssemblyName>GSA87_Adapter</AssemblyName>
<AssemblyName>GSA87_Adapter</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -29,7 +29,7 @@
<DefineConstants>TRACE;GSA_8_7</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AssemblyName>GSA87_Adapter</AssemblyName>
<AssemblyName>GSA87_Adapter</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug87|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -258,4 +258,4 @@
xcopy "$(TargetDir)$(TargetFileName)" "$(ProgramData)\BHoM\Assemblies" /Y
</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>

0 comments on commit 0813718

Please sign in to comment.