# -*- coding: utf-8 -*-
"""
PROGRAM SOLIDS
--------------
Computes the displacement solution for a finite element assembly
of 2D solids under point loads using as input easy-to-create
text files containing element, nodal, materials and loads data.
The input files are created out of a Gmsh (.msh) generated file
using python module meshio.py.

Created by Juan Gomez and Nicolas Guarin-Zapata as part of the courses:

IC0283 COMPUTATIONAL MODELLING
IC0602 INTRODUCTION TO THE FINITE ELEMENT METHOD
Universidad EAFIT
Departamento de Ingenieria Civil

"""
from __future__ import division, print_function


def solids_GUI():   
    import numpy as np
    from datetime import datetime
    import matplotlib.pyplot as plt
    import preprocesor as pre
    import postprocesor as pos
    import assemutil as ass
    import solutil as sol
    
    folder = pre.initial_params()
    start_time = datetime.now()
    echo = False
    
    #%% PRE-PROCESSING
    nodes, mats, elements, loads = pre.readin(folder=folder)
    if echo:
        pre.echomod(nodes, mats, elements, loads, folder=folder)
    DME , IBC , neq = ass.DME(nodes, elements)
    print("Number of nodes: {}".format(nodes.shape[0]))
    print("Number of elements: {}".format(elements.shape[0]))
    print("Number of equations: {}".format(neq))
    
    #%% SYSTEM ASSEMBLY
    KG = ass.assembler(elements, mats, nodes, neq, DME)
    RHSG = ass.loadasem(loads, IBC, neq)
    
    #%% SYSTEM SOLUTION
    UG = sol.static_sol(KG, RHSG)
    if not(np.allclose(KG.dot(UG)/KG.max(), RHSG/KG.max())):
        print("The system is not in equilibrium!")
    end_time = datetime.now()
    del KG
    print('Duration for system solution: {}'.format(end_time - start_time))
    
    #%% POST-PROCESSING
    start_time = datetime.now()
    UC = pos.complete_disp(IBC, nodes, UG)
    E_nodes, S_nodes = pos.strain_nodes(nodes , elements, mats, UC)
    pos.fields_plot(elements, nodes, UC, E_nodes=E_nodes, S_nodes=S_nodes)
    end_time = datetime.now()
    print('Duration for post processing: {}'.format(end_time - start_time))
    print('Analysis terminated successfully!')
    plt.show()

if __name__ == '__main__':
    solids_GUI()
@@ -25,38 +25,8 @@
 %22%22%22%0A
-PROGRAM SOLIDS%0A--------------%0A
 Comp
@@ -568,35 +568,40 @@
 ion%0A
-%0A%0Adef solids_GUI():   %0A    
+import matplotlib.pyplot as plt%0A
 impo
@@ -615,20 +615,16 @@
 y as np%0A
-    
 from dat
@@ -649,159 +649,892 @@
 ime%0A
-    import matplotlib.pyplot as plt%0A    import preprocesor as pre%0A    import postprocesor as pos%0A    import assemutil as ass%0A    import solutil as sol%0A
+import solidspy.preprocesor as pre%0Aimport solidspy.postprocesor as pos%0Aimport solidspy.assemutil as ass%0Aimport solidspy.solutil as sol%0A%0Adef solids_GUI(compute_strains=False, plot_contours=True):%0A    %22%22%22%0A    Run a complete workflow for a Finite Element Analysis%0A    %0A    Parameters%0A    ----------%0A    compute_strains : Bool (optional)%0A      Boolean variable to compute Strains and Stresses at nodes.%0A      By default it is False.%0A    plot_contours : Bool (optional)%0A      Boolean variable to plot contours of the computed variables.%0A      By default it is True.%0A%0A    Returns%0A    -------%0A    UC : ndarray (nnodes, 2)%0A      Displacements at nodes.%0A    E_nodes : ndarray (nnodes, 3), optional%0A      Strains at nodes. It is returned when %60compute_strains%60 is True.%0A    S_nodes : ndarray (nnodes, 3), optional%0A      Stresses at nodes. It is returned when %60compute_strains%60 is True.%0A%0A    %22%22%22
     
@@ -2333,19 +2333,8 @@
 w()%0A
-    del KG%0A
     
@@ -2531,16 +2531,78 @@
 _nodes =
+ None, None%0A    if compute_strains:%0A        E_nodes, S_nodes =
  pos.str
@@ -2639,16 +2639,42 @@
 ts, UC)%0A
+    if plot_contours:%0A    
     pos.
@@ -2901,18 +2901,62 @@
     
-plt.show()
+return UC, E_nodes, S_nodes if compute_strains else UC
 %0A%0Aif
@@ -2996,8 +2996,23 @@
 ds_GUI()
+%0A    plt.show()

Add optional outputs to solids_GUI