Skip to content

Commit

Permalink
Replace Read statements with GetCachedOrRead to improve speeds
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjamesnugent authored and Fraser Greenroyd committed Jun 28, 2023
1 parent ba19c29 commit 3878478
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 72 deletions.
25 changes: 10 additions & 15 deletions Lusas_Adapter/CRUD/Read/Elements/Bars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,20 @@ private List<Bar> ReadBars(List<string> ids = null)

if (!(lusasLines.Count() == 0))
{
IEnumerable<Node> nodesList = ReadNodes();
Dictionary<string, Node> nodes = nodesList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
IEnumerable<Node> nodesList = GetCachedOrRead<Node>();
Dictionary<string, Node> nodes = nodesList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

IEnumerable<Constraint4DOF> supportsList = Read4DOFConstraints();
Dictionary<string, Constraint4DOF> supports = supportsList.ToDictionary(
x => x.Name);
IEnumerable<Constraint4DOF> supportsList = GetCachedOrRead<Constraint4DOF>();
Dictionary<string, Constraint4DOF> supports = supportsList.ToDictionary(x => x.Name);

IEnumerable<IMaterialFragment> materialList = ReadMaterials();
Dictionary<string, IMaterialFragment> materials = materialList.ToDictionary(
x => x.Name.ToString());
IEnumerable<IMaterialFragment> materialList = GetCachedOrRead<IMaterialFragment>();
Dictionary<string, IMaterialFragment> materials = materialList.ToDictionary(x => x.Name.ToString());

IEnumerable<ISectionProperty> sectionPropertiesList = ReadSectionProperties();
Dictionary<string, ISectionProperty> sectionProperties = sectionPropertiesList.ToDictionary(
x => x.Name.ToString());
IEnumerable<ISectionProperty> sectionPropertiesList = GetCachedOrRead<ISectionProperty>();
Dictionary<string, ISectionProperty> sectionProperties = sectionPropertiesList.ToDictionary(x => x.Name.ToString());

List<MeshSettings1D> meshesList = ReadMeshSettings1D();
Dictionary<string, MeshSettings1D> meshes = meshesList.ToDictionary(
x => x.Name.ToString());
List<MeshSettings1D> meshesList = GetCachedOrRead<MeshSettings1D>();
Dictionary<string, MeshSettings1D> meshes = meshesList.ToDictionary(x => x.Name.ToString());

HashSet<string> groupNames = ReadTags();

Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Elements/Edges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ private List<Edge> ReadEdges(List<string> ids = null)

if (lusasLines.Count() != 0)
{
List<Node> nodesList = ReadNodes();
Dictionary<string, Node> nodes = nodesList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Node> nodesList = GetCachedOrRead<Node>();
Dictionary<string, Node> nodes = nodesList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

HashSet<string> groupNames = ReadTags();

Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Elements/Nodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ private List<Node> ReadNodes(List<string> ids = null)
{
HashSet<string> groupNames = ReadTags();

IEnumerable<Constraint6DOF> constraints6DOFList = Read6DOFConstraints();
Dictionary<string, Constraint6DOF> constraints6DOF = constraints6DOFList.ToDictionary(
x => x.Name.ToString());
IEnumerable<Constraint6DOF> constraints6DOFList = GetCachedOrRead<Constraint6DOF>();
Dictionary<string, Constraint6DOF> constraints6DOF = constraints6DOFList.ToDictionary(x => x.Name.ToString());

for (int i = 0; i < lusasPoints.Count(); i++)
{
Expand Down
26 changes: 11 additions & 15 deletions Lusas_Adapter/CRUD/Read/Elements/Panels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,22 @@ private List<Panel> ReadPanels(List<string> ids = null)

if (!(lusasSurfaces.Count() == 0))
{
IEnumerable<Edge> edgesList = ReadEdges();
Dictionary<string, Edge> edges = edgesList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
IEnumerable<Edge> edgesList = GetCachedOrRead<Edge>();
Dictionary<string, Edge> edges = edgesList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

HashSet<string> groupNames = ReadTags();
IEnumerable<IMaterialFragment> materialList = ReadMaterials();
Dictionary<string, IMaterialFragment> materials = materialList.ToDictionary(
x => x.Name.ToString());

IEnumerable<ISurfaceProperty> sectionPropertiesList = Read2DProperties();
Dictionary<string, ISurfaceProperty> sectionProperties = sectionPropertiesList.ToDictionary(
x => x.Name.ToString());
IEnumerable<IMaterialFragment> materialList = GetCachedOrRead<IMaterialFragment>();
Dictionary<string, IMaterialFragment> materials = materialList.ToDictionary(x => x.Name.ToString());

IEnumerable<Constraint4DOF> supportsList = Read4DOFConstraints();
Dictionary<string, Constraint4DOF> supports = supportsList.ToDictionary(
x => x.Name);
IEnumerable<ISurfaceProperty> sectionPropertiesList = GetCachedOrRead<ISurfaceProperty>();
Dictionary<string, ISurfaceProperty> sectionProperties = sectionPropertiesList.ToDictionary(x => x.Name.ToString());

List<MeshSettings2D> meshesList = ReadMeshSettings2D();
Dictionary<string, MeshSettings2D> meshes = meshesList.ToDictionary(
x => x.Name.ToString());
IEnumerable<Constraint4DOF> supportsList = GetCachedOrRead<Constraint4DOF>();
Dictionary<string, Constraint4DOF> supports = supportsList.ToDictionary(x => x.Name);

List<MeshSettings2D> meshesList = GetCachedOrRead<MeshSettings2D>();
Dictionary<string, MeshSettings2D> meshes = meshesList.ToDictionary(x => x.Name.ToString());

for (int i = 0; i < lusasSurfaces.Count(); i++)
{
Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Loads/AreaUniformTemperatureLoads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ private List<ILoad> ReadAreaUniformTemperatureLoads(List<string> ids = null)

if (!(lusasTemperatureLoads.Count() == 0))
{
List<Panel> panelsList = ReadPanels();
Dictionary<string, Panel> panels = panelsList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Panel> panelsList = GetCachedOrRead<Panel>();
Dictionary<string, Panel> panels = panelsList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

List<IFLoadcase> allLoadcases = new List<IFLoadcase>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ private List<ILoad> ReadAreaUniformlyDistributedLoads(List<string> ids = null)

if (!(lusasDistributedLoads.Count() == 0))
{
List<Panel> panelsList = ReadPanels();
Dictionary<string, Panel> panels = panelsList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Panel> panelsList = GetCachedOrRead<Panel>();
Dictionary<string, Panel> panels = panelsList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

List<IFLoadcase> allLoadcases = new List<IFLoadcase>();

Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Loads/BarPointLoads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ private List<ILoad> ReadBarPointLoads(List<string> ids = null)

if (lusasInternalBeamPointLoads.Count() != 0)
{
List<Bar> barsList = ReadBars();
Dictionary<string, Bar> bars = barsList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Bar> barsList = GetCachedOrRead<Bar>();
Dictionary<string, Bar> bars = barsList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

List<IFLoadcase> allLoadcases = new List<IFLoadcase>();

Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Loads/BarUniformTemperatureLoads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ private List<ILoad> ReadBarUniformTemperatureLoads(List<string> ids = null)

if (!(lusasTemperatureLoads.Count() == 0))
{
List<Bar> barsList = ReadBars();
Dictionary<string, Bar> bars = barsList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Bar> barsList = GetCachedOrRead<Bar>();
Dictionary<string, Bar> bars = barsList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

List<IFLoadcase> allLoadcases = new List<IFLoadcase>();

Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Loads/BarUniformlyDistributedLoads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ private List<ILoad> ReadBarUniformlyDistributedLoads(List<string> ids = null)

if (!(lusasDistributedLoads.Count() == 0))
{
List<Bar> barsList = ReadBars();
Dictionary<string, Bar> bars = barsList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Bar> barsList = GetCachedOrRead<Bar>();
Dictionary<string, Bar> bars = barsList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

List<IFLoadcase> allLoadcases = new List<IFLoadcase>();

Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Loads/BarVaryingDistributedLoads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ private List<ILoad> ReadBarVaryingDistributedLoads(List<string> ids = null)

if (lusasInternalBeamDistributedLoads.Count() != 0)
{
List<Bar> barsList = ReadBars();
Dictionary<string, Bar> bars = barsList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Bar> barsList = GetCachedOrRead<Bar>();
Dictionary<string, Bar> bars = barsList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

List<IFLoadcase> allLoadcases = new List<IFLoadcase>();

Expand Down
15 changes: 6 additions & 9 deletions Lusas_Adapter/CRUD/Read/Loads/GravityLoads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ private List<ILoad> ReadGravityLoads(List<string> ids = null)

if (!(lusasBodyForces.Count() == 0))
{
List<Node> nodesList = ReadNodes();
List<Bar> barsList = ReadBars();
List<Panel> panelsList = ReadPanels();
Dictionary<string, Node> nodes = nodesList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
Dictionary<string, Bar> bars = barsList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
Dictionary<string, Panel> panels = panelsList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Node> nodeList = GetCachedOrRead<Node>();
Dictionary<string, Node> nodes = nodeList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));
List<Bar> barsList = GetCachedOrRead<Bar>();
Dictionary<string, Bar> bars = barsList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));
List<Panel> panelsList = GetCachedOrRead<Panel>();
Dictionary<string, Panel> panels = panelsList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

List<IFLoadcase> allLoadcases = new List<IFLoadcase>();

Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Loads/LoadCombinations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ private List<LoadCombination> ReadLoadCombinations(List<string> ids = null)

if (!(lusasCombinations.Count() == 0))
{
List<Loadcase> lusasLoadcases = ReadLoadcases();
Dictionary<string, Loadcase> loadcaseDictionary = lusasLoadcases.ToDictionary(
x => x.Number.ToString());
List<Loadcase> lusasLoadcases = GetCachedOrRead<Loadcase>();
Dictionary<string, Loadcase> loadcaseDictionary = lusasLoadcases.ToDictionary(x => x.Number.ToString());

for (int i = 0; i < lusasCombinations.Count(); i++)
{
Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Loads/PointDisplacements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ private List<ILoad> ReadPointDisplacements(List<string> ids = null)

if (!(lusasPrescribedDisplacements.Count() == 0))
{
List<Node> nodesList = ReadNodes();
Dictionary<string, Node> nodes = nodesList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Node> nodesList = GetCachedOrRead<Node>();
Dictionary<string, Node> nodes = nodesList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

List<IFLoadcase> allLoadcases = new List<IFLoadcase>();

Expand Down
5 changes: 2 additions & 3 deletions Lusas_Adapter/CRUD/Read/Loads/PointForces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ private List<ILoad> ReadPointLoads(List<string> ids = null)

if (!(lusasConcentratedLoads.Count() == 0))
{
List<Node> nodesList = ReadNodes();
Dictionary<string, Node> nodes = nodesList.ToDictionary(
x => x.AdapterId<string>(typeof(LusasId)));
List<Node> nodesList = GetCachedOrRead<Node>();
Dictionary<string, Node> nodes = nodesList.ToDictionary(x => x.AdapterId<string>(typeof(LusasId)));

List<IFLoadcase> allLoadcases = new List<IFLoadcase>();

Expand Down

0 comments on commit 3878478

Please sign in to comment.