From a930d35a3c5b6785c5130aaebd58bec842ad726b Mon Sep 17 00:00:00 2001 From: sbosse Date: Wed, 28 Aug 2024 21:38:56 +0200 Subject: [PATCH] Wed 28 Aug 21:38:52 CEST 2024 --- src/SimNDT/core/checkSimulation.py | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 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..160cd37 --- /dev/null +++ b/src/SimNDT/core/checkSimulation.py @@ -0,0 +1,84 @@ +#!/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 + + +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