def test_GetSetProcessInfoData(self): settings_scal = KM.Parameters("""{ "model_part_name" : "mp_4_test", "location" : "process_info", "variable_name" : "NODAL_ERROR" }""") settings_vec = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "NORMAL", "location" : "process_info", "dimension" : 2 }""") coupling_data_scal = CouplingInterfaceData(settings_scal, self.model) coupling_data_vec = CouplingInterfaceData(settings_vec, self.model) coupling_data_scal.Initialize() coupling_data_vec.Initialize() # 1. check the initial values self.__CheckData([process_info_scalar_value], coupling_data_scal.GetData()) self.__CheckData( [process_info_vector_value[0], process_info_vector_value[1]], coupling_data_vec.GetData()) # 2. check setting and getting works set_data_scal = [model_part_scalar_value] set_data_vec = [model_part_vector_value[0], model_part_vector_value[1]] self.__CheckSetGetData(set_data_scal, coupling_data_scal) self.__CheckSetGetData(set_data_vec, coupling_data_vec)
def test_wrong_input_set_data(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE" }""") settings_model_part = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE", "location" : "model_part" }""") coupling_data = CouplingInterfaceData(settings, self.model) coupling_data.Initialize() coupling_data_mp = CouplingInterfaceData(settings_model_part, self.model) coupling_data_mp.Initialize() wrong_data = [1,2,3] correct_data = [1,2,3,4,5] with self.assertRaisesRegex(Exception, "The sizes of the data are not matching, got: 3, expected: 5"): coupling_data.SetData(wrong_data) with self.assertRaisesRegex(Exception, "The buffer-size is not large enough: current buffer size: 2 | requested solution_step_index: 3"): coupling_data.SetData(correct_data, 2) with self.assertRaisesRegex(Exception, "accessing data from previous steps is only possible with historical nodal data!"): coupling_data_mp.SetData(correct_data, 2)
def test_GetHistoricalVariableDict(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE" }""") coupling_data = CouplingInterfaceData(settings, self.model) exp_dict = {"mp_4_test": KM.PRESSURE} dict_res = coupling_data.GetHistoricalVariableDict() self.assertEqual(len(exp_dict), len(dict_res)) self.assertEqual(exp_dict["mp_4_test"].Name(), dict_res["mp_4_test"].Name()) # this should not give anything since there are no historical variables in this case settings_2 = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE", "location" : "element" }""") coupling_data_2 = CouplingInterfaceData(settings_2, self.model) exp_dict_2 = {} dict_res_2 = coupling_data_2.GetHistoricalVariableDict() self.assertEqual(len(exp_dict_2), len(dict_res_2))
def test_GetSetModelPartData(self): settings_scal = KM.Parameters("""{ "model_part_name" : "mp_4_test", "location" : "model_part", "variable_name" : "NODAL_MASS" }""") settings_vec = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "TORQUE", "location" : "model_part", "dimension" : 1 }""") self.mp.ProcessInfo[KM.DOMAIN_SIZE] = 1 coupling_data_scal = CouplingInterfaceData(settings_scal, self.model) coupling_data_vec = CouplingInterfaceData(settings_vec, self.model) coupling_data_scal.Initialize() coupling_data_vec.Initialize() # 1. check the initial values self.__CheckData([model_part_scalar_value], coupling_data_scal.GetData()) self.__CheckData([model_part_vector_value[0]], coupling_data_vec.GetData()) # 2. check setting and getting works set_data_scal = [model_part_scalar_value_2] set_data_vec = [model_part_vector_value_2[0]] self.__CheckSetGetData(set_data_scal, coupling_data_scal) self.__CheckSetGetData(set_data_vec, coupling_data_vec)
def test_GetSetElementalData(self): settings_scal = KM.Parameters("""{ "model_part_name" : "mp_4_test", "location" : "element", "variable_name" : "DENSITY" }""") settings_vec = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "FORCE", "location" : "element", "dimension" : 2 }""") coupling_data_scal = CouplingInterfaceData(settings_scal, self.model) coupling_data_vec = CouplingInterfaceData(settings_vec, self.model) coupling_data_scal.Initialize() coupling_data_vec.Initialize() # 1. check the initial values exp_data_scal = [ElementScalarValue(elem.Id) for elem in self.mp.Elements] exp_data_vec = GetVectorValues(self.mp.Elements, ElementVectorValue, 2) self.__CheckData(exp_data_scal, coupling_data_scal.GetData()) self.__CheckData(exp_data_vec, coupling_data_vec.GetData()) # 2. check setting and getting works set_data_scal = [NodeScalarNonHistValue(elem.Id) for elem in self.mp.Elements] set_data_vec = GetVectorValues(self.mp.Elements, NodeVectorNonHistValue, 2) self.__CheckSetGetData(set_data_scal, coupling_data_scal) self.__CheckSetGetData(set_data_vec, coupling_data_vec)
def test_GetSetConditionalData(self): if using_pykratos: self.skipTest("This test cannot be run with pyKratos!") settings_scal = KM.Parameters("""{ "model_part_name" : "mp_4_test", "location" : "condition", "variable_name" : "YOUNG_MODULUS" }""") settings_vec = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "ROTATION", "location" : "condition", "dimension" : 2 }""") coupling_data_scal = CouplingInterfaceData(settings_scal, self.model) coupling_data_vec = CouplingInterfaceData(settings_vec, self.model) coupling_data_scal.Initialize() coupling_data_vec.Initialize() # 1. check the initial values exp_data_scal = [ConditionScalarValue(cond.Id) for cond in self.mp.Conditions] exp_data_vec = GetVectorValues(self.mp.Conditions, ConditionVectorValue, 2) self.__CheckData(exp_data_scal, coupling_data_scal.GetData()) self.__CheckData(exp_data_vec, coupling_data_vec.GetData()) # 2. check setting and getting works set_data_scal = [NodeScalarHistValuePrevious(cond.Id) for cond in self.mp.Conditions] set_data_vec = GetVectorValues(self.mp.Conditions, NodeVectorHistValuePrevious, 2) self.__CheckSetGetData(set_data_scal, coupling_data_scal) self.__CheckSetGetData(set_data_vec, coupling_data_vec)
def test_basics(self): settings_scal_hist = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE" }""") settings_vec_elem = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "DISPLACEMENT", "location" : "element", "dimension" : 2 }""") coupling_data_scal = CouplingInterfaceData(settings_scal_hist, self.model) coupling_data_scal.Initialize() coupling_data_vec = CouplingInterfaceData(settings_vec_elem, self.model) coupling_data_vec.Initialize() self.assertEqual(coupling_data_scal.GetModelPart().Name, "mp_4_test") self.assertEqual(coupling_data_vec.GetModelPart().Name, "mp_4_test") self.assertFalse(coupling_data_scal.GetModelPart().IsDistributed()) self.assertFalse(coupling_data_vec.GetModelPart().IsDistributed()) self.assertEqual(coupling_data_scal.Size(), 5) # 5 nodes and scalar var self.assertEqual(coupling_data_vec.Size(), 14) # 7 elements and vector var with dim==2 self.assertEqual(coupling_data_scal.GetBufferSize(), 2) self.assertEqual(coupling_data_vec.GetBufferSize(), 1)
def test_GetSetNodalNonHistoricalData(self): settings_scal = KM.Parameters("""{ "model_part_name" : "mp_4_test", "location" : "node_non_historical", "variable_name" : "TEMPERATURE" }""") settings_vec = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "VELOCITY", "location" : "node_non_historical", "dimension" : 3 }""") self.mp.ProcessInfo[KM.DOMAIN_SIZE] = 3 coupling_data_scal = CouplingInterfaceData(settings_scal, self.model) coupling_data_vec = CouplingInterfaceData(settings_vec, self.model) coupling_data_scal.Initialize() coupling_data_vec.Initialize() # 1. check the initial values exp_data_scal = [NodeScalarNonHistValue(node.Id) for node in self.mp.Nodes] exp_data_vec = GetVectorValues(self.mp.Nodes, NodeVectorNonHistValue, 3) self.__CheckData(exp_data_scal, coupling_data_scal.GetData()) self.__CheckData(exp_data_vec, coupling_data_vec.GetData()) # 2. check setting and getting works set_data_scal = [ConditionScalarValue(node.Id) for node in self.mp.Nodes] set_data_vec = GetVectorValues(self.mp.Nodes, ConditionVectorValue, 3) self.__CheckSetGetData(set_data_scal, coupling_data_scal) self.__CheckSetGetData(set_data_vec, coupling_data_vec)
def test_Export_ImportCouplingData(self): p = self.__RunPythonInSubProcess("import_export_data") model = KM.Model() io_settings = KM.Parameters("""{ "connect_to" : "impExp" }""") solver_name = "ExpImp" # aka "my_name" for the CoSimIO kratos_co_sim_io = CreateKratosCoSimIO(io_settings, model, solver_name) # this connects kratos_co_sim_io.Initialize() model_part = model.CreateModelPart("for_test") model_part.AddNodalSolutionStepVariable(KM.PRESSURE) model_part.AddNodalSolutionStepVariable(KM.TEMPERATURE) for i in range(5): node = model_part.CreateNewNode( i + 1, 0.0, 0.0, 0.0) # using same coord, doesn't matter for this test node.SetSolutionStepValue(KM.PRESSURE, i * 1.7) settings_pres = KM.Parameters("""{ "model_part_name" : "for_test", "variable_name" : "PRESSURE" }""") settings_temp = KM.Parameters("""{ "model_part_name" : "for_test", "variable_name" : "TEMPERATURE" }""") interface_data_pres = CouplingInterfaceData(settings_pres, model, "data_exchange_1") interface_data_temp = CouplingInterfaceData(settings_temp, model, "data_exchange_2") interface_data_pres.Initialize() interface_data_temp.Initialize() data_configuration_export = { "type": "coupling_interface_data", "interface_data": interface_data_pres } kratos_co_sim_io.ExportData(data_configuration_export) data_configuration_import = { "type": "coupling_interface_data", "interface_data": interface_data_temp } kratos_co_sim_io.ImportData(data_configuration_import) kratos_co_sim_io.Finalize() # this disconnects # checking the values after disconnecting to avoid deadlock for i, node in enumerate(model_part.Nodes): self.assertAlmostEqual(node.GetSolutionStepValue(KM.TEMPERATURE), i * 1.7) self.__CheckSubProcess(p)
def test_GetSetNodalHistoricalData(self): settings_scal = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE" }""") settings_vec = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "DISPLACEMENT", "dimension" : 2 }""") coupling_data_scal = CouplingInterfaceData(settings_scal, self.model) coupling_data_vec = CouplingInterfaceData(settings_vec, self.model) coupling_data_scal.Initialize() coupling_data_vec.Initialize() # 1. check the initial values exp_data_scal_cur = [ NodeScalarHistValueCurrent(node.Id) for node in self.mp.Nodes ] exp_data_scal_prev = [ NodeScalarHistValuePrevious(node.Id) for node in self.mp.Nodes ] exp_data_vec_cur = GetVectorValues(self.mp.Nodes, NodeVectorHistValueCurrent, 2) exp_data_vec_prev = GetVectorValues(self.mp.Nodes, NodeVectorHistValuePrevious, 2) self.__CheckData(exp_data_scal_cur, coupling_data_scal.GetData()) self.__CheckData(exp_data_vec_cur, coupling_data_vec.GetData()) self.__CheckData(exp_data_scal_prev, coupling_data_scal.GetData(1)) self.__CheckData(exp_data_vec_prev, coupling_data_vec.GetData(1)) # 2. check setting and getting works set_data_scal_cur = [ ElementScalarValue(node.Id) for node in self.mp.Nodes ] set_data_scal_prev = [ ConditionScalarValue(node.Id) for node in self.mp.Nodes ] set_data_vec_cur = GetVectorValues(self.mp.Nodes, ElementVectorValue, 2) set_data_vec_prev = GetVectorValues(self.mp.Nodes, ConditionVectorValue, 2) self.__CheckSetGetData(set_data_scal_cur, coupling_data_scal) self.__CheckSetGetData(set_data_vec_cur, coupling_data_vec) self.__CheckSetGetData(set_data_scal_prev, coupling_data_scal, 1) self.__CheckSetGetData(set_data_vec_prev, coupling_data_vec, 1)
def test_unallowed_names(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE" }""") with self.assertRaisesRegex(Exception, 'The name cannot be empty, contain whitespaces or "."!'): CouplingInterfaceData(settings, self.model, "") with self.assertRaisesRegex(Exception, 'The name cannot be empty, contain whitespaces or "."!'): CouplingInterfaceData(settings, self.model, "aaa.bbbb") with self.assertRaisesRegex(Exception, 'The name cannot be empty, contain whitespaces or "."!'): CouplingInterfaceData(settings, self.model, "aaa bbb")
def __init__(self, settings, name): """Constructor of the Base Solver Wrapper The derived classes should do the following things in their constructors: 1. call the base-class constructor (i.e. the constructor of this class => CoSimulationSolverWrapper) 2. create the ModelParts required for the CoSimulation 3. Optional: call "_AllocateHistoricalVariablesFromCouplingData" to allocate the nodal historical variables on the previously created ModelParts (this should not be necessary for Kratos) => this has to be done before the meshes/coupling-interfaces are read/received/imported (due to how the memory allocation of Kratos works for historical nodal values) """ # Every SolverWrapper has its own model, because: # - the names can be easily overlapping (e.g. "Structure.Interface") # - Solvers should not be able to access the data of other solvers directly! self.model = KM.Model() self.settings = settings self.settings.ValidateAndAssignDefaults(self._GetDefaultSettings()) self.name = name self.echo_level = self.settings["echo_level"].GetInt() self.data_dict = { data_name: CouplingInterfaceData(data_config, self.model, data_name, self.name) for (data_name, data_config) in self.settings["data"].items() } # The IO is only used if the corresponding solver is used in coupling and it initialized from the "higher instance, i.e. the coupling-solver self.__io = None
def setUp(self): self.model = KM.Model() self.model_part = self.model.CreateModelPart("default") self.model_part.AddNodalSolutionStepVariable(KM.PRESSURE) self.model_part.AddNodalSolutionStepVariable(KM.PARTITION_INDEX) self.dimension = 3 self.model_part.ProcessInfo[KM.DOMAIN_SIZE] = self.dimension self.my_pid = KM.DataCommunicator.GetDefault().Rank() self.num_nodes = self.my_pid % 5 + 3 # num_nodes in range (3 ... 7) if self.my_pid == 4: self.num_nodes = 0 # in order to emulate one partition not having local nodes for i in range(self.num_nodes): node = self.model_part.CreateNewNode( i, 0.1 * i, 0.0, 0.0 ) # this creates the same coords in different ranks, which does not matter for this test node.SetSolutionStepValue(KM.PARTITION_INDEX, self.my_pid) node.SetSolutionStepValue(KM.PRESSURE, uniform(-10, 50)) if KM.IsDistributedRun(): KratosMPI.ParallelFillCommunicator(self.model_part).Execute() data_settings = KM.Parameters("""{ "model_part_name" : "default", "variable_name" : "PRESSURE" }""") self.interface_data = CouplingInterfaceData(data_settings, self.model) self.interface_data.Initialize() self.dummy_solver_wrapper = DummySolverWrapper( {"data_4_testing": self.interface_data})
def test_without_initialization(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "DISPLACEMENT", "dimension" : 2 }""") coupling_data = CouplingInterfaceData(settings, self.model) # coupling_data.Initialize() # intentially commented to raise error with self.assertRaisesRegex(Exception, ' can onyl be called after initializing the CouplingInterfaceData!'): self.assertMultiLineEqual(str(coupling_data), coupling_interface_data_str) with self.assertRaisesRegex(Exception, ' can onyl be called after initializing the CouplingInterfaceData!'): coupling_data.PrintInfo() with self.assertRaisesRegex(Exception, ' can onyl be called after initializing the CouplingInterfaceData!'): coupling_data.GetModelPart() with self.assertRaisesRegex(Exception, ' can onyl be called after initializing the CouplingInterfaceData!'): coupling_data.IsDistributed() with self.assertRaisesRegex(Exception, ' can onyl be called after initializing the CouplingInterfaceData!'): coupling_data.Size() with self.assertRaisesRegex(Exception, ' can onyl be called after initializing the CouplingInterfaceData!'): coupling_data.GetBufferSize() with self.assertRaisesRegex(Exception, ' can onyl be called after initializing the CouplingInterfaceData!'): coupling_data.GetData() with self.assertRaisesRegex(Exception, ' can onyl be called after initializing the CouplingInterfaceData!'): coupling_data.SetData([])
def __CreateInterfaceDataDict(self): data_dict = dict() for data_name, data_config in self.settings["data"].items(): data_dict[data_name] = CouplingInterfaceData( data_config, self.model) return data_dict
def test_var_does_not_exist(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "var_that_hopefully_none_will_ever_create_otherwise_this_test_will_be_wrong" }""") with self.assertRaisesRegex(Exception, 'does not exist!'): CouplingInterfaceData(settings, self.model)
def test_wrong_input_no_dim_vector(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "DISPLACEMENT" }""") with self.assertRaisesRegex(Exception, '"dimension" has to be specifed for vector variables!'): CouplingInterfaceData(settings, self.model)
def test_wrong_input_dim_scalar(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE", "dimension" : 2 }""") with self.assertRaisesRegex(Exception, '"dimension" cannot be specifed for scalar variables!'): CouplingInterfaceData(settings, self.model)
def test_non_existing_model_part(self): settings = KM.Parameters("""{ "model_part_name" : "something", "variable_name" : "PRESSURE", "location" : "node_non_historical" }""") with self.assertRaisesRegex(Exception, 'The ModelPart named : "something" was not found either as root-ModelPart or as a flat name. The total input string was "something'): CouplingInterfaceData(settings, self.model)
def test_printing(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "DISPLACEMENT", "dimension" : 2 }""") coupling_data = CouplingInterfaceData(settings, self.model) self.assertMultiLineEqual(str(coupling_data), coupling_interface_data_str)
def Initialize(self): self.data_dict = { data_name: CouplingInterfaceData(data_config, self.model, data_name, self.name) for (data_name, data_config) in self.settings["data"].items() } if self.__HasIO(): self.__GetIO().Initialize()
def test_non_existing_model_part(self): settings = KM.Parameters("""{ "model_part_name" : "something", "variable_name" : "PRESSURE", "location" : "node_non_historical" }""") coupling_data = CouplingInterfaceData(settings, self.model) with self.assertRaisesRegex(Exception, "The specified ModelPart is not in the Model, only the following ModelParts are available:"): coupling_data.Initialize()
def test_wrong_input_missing_solutionstepvar_double(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "TEMPERATURE" }""") exp_error = '"TEMPERATURE" is missing as SolutionStepVariable in ModelPart "mp_4_test"' with self.assertRaisesRegex(Exception, exp_error): CouplingInterfaceData(settings, self.model)
def test_wrong_input_variable_type(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "EXTERNAL_FORCES_VECTOR" }""") exp_error = 'The input for "variable" "EXTERNAL_FORCES_VECTOR" is of variable type "Vector" which is not allowed, only the following variable types are allowed:\nBool, Integer, Unsigned Integer, Double, Array' with self.assertRaisesRegex(Exception, exp_error): CouplingInterfaceData(settings, self.model)
def test_wrong_input_dim_array(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "DISPLACEMENT", "dimension" : 4 }""") exp_error = '"dimension" can only be 1,2,3 when using variables of type "Array"' with self.assertRaisesRegex(Exception, exp_error): CouplingInterfaceData(settings, self.model)
def test_wrong_input_location(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE", "location" : "dummy" }""") exp_error = '"dummy" is not allowed as "location", only the following options are possible:\nnode_historical, node_non_historical, element, condition, model_part' with self.assertRaisesRegex(Exception, exp_error): CouplingInterfaceData(settings, self.model)
def test_wrong_input_missing_solutionstepvar_component(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "FORCE_X" }""") exp_error = '"FORCE_X" is missing as SolutionStepVariable in ModelPart "mp_4_test"' coupling_data = CouplingInterfaceData(settings, self.model) with self.assertRaisesRegex(Exception, exp_error): coupling_data.Initialize()
def test_kratos_mapping_transfer_operator(self): if not mapping_app_available: self.skipTest("MappingApplication not available!") data_transfer_op_settings_missing = KM.Parameters("""{ "type" : "kratos_mapping" }""") exp_error = 'No "mapper_settings" provided!' with self.assertRaisesRegex(Exception, exp_error): data_transfer_operator_factory.CreateDataTransferOperator(data_transfer_op_settings_missing) data_transfer_op_settings = KM.Parameters("""{ "type" : "kratos_mapping", "mapper_settings" : { "mapper_type" : "nearest_neighbor" } }""") data_transfer_op = data_transfer_operator_factory.CreateDataTransferOperator(data_transfer_op_settings) self.__TestTransferMatching(data_transfer_op) self.__TestTransferMatchingSwapSign(data_transfer_op) self.__TestTransferMatchingAddValues(data_transfer_op) self.__TestTransferMatchingAddValuesAndSwapSign(data_transfer_op) # with this we make sure that only one mapper is created (and not several ones for each mapping operation!) # Hint: requires access to private member self.assertEqual(len(data_transfer_op._KratosMappingDataTransferOperator__mappers), 1) self.__TestTransferMatchingInverse(data_transfer_op) # here we check explicitly the InverseMap fct self.assertEqual(len(data_transfer_op._KratosMappingDataTransferOperator__mappers), 1) transfer_options_empty = KM.Parameters(""" [] """) data_transfer_op.TransferData(self.origin_data_scalar, self.destination_non_matching_data_scalar, transfer_options_empty) # here we check explicitly the creation of a second mapper, which is required since the interfaces are not the same this time self.assertEqual(len(data_transfer_op._KratosMappingDataTransferOperator__mappers), 2) data_settings_model_part = KM.Parameters("""{ "model_part_name" : "mp_single_node", "variable_name" : "TEMPERATURE", "location" : "model_part" }""") data_model_part = CouplingInterfaceData(data_settings_model_part, self.model) with self.assertRaisesRegex(Exception, 'Currently only historical nodal values are supported'): data_transfer_op.TransferData(self.origin_data_scalar, data_model_part, transfer_options_empty)
def setUp(self): self.model = KM.Model() self.model_part = self.model.CreateModelPart("default") self.model_part.AddNodalSolutionStepVariable(KM.PRESSURE) for i in range(10): # using 10 nodes gives suitable values in the tests node = self.model_part.CreateNewNode(i+1, 0.0, 0.0, 0.0) # position of nodes does not matter for this test node.SetSolutionStepValue(KM.PRESSURE, 1.0) data_settings = KM.Parameters("""{ "model_part_name" : "default", "variable_name" : "PRESSURE" }""") self.interface_data = CouplingInterfaceData(data_settings, self.model) self.dummy_solver_wrapper = DummySolverWrapper({"data_4_testing" : self.interface_data})
def test_inplace_mult(self): settings = KM.Parameters("""{ "model_part_name" : "mp_4_test", "variable_name" : "PRESSURE" }""") coupling_data = CouplingInterfaceData(settings, self.model) coupling_data.Initialize() factor = 1.55 data_init = coupling_data.GetData() coupling_data.InplaceMultiply(factor) data_mod = coupling_data.GetData() for v_old, v_new in zip(data_init, data_mod): self.assertAlmostEqual(v_old * factor, v_new)