From 387847805d539937ba3d7ed329c204dbc6fe2b65 Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Wed, 28 Jun 2023 15:42:05 +0100 Subject: [PATCH] Replace Read statements with GetCachedOrRead to improve speeds --- Lusas_Adapter/CRUD/Read/Elements/Bars.cs | 25 +++++++----------- Lusas_Adapter/CRUD/Read/Elements/Edges.cs | 5 ++-- Lusas_Adapter/CRUD/Read/Elements/Nodes.cs | 5 ++-- Lusas_Adapter/CRUD/Read/Elements/Panels.cs | 26 ++++++++----------- .../Read/Loads/AreaUniformTemperatureLoads.cs | 5 ++-- .../Loads/AreaUniformlyDistributedLoads.cs | 5 ++-- .../CRUD/Read/Loads/BarPointLoads.cs | 5 ++-- .../Read/Loads/BarUniformTemperatureLoads.cs | 5 ++-- .../Loads/BarUniformlyDistributedLoads.cs | 5 ++-- .../Read/Loads/BarVaryingDistributedLoads.cs | 5 ++-- Lusas_Adapter/CRUD/Read/Loads/GravityLoads.cs | 15 +++++------ .../CRUD/Read/Loads/LoadCombinations.cs | 5 ++-- .../CRUD/Read/Loads/PointDisplacements.cs | 5 ++-- Lusas_Adapter/CRUD/Read/Loads/PointForces.cs | 5 ++-- 14 files changed, 49 insertions(+), 72 deletions(-) diff --git a/Lusas_Adapter/CRUD/Read/Elements/Bars.cs b/Lusas_Adapter/CRUD/Read/Elements/Bars.cs index 873317a1..6d2a758f 100644 --- a/Lusas_Adapter/CRUD/Read/Elements/Bars.cs +++ b/Lusas_Adapter/CRUD/Read/Elements/Bars.cs @@ -54,25 +54,20 @@ private List ReadBars(List ids = null) if (!(lusasLines.Count() == 0)) { - IEnumerable nodesList = ReadNodes(); - Dictionary nodes = nodesList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + IEnumerable nodesList = GetCachedOrRead(); + Dictionary nodes = nodesList.ToDictionary(x => x.AdapterId(typeof(LusasId))); - IEnumerable supportsList = Read4DOFConstraints(); - Dictionary supports = supportsList.ToDictionary( - x => x.Name); + IEnumerable supportsList = GetCachedOrRead(); + Dictionary supports = supportsList.ToDictionary(x => x.Name); - IEnumerable materialList = ReadMaterials(); - Dictionary materials = materialList.ToDictionary( - x => x.Name.ToString()); + IEnumerable materialList = GetCachedOrRead(); + Dictionary materials = materialList.ToDictionary(x => x.Name.ToString()); - IEnumerable sectionPropertiesList = ReadSectionProperties(); - Dictionary sectionProperties = sectionPropertiesList.ToDictionary( - x => x.Name.ToString()); + IEnumerable sectionPropertiesList = GetCachedOrRead(); + Dictionary sectionProperties = sectionPropertiesList.ToDictionary(x => x.Name.ToString()); - List meshesList = ReadMeshSettings1D(); - Dictionary meshes = meshesList.ToDictionary( - x => x.Name.ToString()); + List meshesList = GetCachedOrRead(); + Dictionary meshes = meshesList.ToDictionary(x => x.Name.ToString()); HashSet groupNames = ReadTags(); diff --git a/Lusas_Adapter/CRUD/Read/Elements/Edges.cs b/Lusas_Adapter/CRUD/Read/Elements/Edges.cs index b7fcbad2..0cd68d79 100644 --- a/Lusas_Adapter/CRUD/Read/Elements/Edges.cs +++ b/Lusas_Adapter/CRUD/Read/Elements/Edges.cs @@ -50,9 +50,8 @@ private List ReadEdges(List ids = null) if (lusasLines.Count() != 0) { - List nodesList = ReadNodes(); - Dictionary nodes = nodesList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List nodesList = GetCachedOrRead(); + Dictionary nodes = nodesList.ToDictionary(x => x.AdapterId(typeof(LusasId))); HashSet groupNames = ReadTags(); diff --git a/Lusas_Adapter/CRUD/Read/Elements/Nodes.cs b/Lusas_Adapter/CRUD/Read/Elements/Nodes.cs index 669abb54..6ff8c9f6 100644 --- a/Lusas_Adapter/CRUD/Read/Elements/Nodes.cs +++ b/Lusas_Adapter/CRUD/Read/Elements/Nodes.cs @@ -51,9 +51,8 @@ private List ReadNodes(List ids = null) { HashSet groupNames = ReadTags(); - IEnumerable constraints6DOFList = Read6DOFConstraints(); - Dictionary constraints6DOF = constraints6DOFList.ToDictionary( - x => x.Name.ToString()); + IEnumerable constraints6DOFList = GetCachedOrRead(); + Dictionary constraints6DOF = constraints6DOFList.ToDictionary(x => x.Name.ToString()); for (int i = 0; i < lusasPoints.Count(); i++) { diff --git a/Lusas_Adapter/CRUD/Read/Elements/Panels.cs b/Lusas_Adapter/CRUD/Read/Elements/Panels.cs index 08b9a8a3..2bb8c2bf 100644 --- a/Lusas_Adapter/CRUD/Read/Elements/Panels.cs +++ b/Lusas_Adapter/CRUD/Read/Elements/Panels.cs @@ -54,26 +54,22 @@ private List ReadPanels(List ids = null) if (!(lusasSurfaces.Count() == 0)) { - IEnumerable edgesList = ReadEdges(); - Dictionary edges = edgesList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + IEnumerable edgesList = GetCachedOrRead(); + Dictionary edges = edgesList.ToDictionary(x => x.AdapterId(typeof(LusasId))); HashSet groupNames = ReadTags(); - IEnumerable materialList = ReadMaterials(); - Dictionary materials = materialList.ToDictionary( - x => x.Name.ToString()); - IEnumerable sectionPropertiesList = Read2DProperties(); - Dictionary sectionProperties = sectionPropertiesList.ToDictionary( - x => x.Name.ToString()); + IEnumerable materialList = GetCachedOrRead(); + Dictionary materials = materialList.ToDictionary(x => x.Name.ToString()); - IEnumerable supportsList = Read4DOFConstraints(); - Dictionary supports = supportsList.ToDictionary( - x => x.Name); + IEnumerable sectionPropertiesList = GetCachedOrRead(); + Dictionary sectionProperties = sectionPropertiesList.ToDictionary(x => x.Name.ToString()); - List meshesList = ReadMeshSettings2D(); - Dictionary meshes = meshesList.ToDictionary( - x => x.Name.ToString()); + IEnumerable supportsList = GetCachedOrRead(); + Dictionary supports = supportsList.ToDictionary(x => x.Name); + + List meshesList = GetCachedOrRead(); + Dictionary meshes = meshesList.ToDictionary(x => x.Name.ToString()); for (int i = 0; i < lusasSurfaces.Count(); i++) { diff --git a/Lusas_Adapter/CRUD/Read/Loads/AreaUniformTemperatureLoads.cs b/Lusas_Adapter/CRUD/Read/Loads/AreaUniformTemperatureLoads.cs index c818999c..347ef361 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/AreaUniformTemperatureLoads.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/AreaUniformTemperatureLoads.cs @@ -51,9 +51,8 @@ private List ReadAreaUniformTemperatureLoads(List ids = null) if (!(lusasTemperatureLoads.Count() == 0)) { - List panelsList = ReadPanels(); - Dictionary panels = panelsList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List panelsList = GetCachedOrRead(); + Dictionary panels = panelsList.ToDictionary(x => x.AdapterId(typeof(LusasId))); List allLoadcases = new List(); diff --git a/Lusas_Adapter/CRUD/Read/Loads/AreaUniformlyDistributedLoads.cs b/Lusas_Adapter/CRUD/Read/Loads/AreaUniformlyDistributedLoads.cs index adaff650..2bc753a1 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/AreaUniformlyDistributedLoads.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/AreaUniformlyDistributedLoads.cs @@ -57,9 +57,8 @@ private List ReadAreaUniformlyDistributedLoads(List ids = null) if (!(lusasDistributedLoads.Count() == 0)) { - List panelsList = ReadPanels(); - Dictionary panels = panelsList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List panelsList = GetCachedOrRead(); + Dictionary panels = panelsList.ToDictionary(x => x.AdapterId(typeof(LusasId))); List allLoadcases = new List(); diff --git a/Lusas_Adapter/CRUD/Read/Loads/BarPointLoads.cs b/Lusas_Adapter/CRUD/Read/Loads/BarPointLoads.cs index 49ad0033..9dea7dbe 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/BarPointLoads.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/BarPointLoads.cs @@ -52,9 +52,8 @@ private List ReadBarPointLoads(List ids = null) if (lusasInternalBeamPointLoads.Count() != 0) { - List barsList = ReadBars(); - Dictionary bars = barsList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List barsList = GetCachedOrRead(); + Dictionary bars = barsList.ToDictionary(x => x.AdapterId(typeof(LusasId))); List allLoadcases = new List(); diff --git a/Lusas_Adapter/CRUD/Read/Loads/BarUniformTemperatureLoads.cs b/Lusas_Adapter/CRUD/Read/Loads/BarUniformTemperatureLoads.cs index 8e9bf6c1..c5c4e559 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/BarUniformTemperatureLoads.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/BarUniformTemperatureLoads.cs @@ -51,9 +51,8 @@ private List ReadBarUniformTemperatureLoads(List ids = null) if (!(lusasTemperatureLoads.Count() == 0)) { - List barsList = ReadBars(); - Dictionary bars = barsList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List barsList = GetCachedOrRead(); + Dictionary bars = barsList.ToDictionary(x => x.AdapterId(typeof(LusasId))); List allLoadcases = new List(); diff --git a/Lusas_Adapter/CRUD/Read/Loads/BarUniformlyDistributedLoads.cs b/Lusas_Adapter/CRUD/Read/Loads/BarUniformlyDistributedLoads.cs index f4cfc05c..44581cfa 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/BarUniformlyDistributedLoads.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/BarUniformlyDistributedLoads.cs @@ -55,9 +55,8 @@ private List ReadBarUniformlyDistributedLoads(List ids = null) if (!(lusasDistributedLoads.Count() == 0)) { - List barsList = ReadBars(); - Dictionary bars = barsList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List barsList = GetCachedOrRead(); + Dictionary bars = barsList.ToDictionary(x => x.AdapterId(typeof(LusasId))); List allLoadcases = new List(); diff --git a/Lusas_Adapter/CRUD/Read/Loads/BarVaryingDistributedLoads.cs b/Lusas_Adapter/CRUD/Read/Loads/BarVaryingDistributedLoads.cs index 5ba11eb1..df5921aa 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/BarVaryingDistributedLoads.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/BarVaryingDistributedLoads.cs @@ -52,9 +52,8 @@ private List ReadBarVaryingDistributedLoads(List ids = null) if (lusasInternalBeamDistributedLoads.Count() != 0) { - List barsList = ReadBars(); - Dictionary bars = barsList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List barsList = GetCachedOrRead(); + Dictionary bars = barsList.ToDictionary(x => x.AdapterId(typeof(LusasId))); List allLoadcases = new List(); diff --git a/Lusas_Adapter/CRUD/Read/Loads/GravityLoads.cs b/Lusas_Adapter/CRUD/Read/Loads/GravityLoads.cs index 972be60f..26b7e462 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/GravityLoads.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/GravityLoads.cs @@ -51,15 +51,12 @@ private List ReadGravityLoads(List ids = null) if (!(lusasBodyForces.Count() == 0)) { - List nodesList = ReadNodes(); - List barsList = ReadBars(); - List panelsList = ReadPanels(); - Dictionary nodes = nodesList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); - Dictionary bars = barsList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); - Dictionary panels = panelsList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List nodeList = GetCachedOrRead(); + Dictionary nodes = nodeList.ToDictionary(x => x.AdapterId(typeof(LusasId))); + List barsList = GetCachedOrRead(); + Dictionary bars = barsList.ToDictionary(x => x.AdapterId(typeof(LusasId))); + List panelsList = GetCachedOrRead(); + Dictionary panels = panelsList.ToDictionary(x => x.AdapterId(typeof(LusasId))); List allLoadcases = new List(); diff --git a/Lusas_Adapter/CRUD/Read/Loads/LoadCombinations.cs b/Lusas_Adapter/CRUD/Read/Loads/LoadCombinations.cs index 722fe48c..cf953a37 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/LoadCombinations.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/LoadCombinations.cs @@ -48,9 +48,8 @@ private List ReadLoadCombinations(List ids = null) if (!(lusasCombinations.Count() == 0)) { - List lusasLoadcases = ReadLoadcases(); - Dictionary loadcaseDictionary = lusasLoadcases.ToDictionary( - x => x.Number.ToString()); + List lusasLoadcases = GetCachedOrRead(); + Dictionary loadcaseDictionary = lusasLoadcases.ToDictionary(x => x.Number.ToString()); for (int i = 0; i < lusasCombinations.Count(); i++) { diff --git a/Lusas_Adapter/CRUD/Read/Loads/PointDisplacements.cs b/Lusas_Adapter/CRUD/Read/Loads/PointDisplacements.cs index 6548d8a2..859b1729 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/PointDisplacements.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/PointDisplacements.cs @@ -51,9 +51,8 @@ private List ReadPointDisplacements(List ids = null) if (!(lusasPrescribedDisplacements.Count() == 0)) { - List nodesList = ReadNodes(); - Dictionary nodes = nodesList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List nodesList = GetCachedOrRead(); + Dictionary nodes = nodesList.ToDictionary(x => x.AdapterId(typeof(LusasId))); List allLoadcases = new List(); diff --git a/Lusas_Adapter/CRUD/Read/Loads/PointForces.cs b/Lusas_Adapter/CRUD/Read/Loads/PointForces.cs index 3e0ad4b7..20bffc0d 100644 --- a/Lusas_Adapter/CRUD/Read/Loads/PointForces.cs +++ b/Lusas_Adapter/CRUD/Read/Loads/PointForces.cs @@ -52,9 +52,8 @@ private List ReadPointLoads(List ids = null) if (!(lusasConcentratedLoads.Count() == 0)) { - List nodesList = ReadNodes(); - Dictionary nodes = nodesList.ToDictionary( - x => x.AdapterId(typeof(LusasId))); + List nodesList = GetCachedOrRead(); + Dictionary nodes = nodesList.ToDictionary(x => x.AdapterId(typeof(LusasId))); List allLoadcases = new List();