From 9ca84efe160c008f6b223cf32ad7d2c1bb2d8f11 Mon Sep 17 00:00:00 2001
From: imcovangent <I.vanGent@tudelft.nl>
Date: Fri, 19 May 2017 17:58:14 +0200
Subject: [PATCH] graph_kadmos.py - create_dsm() - extended creation of MDG
 without MPG

Former-commit-id: 47466ff1ce7a32a3a811eb18224135ef9dbed803
---
 kadmos/graph/graph_kadmos.py | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/kadmos/graph/graph_kadmos.py b/kadmos/graph/graph_kadmos.py
index d61a9a497..62d851ba8 100644
--- a/kadmos/graph/graph_kadmos.py
+++ b/kadmos/graph/graph_kadmos.py
@@ -509,7 +509,7 @@ class KadmosGraph(nx.DiGraph, VispackMixin):
         :type function_order: list
         """
 
-        from graph_data import RepositoryConnectivityGraph, FundamentalProblemGraph
+        from graph_data import RepositoryConnectivityGraph, FundamentalProblemGraph, MdaoDataGraph
 
         # Input assertions
         assert isinstance(open_pdf, bool)
@@ -565,6 +565,8 @@ class KadmosGraph(nx.DiGraph, VispackMixin):
                 else:
                     if 'function_order' in graph.graph['problem_formulation']:
                         diagonal_nodes = graph.graph['problem_formulation']['function_order']
+                        assert not set(diagonal_nodes).symmetric_difference(set(function_nodes)), \
+                            'Function order of graph does not contain all function nodes, give function_order manually.'
                     else:
                         diagonal_nodes = function_nodes
             else:
@@ -607,6 +609,34 @@ class KadmosGraph(nx.DiGraph, VispackMixin):
                     else:
                         print 'WARNING: An invalid FPG has been provided: problem_role missing for: %s.' % node
                         node_style = 'RcgAnalysis'
+                elif isinstance(graph, MdaoDataGraph):
+                    if 'architecture_role' in graph.node[node]:
+                        if graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[0]:  # coordinator
+                            node_style = 'Coordinator'
+                        elif graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[1]:  # optimizer
+                            node_style = 'Optimization'
+                        elif graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[2]:  # converger
+                            node_style = 'Converger'
+                        elif graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[3]:  # doe
+                            node_style = 'DOE'
+                        elif graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[4]:  # pre-coupling an.
+                            node_style = 'PreAnalysis'
+                        elif graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[5]:  # pre-iterator an.
+                            node_style = 'PreAnalysis'
+                        elif graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[6]:  # post-iterator an.
+                            node_style = 'PreAnalysis'
+                        elif graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[7]:  # coupled an.
+                            node_style = 'CoupledAnalysis'
+                        elif graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[8]:  # post-coupling an.
+                            node_style = 'PostAnalysis'
+                        elif graph.node[node]['architecture_role'] == graph.ARCHITECTURE_ROLES_FUNS[9]:  # cons. const. fun.
+                            node_style = 'PostAnalysis'
+                        else:
+                            raise AssertionError('Architecture role %s is not supported for creation of XDSMs.'
+                                                 % graph_mpg.node[node]['architecture_role'])
+                    else:
+                        print 'WARNING: An invalid MDG has been provided: architecture_role missing for: %s.' % node
+                        node_style = 'RcgAnalysis'
                 else:
                     node_style = 'RcgAnalysis'
 
-- 
GitLab