From dc941e432d31f3c15f250f36f120c5e805204bc0 Mon Sep 17 00:00:00 2001 From: sbosse Date: Fri, 29 Nov 2024 16:32:08 +0100 Subject: [PATCH] Fri 29 Nov 2024 04:30:50 PM CET --- src/SimNDT/core/checkSimulation.py | 85 ++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/SimNDT/core/checkSimulation.py diff --git a/src/SimNDT/core/checkSimulation.py b/src/SimNDT/core/checkSimulation.py new file mode 100644 index 0000000..97aa396 --- /dev/null +++ b/src/SimNDT/core/checkSimulation.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +# encoding: utf-8 +""" +checkSimulation.py + +Created by Miguel Molero on 2013-10-04. +Copyright (c) 2013 MMolero. All rights reserved. +""" + +import numpy as np +import copy + +from SimNDT.core.constants import * +from SimNDT.core.boundary import Boundary +# from MainWindow import openSim + + +def boundaries(Scenario, Boundaries): + if np.size(Scenario.Iabs) == 1: + names = ["Top","Bottom", "Left", "Right"] + Boundaries = [Boundary(name, BC=BC.AirLayer, size=0) for name in names] + + return Boundaries + + + +def boundariesReLoad(Scenario, Materials, Boundaries, Transducer, Inspection, Simulation=None): + + """ + + :rtype : object + """ + + isChange = False + + if np.size(Scenario.Iabs) == 1: + names = ["Top","Bottom", "Left", "Right"] + boundaries = [Boundary(name, BC=BC.AirLayer, size=0) for name in names] + Boundaries = copy.deepcopy(boundaries) + Scenario.createBoundaries(boundaries) + isChange = True + + if Simulation is not None: + Simulation.reLoad(Materials, Scenario,Transducer) + + return Scenario, Boundaries, isChange + + +def labels(Scenario, Materials): + numLabels = np.size(np.unique(Scenario.I)) + numMaterials = len(Materials) + if numLabels == numMaterials: + return 0 + elif numLabels > numMaterials: + return 1 + elif numLabels < numMaterials: + return 2 + +def isLabelsEquals(Scenario, Materials): + labels = np.unique(Scenario.I).tolist() + mat = [material.Label for material in Materials] + s1 = set(labels) + s2 = set(mat) + if s1.issubset(s2): + return 0 + else: + return 1 + + +def materials(Materials): + mat = [material.Label for material in Materials] + length = len(mat) + unique_Length = np.size(np.unique(mat)) + if length == unique_Length: + return 0 + else: + return 1 + + + + + + + + \ No newline at end of file