Skip to content

Commit

Permalink
Merge pull request #12298 from KratosMultiphysics/siapp/fix_cmake_fro…
Browse files Browse the repository at this point in the history
…m_dtapp

[SIApp] Add a SI Unit test
  • Loading branch information
sunethwarna authored May 10, 2024
2 parents dd52469 + 83bc03a commit 8bdc838
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
12 changes: 6 additions & 6 deletions applications/SystemIdentificationApplication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ endif(${KRATOS_BUILD_TESTING} MATCHES ON)
## SystemIdentification python interface sources
file(GLOB_RECURSE KRATOS_DIGITAL_TWIN_APPLICATION_PYTHON_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/custom_python/*.cpp)

add_library(KratosDigitalTwinCore SHARED ${KRATOS_DIGITAL_TWIN_APPLICATION_CORE} ${KRATOS_DIGITAL_TWIN_APPLICATION_TESTING_SOURCES})
target_link_libraries(KratosDigitalTwinCore PUBLIC KratosCore)
set_target_properties(KratosDigitalTwinCore PROPERTIES COMPILE_DEFINITIONS "DIGITAL_TWIN_APPLICATION=EXPORT,API")
add_library(KratosSystemIdentificationCore SHARED ${KRATOS_DIGITAL_TWIN_APPLICATION_CORE} ${KRATOS_DIGITAL_TWIN_APPLICATION_TESTING_SOURCES})
target_link_libraries(KratosSystemIdentificationCore PUBLIC KratosCore)
set_target_properties(KratosSystemIdentificationCore PROPERTIES COMPILE_DEFINITIONS "DIGITAL_TWIN_APPLICATION=EXPORT,API")

###############################################################
## define library Kratos which defines the basic python interface
pybind11_add_module(KratosSystemIdentificationApplication MODULE THIN_LTO ${KRATOS_DIGITAL_TWIN_APPLICATION_PYTHON_INTERFACE})
target_link_libraries(KratosSystemIdentificationApplication PRIVATE KratosDigitalTwinCore)
target_link_libraries(KratosSystemIdentificationApplication PRIVATE KratosSystemIdentificationCore)
set_target_properties(KratosSystemIdentificationApplication PROPERTIES PREFIX "")

# changing the .dll suffix to .pyd (Windows)
Expand Down Expand Up @@ -65,9 +65,9 @@ if(${INSTALL_TESTING_FILES} MATCHES ON )
endif(${INSTALL_TESTING_FILES} MATCHES ON)

# Install targets
install(TARGETS KratosDigitalTwinCore DESTINATION libs )
install(TARGETS KratosSystemIdentificationCore DESTINATION libs )
install(TARGETS KratosSystemIdentificationApplication DESTINATION libs )

# Define custom targets
set(KRATOS_KERNEL "${KRATOS_KERNEL};KratosDigitalTwinCore" PARENT_SCOPE)
set(KRATOS_KERNEL "${KRATOS_KERNEL};KratosSystemIdentificationCore" PARENT_SCOPE)
set(KRATOS_PYTHON_INTERFACE "${KRATOS_PYTHON_INTERFACE};KratosSystemIdentificationApplication" PARENT_SCOPE)
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
}
},
{
"type": "connectivity_preserving_model_part_duplication_controller",
"type": "connectivity_preserving_model_part_controller",
"settings": {
"source_model_part_name": "AdjointStructure",
"destination_model_part_name": "Structure",
"destination_element_name": "ShellThinElement3D3N",
"destination_condition_name": "LineLoadCondition3D2N"
"transformation_settings": [
{
"source_model_part_name": "AdjointStructure",
"destination_model_part_name": "Structure",
"destination_element_name": "ShellThinElement3D3N",
"destination_condition_name": "LineLoadCondition3D2N"
}
]
}
}
],
Expand Down Expand Up @@ -77,8 +81,12 @@
0.0,
30000000000.0
],
"filtering": {
"filter_type": "entity_nodal_entity_filter"
"filter_settings": {
"filter_type": "explicit_filter",
"filter_radius_settings": {
"filter_radius": 5.0,
"filter_radius_type": "constant"
}
}
}
}
Expand All @@ -89,7 +97,7 @@
"echo_level": 0,
"line_search": {
"type": "const_step",
"init_step": 1e+8,
"init_step": 0.01,
"gradient_scaling": "inf_norm"
},
"conv_settings": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Variables": {
"THICKNESS": 0.25,
"DENSITY": 1.0,
"YOUNG_MODULUS": 30000000000.0,
"YOUNG_MODULUS": 10000000000.0,
"POISSON_RATIO": 0.29
},
"Tables": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
# --------------- Initial values ----------------
# algorithm:
# damage_response:
# initial_value: 2.656339179e-06
# initial_value: 7.924977798e-04
# ------------ End of initial values ------------
# -----------------------------------------------
# ------------ Start of step values -------------
# Headers:
# STEP, algorithm:std_obj_value, algorithm:rel_obj[%], algorithm:abs_obj[%], damage_response:value
0, 2.656339179e-06, 0.000000000e+00, 0.000000000e+00, 2.656339179e-06
1, 2.600481313e-06, -2.102813744e+00, -2.102813744e+00, 2.600481313e-06
2, 2.545141620e-06, -2.128055802e+00, -4.186120496e+00, 2.545141620e-06
3, 2.490320702e-06, -2.153943721e+00, -6.249897537e+00, 2.490320702e-06
4, 2.436020847e-06, -2.180436222e+00, -8.294058729e+00, 2.436020847e-06
5, 2.382244381e-06, -2.207553591e+00, -1.031851653e+01, 2.382244381e-06
0, 7.924977798e-04, 0.000000000e+00, 0.000000000e+00, 7.924977798e-04
1, 7.578660731e-04, -4.369943684e+00, -4.369943684e+00, 7.578660731e-04
2, 7.244679939e-04, -4.406857674e+00, -8.584224159e+00, 7.244679939e-04
3, 6.922659748e-04, -4.444919496e+00, -1.264758180e+01, 6.922659748e-04
4, 6.612241594e-04, -4.484087994e+00, -1.656454110e+01, 6.612241594e-04
5, 6.313082950e-04, -4.524315075e+00, -2.033942414e+01, 6.313082950e-04
# End of file
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def AssembleTestSuites():
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([test_adjoint_sensors.TestStrainSensor]))
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([test_sensor_output_process.TestSensorOutputProcess]))
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([test_smooth_clamper.TestSmoothClamper]))
# smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([test_system_identification.TestSystemIdentification]))
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([test_system_identification.TestSystemIdentification]))

nightSuite = suites['nightly']
nightSuite.addTests(smallSuite)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_DamagedSystem(self):

data = numpy.loadtxt("auxiliary_files/damaged_problem/measured_data.csv", comments="#", usecols=[0,3,4,5,6], delimiter=",")
ref_data = numpy.loadtxt("auxiliary_files/damaged_problem/measured_data_ref.csv", comments="#", usecols=[0,3,4,5,6], delimiter=",")
self.assertMatrixAlmostEqual(data, ref_data, 9)
self.assertTrue(numpy.allclose(data, ref_data, 1e-12, 1e-12))

def test_SystemIdentification(self):
model = Kratos.Model()
Expand Down

0 comments on commit 8bdc838

Please sign in to comment.