From e875deb136272f1c997360b042046171c473ddd1 Mon Sep 17 00:00:00 2001 From: Durganshu Mishra Date: Thu, 6 Jul 2023 18:02:29 +0200 Subject: [PATCH 1/8] Added Pybind version of test_3d_thin_plate --- .../test_3d_thin_plate_python/CMakeLists.txt | 34 ++ .../pybind_tool/pybind_test.py | 122 +++++++ .../FluidObserver_Pressure_Run_0_result.xml | 9 + .../FluidObserver_Pressure_Run_14_result.xml | 9 + .../FluidObserver_Pressure_Run_7_result.xml | 9 + .../FluidObserver_Pressure_dtwdistance.xml | 4 + .../FluidObserver_Pressure_runtimes.dat | 3 + ...ody_TotalMechanicalEnergy_Run_0_result.xml | 9 + ...dy_TotalMechanicalEnergy_Run_10_result.xml | 9 + ...ody_TotalMechanicalEnergy_Run_5_result.xml | 9 + ...Body_TotalMechanicalEnergy_dtwdistance.xml | 4 + ...terBody_TotalMechanicalEnergy_runtimes.dat | 3 + .../regression_test_tool.py | 44 +++ .../thin_plate_python.cpp | 324 ++++++++++++++++++ 14 files changed, 592 insertions(+) create mode 100644 tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt create mode 100755 tests/user_examples/test_3d_thin_plate_python/pybind_tool/pybind_test.py create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_14_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_7_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_10_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py create mode 100644 tests/user_examples/test_3d_thin_plate_python/thin_plate_python.cpp diff --git a/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt b/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt new file mode 100644 index 0000000000..f9b7740ee4 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt @@ -0,0 +1,34 @@ +### Python, for ${Python_EXECUTABLE} +find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +### Pybind11 +find_package(pybind11 CONFIG REQUIRED) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # main (top) cmake dir + +set(CMAKE_VERBOSE_MAKEFILE on) + +STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +PROJECT("${CURRENT_FOLDER}") + +SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) +SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") +SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") +SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") +SET(BUILD_BIND_PATH "${EXECUTABLE_OUTPUT_PATH}/bind") + +file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ + DESTINATION ${BUILD_INPUT_PATH}) + +file(MAKE_DIRECTORY ${BUILD_BIND_PATH}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/pybind_tool/ + DESTINATION ${BUILD_BIND_PATH}) + +aux_source_directory(. DIR_SRCS) +pybind11_add_module(${PROJECT_NAME} ${DIR_SRCS}) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} PRIVATE sphinxsys_3d) + +add_test(NAME ${PROJECT_NAME} COMMAND ${Python3_EXECUTABLE} "${EXECUTABLE_OUTPUT_PATH}/bind/pybind_test.py") +set_tests_properties(${PROJECT_NAME} PROPERTIES WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}/bind" + PASS_REGULAR_EXPRESSION "The result of Pressure is correct based on the dynamic time warping regression test!") diff --git a/tests/user_examples/test_3d_thin_plate_python/pybind_tool/pybind_test.py b/tests/user_examples/test_3d_thin_plate_python/pybind_tool/pybind_test.py new file mode 100755 index 0000000000..1f175f5ee8 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/pybind_tool/pybind_test.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +import os +import sys +import platform +import argparse + +# add dynamic link library or shared object to python env +# attention: match current python version with the version exposing the cpp code +sys_str = platform.system() +path_1 = os.path.abspath(os.path.join(os.getcwd(), '../..')) +if sys_str == 'Windows': + path_2 = 'lib' +elif sys_str == 'Linux': + path_2 = 'lib' +else: + # depend on the system + path_2 = 'lib' +path = os.path.join(path_1, path_2) +sys.path.append(path) +# change import depending on the project name +import test_3d_thin_plate_python as test_3d + + +def run_case(value): + parser = argparse.ArgumentParser() + # set case parameters + parser.add_argument("--restart_step", default=0, type=int) + parser.add_argument("--end_time", default=20, type=int) + parser.add_argument("--loading_factor", default=100, type=float) + case = parser.parse_args() + # project = test_3d.thin_plate_from_sph_cpp(case.loading_factor) + project = test_3d.thin_plate_from_sph_cpp(value) + if project.CmakeTest() == 1: + project.RunCase() + else: + print("check path: ", path) + +def net_displacement(file_path, output_file): + with open(file_path, 'r') as infile: + lines = infile.readlines() + + first_line_values = lines[1].strip().split() + first_value = float(first_line_values[3]) + + last_line_values = lines[-1].strip().split() + last_time = float(last_line_values[0]) + last_value = float(last_line_values[3]) + displacement_z = last_value - first_value + + displacement_x = float(last_line_values[1]) - float(first_line_values[1]) + + with open(output_file, 'a') as outfile: + outfile.write("run_time = " + str(last_time) + ", displacement in Z direction = " + str(displacement_z) + '\n') + + return last_time, displacement_z + + +def copy_files(output_folder): + source_files = ['output/PlateObserver_Position.dat', 'output/SPHBody_PlateBody_0000000000.vtp', 'output/SPHBody_PlateBody_0000806458.vtp'] + destination_files = [output_folder + 'PlateObserver_Position.dat', output_folder + 'SPHBody_PlateBody_0000000000.vtp', output_folder + 'SPHBody_PlateBody_0000806458.vtp'] + + for index, source_file in enumerate(source_files): + # Read the content of the source file + with open(source_file, 'rb') as source: + content = source.read() + # Write the content to the destination file + with open(destination_files[index], 'wb') as destination: + destination.write(content) + +def rename_files(value, output_folder): + old_file_name = [output_folder + 'PlateObserver_Position.dat', output_folder + 'SPHBody_PlateBody_0000000000.vtp', output_folder + 'SPHBody_PlateBody_0000806458.vtp'] + new_file_name = [(output_folder + 'PlateObserver_Position_' + value + '.dat'), (output_folder + 'SPHBody_PlateBody_0000000000_' + value + '.vtp'), (output_folder + 'SPHBody_PlateBody_0000806458_' + value + '.vtp')] + + for index, file in enumerate(old_file_name): + try: + os.rename(file, new_file_name[index]) + print('File renamed successfully.') + except OSError: + print('Error: File rename operation failed.') + + +if __name__ == "__main__": + + file_path = 'output/PlateObserver_Position.dat' + output_folder = 'multiple_runs_output/' + output_file = output_folder + 'Displacements.dat' + values = [6.5, 12.5, 25, 50, 75, 100, 125, 150, 175, 200] + #values = [6.5, 12.5] + displacement = list(range(len(values))) + displacement = list(range(len(values))) + run_time = list(range(len(values))) + + if not os.path.exists(output_folder): + # Create the folder + os.makedirs(output_folder) + else: + print(f"The folder '{output_folder}' already exists. Skipping creation.") + + with open(output_file, 'w') as outfile: + outfile.truncate() + + for index,value in enumerate(values): + with open(output_file, 'a') as outfile: + outfile.write("loading_factor = " + str(value) + '\n') + run_case(value) + displacement[index], run_time[index] = net_displacement(file_path, output_file) + with open(output_file, 'a') as outfile: + outfile.write('\n') + copy_files(output_folder) + rename_files(str(index), output_folder) + + print("------------------------------------------------------") + print(f"All the cases finished! Files are saved as follows: ") + for index,value in enumerate(values): + print(f"For loading_factor = {value} :") + new_file_name = [(output_folder + 'PlateObserver_Position_' + str(index) + '.dat'), (output_folder + 'SPHBody_PlateBody_0000000000_' + str(index) + '.vtp'), (output_folder + 'SPHBody_PlateBody_0000806458_' + str(index) + '.vtp')] + print("\t" + new_file_name[0]) + print("\t" + new_file_name[1]) + print("\t" + new_file_name[2]) + + print(f"Summary of displacements saved in : " + output_file) + print("\n") diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml new file mode 100644 index 0000000000..fe63aab918 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_14_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_14_result.xml new file mode 100644 index 0000000000..26f2c5636c --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_14_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_7_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_7_result.xml new file mode 100644 index 0000000000..6e76b39aa6 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_7_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml new file mode 100644 index 0000000000..a11b3bba5e --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat new file mode 100644 index 0000000000..9c41804468 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat @@ -0,0 +1,3 @@ +true +15 +4 \ No newline at end of file diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml new file mode 100644 index 0000000000..e3eefe99ba --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_10_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_10_result.xml new file mode 100644 index 0000000000..b9e557093d --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_10_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml new file mode 100644 index 0000000000..859285cd4c --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml new file mode 100644 index 0000000000..eaf89cd547 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat new file mode 100644 index 0000000000..452899ced3 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat @@ -0,0 +1,3 @@ +true +16 +4 \ No newline at end of file diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py new file mode 100644 index 0000000000..8f3d795957 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py @@ -0,0 +1,44 @@ +# !/usr/bin/env python3 +import os +import sys + +path = os.path.abspath('../../../../../PythonScriptStore/RegressionTest') +sys.path.append(path) +from regression_test_base_tool import SphinxsysRegressionTest + +""" +case name: test_2d_dambreak +""" + +case_name = "test_2d_dambreak" +body_name = "WaterBody" +parameter_name = "TotalMechanicalEnergy" +body_name_1 = "FluidObserver" +parameter_name_1 = "Pressure" + +number_of_run_times = 0 +converged = 0 +sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name) +sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1) + + +while True: + print("Now start a new run......") + sphinxsys.run_case() + number_of_run_times += 1 + converged = sphinxsys.read_dat_file() + converged_1 = sphinxsys_1.read_dat_file() + print("Please note: This is the", number_of_run_times, "run!") + if number_of_run_times <= 200: + if (converged == "true") and (converged_1 == "true"): + print("The tested parameters of all variables are converged, and the run will stop here!") + break + elif converged != "true": + print("The tested parameters of", sphinxsys.sphinxsys_parameter_name, "are not converged!") + continue + elif converged_1 != "true": + print("The tested parameters of", sphinxsys_1.sphinxsys_parameter_name, "are not converged!") + continue + else: + print("It's too many runs but still not converged, please try again!") + break diff --git a/tests/user_examples/test_3d_thin_plate_python/thin_plate_python.cpp b/tests/user_examples/test_3d_thin_plate_python/thin_plate_python.cpp new file mode 100644 index 0000000000..cfc4f03e8b --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/thin_plate_python.cpp @@ -0,0 +1,324 @@ +/** + * @file test_3d_thin_plate.cpp + * @brief This is the benchmark test of the shell. + * @details We consider the body force applied on a quasi-static square plate. + * @author Dong Wu, Chi Zhang and Xiangyu Hu + * @ref doi.org/10.1016/j.ijnonlinmec.2014.04.009, doi.org/10.1201/9780849384165 + */ +#include "sphinxsys.h" +#include +#include +namespace py = pybind11; +using namespace SPH; // Namespace cite here. + +/** + * @brief Basic geometry parameters and numerical setup. + */ +class Parameter +{ +protected: + Real PL = 10.0; /** Length of the square plate. */ + Real PH = 10.0; /** Width of the square plate. */ + Real PT = 1.0; /** Thickness of the square plate. */ + Vec3d n_0 = Vec3d(0.0, 0.0, 1.0); /** Pseudo-normal. */ + int particle_number = 40; /** Particle number in the direction of the length */ + Real resolution_ref = PL / (Real)particle_number; /** Initial reference particle spacing. */ + int BWD = 1; /** Width of the boundary layer measured by number of particles. */ + Real BW = resolution_ref * (Real)BWD; /** Boundary width, determined by specific layer of boundary particles. */ + + /** For material properties of the solid. */ + Real rho0_s = 1.0; /** Normalized density. */ + Real Youngs_modulus = 1.3024653e6; /** Normalized Youngs Modulus. */ + Real poisson = 0.3; /** Poisson ratio. */ + Real physical_viscosity = 200.0; /** physical damping, here we choose the same value as numerical viscosity. */ + + //Real q = 100.0 * Youngs_modulus * 1.0e-4; /** Total distributed load. */ + Real q = Youngs_modulus * 1.0e-4; /** Total distributed load. */ + Real time_to_full_external_force = 0.1; + + Real gravitational_acceleration = 0.009646; + + Real observed_quantity_0 = 0.0; + Real observed_quantity_n = 0.0; + Real displ_max_reference = 1.8687; +}; + + +/** Define application dependent particle generator for thin structure. */ +class PlateParticleGenerator : public SurfaceParticleGenerator, public Parameter +{ +public: + explicit PlateParticleGenerator(SPHBody &sph_body) : SurfaceParticleGenerator(sph_body){}; + virtual void initializeGeometricVariables() override + { + // the plate and boundary + for (int i = 0; i < (particle_number + 2 * BWD); i++) + { + for (int j = 0; j < (particle_number + 2 * BWD); j++) + { + Real x = resolution_ref * i - BW + resolution_ref * 0.5; + Real y = resolution_ref * j - BW + resolution_ref * 0.5; + initializePositionAndVolumetricMeasure(Vecd(x, y, 0.0), resolution_ref * resolution_ref); + initializeSurfaceProperties(n_0, PT); + } + } + } +}; +/** Define the boundary geometry. */ +class BoundaryGeometryParallelToXAxis : public BodyPartByParticle, public Parameter +{ +public: + BoundaryGeometryParallelToXAxis(SPHBody &body, const std::string &body_part_name) + : BodyPartByParticle(body, body_part_name) + { + TaggingParticleMethod tagging_particle_method = std::bind(&BoundaryGeometryParallelToXAxis::tagManually, this, _1); + tagParticles(tagging_particle_method); + }; + virtual ~BoundaryGeometryParallelToXAxis() {}; + +private: + void tagManually(size_t index_i) + { + if (base_particles_.pos_[index_i][1] < 0.0 || base_particles_.pos_[index_i][1] > PH) + { + body_part_particles_.push_back(index_i); + } + }; +}; +class BoundaryGeometryParallelToYAxis : public BodyPartByParticle, public Parameter +{ +public: + BoundaryGeometryParallelToYAxis(SPHBody &body, const std::string &body_part_name) + : BodyPartByParticle(body, body_part_name) + { + TaggingParticleMethod tagging_particle_method = std::bind(&BoundaryGeometryParallelToYAxis::tagManually, this, _1); + tagParticles(tagging_particle_method); + }; + virtual ~BoundaryGeometryParallelToYAxis() {}; + +private: + void tagManually(size_t index_i) + { + if (base_particles_.pos_[index_i][0] < 0.0 || base_particles_.pos_[index_i][0] > PL) + { + body_part_particles_.push_back(index_i); + } + }; +}; +/** + * define time dependent external force + */ +class TimeDependentExternalForce : public Gravity, public Parameter +{ +public: + explicit TimeDependentExternalForce(Vecd external_force) + : Gravity(external_force) {} + virtual Vecd InducedAcceleration(Vecd &position) override + { + Real current_time = GlobalStaticVariables::physical_time_; + return current_time < time_to_full_external_force + ? current_time * global_acceleration_ / time_to_full_external_force + : global_acceleration_; + } +}; +//---------------------------------------------------------------------- +// Define system, geometry, material, particles and all other things. +//---------------------------------------------------------------------- +class PreSettingCase : public Parameter +{ +protected: + /** Domain bounds of the system. */ + BoundingBox system_domain_bounds; + // Observer location + StdVec observation_location = {Vecd(0.5 * PL, 0.5 * PH, 0.0)}; + /** Setup the system. */ + SPHSystem system; + + /** create a plate body. */ + SolidBody plate_body; + + /** Define Observer. */ + ObserverBody plate_observer; + +public: + PreSettingCase(): + system_domain_bounds(Vec3d(-BW, -BW, -0.5 * resolution_ref), + Vec3d(PL + BW, PH + BW, 0.5 * resolution_ref)), + system(system_domain_bounds, resolution_ref), + plate_body(system, makeShared("PlateBody")), + plate_observer(system, "PlateObserver") + { + //---------------------------------------------------------------------- + // Creating bodies with corresponding materials and particles. + //---------------------------------------------------------------------- + plate_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); + plate_body.generateParticles(); + + plate_observer.defineParticlesAndMaterial(); + plate_observer.generateParticles(observation_location); + } +}; +//---------------------------------------------------------------------- +// Define environment. +//---------------------------------------------------------------------- +class Environment : public PreSettingCase +{ +protected: + Real loading_factor; + /** Set body contact map + * The contact map gives the data connections between the bodies + * basically the the range of bodies to build neighbor particle lists + */ + InnerRelation plate_body_inner; + ContactRelation plate_observer_contact; + + /** Common particle dynamics. */ + SimpleDynamics initialize_external_force; + /** + * This section define all numerical methods will be used in this case. + */ + /** Corrected configuration. */ + InteractionDynamics + corrected_configuration; + /** Time step size calculation. */ + ReduceDynamics computing_time_step_size; + /** active-passive stress relaxation. */ + Dynamics1Level + stress_relaxation_first_half; + Dynamics1Level + stress_relaxation_second_half; + /** Constrain the Boundary. */ + BoundaryGeometryParallelToXAxis boundary_geometry_x; + SimpleDynamics + constrain_holder_x; + BoundaryGeometryParallelToYAxis boundary_geometry_y; + SimpleDynamics + constrain_holder_y; + DampingWithRandomChoice>> + plate_position_damping; + DampingWithRandomChoice>> + plate_rotation_damping; + /** Output */ + IOEnvironment io_environment; + BodyStatesRecordingToVtp write_states; + ObservedQuantityRecording write_plate_max_displacement; + + + /** Statistics for computing time. */ + TickCount t1 = TickCount::now(); + TimeInterval interval; + +public: + explicit Environment(Real loading_factor_new) : + PreSettingCase(), + loading_factor(loading_factor_new), + plate_body_inner(plate_body), + plate_observer_contact(plate_observer, {&plate_body}), + initialize_external_force(plate_body, + makeShared(Vec3d(0.0, 0.0, q*loading_factor / (PT * rho0_s) - gravitational_acceleration))), + corrected_configuration(plate_body_inner), + computing_time_step_size(plate_body), + stress_relaxation_first_half(plate_body_inner), + stress_relaxation_second_half(plate_body_inner), + boundary_geometry_x(plate_body, "BoundaryGeometryParallelToXAxis"), + constrain_holder_x(boundary_geometry_x, 0), + boundary_geometry_y(plate_body, "BoundaryGeometryParallelToYAxis"), + constrain_holder_y(boundary_geometry_y, 1), + plate_position_damping(0.5, plate_body_inner, "Velocity", physical_viscosity), + plate_rotation_damping(0.5, plate_body_inner, "AngularVelocity", physical_viscosity), + io_environment(system), + write_states(io_environment, system.real_bodies_), + write_plate_max_displacement("Position", io_environment, plate_observer_contact) + { + std::cout<<"Running simulation for loading factor = " << loading_factor <<"\n"; + /** Apply initial condition. */ + system.initializeSystemCellLinkedLists(); + system.initializeSystemConfigurations(); + corrected_configuration.exec(); + + write_states.writeToFile(0); + write_plate_max_displacement.writeToFile(0); + observed_quantity_0 = (*write_plate_max_displacement.getObservedQuantity())[0][2]; + + } + + virtual ~Environment() {}; + //---------------------------------------------------------------------- + // For ctest. + //---------------------------------------------------------------------- + int cmakeTest() + { + return 1; + } + + /** + * The main program + */ + void runCase() + { + + /** Set the starting time. + * From here the time stepping begins. + */ + GlobalStaticVariables::physical_time_ = 0.0; + /** Setup physical parameters. */ + int ite = 0; + Real end_time = 0.8; + Real output_period = end_time / 100.0; + Real dt = 0.0; + + /** + * Main loop + */ + while (GlobalStaticVariables::physical_time_ < end_time) + { + Real integral_time = 0.0; + while (integral_time < output_period) + { + if (ite % 100 == 0) + { + std::cout << "N=" << ite << " Time: " + << GlobalStaticVariables::physical_time_ << " dt: " + << dt << "\n"; + } + initialize_external_force.exec(dt); + stress_relaxation_first_half.exec(dt); + constrain_holder_x.exec(dt); + constrain_holder_y.exec(dt); + plate_position_damping.exec(dt); + plate_rotation_damping.exec(dt); + constrain_holder_x.exec(dt); + constrain_holder_y.exec(dt); + stress_relaxation_second_half.exec(dt); + + ite++; + dt = computing_time_step_size.exec(); + integral_time += dt; + GlobalStaticVariables::physical_time_ += dt; + } + write_plate_max_displacement.writeToFile(ite); + + + } + TickCount t2 = TickCount::now(); + write_states.writeToFile(); + TickCount t3 = TickCount::now(); + interval = t3 - t2; + TickCount t4 = TickCount::now(); + + TimeInterval tt; + tt = t4 - t1 - interval; + std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + + observed_quantity_n = (*write_plate_max_displacement.getObservedQuantity())[0][2]; + + } +}; + +PYBIND11_MODULE(test_3d_thin_plate_python, m) +{ + py::class_(m, "thin_plate_from_sph_cpp") + .def(py::init()) + .def("CmakeTest", &Environment::cmakeTest) + .def("RunCase", &Environment::runCase); +} From 7fc4d8abdcb27986f2d916af6bd5e7eb821afe42 Mon Sep 17 00:00:00 2001 From: Durganshu Mishra Date: Thu, 6 Jul 2023 18:08:57 +0200 Subject: [PATCH 2/8] Removed redundant files from the pybind case --- .../FluidObserver_Pressure_Run_0_result.xml | 9 ---- .../FluidObserver_Pressure_Run_14_result.xml | 9 ---- .../FluidObserver_Pressure_Run_7_result.xml | 9 ---- .../FluidObserver_Pressure_dtwdistance.xml | 4 -- .../FluidObserver_Pressure_runtimes.dat | 3 -- ...ody_TotalMechanicalEnergy_Run_0_result.xml | 9 ---- ...dy_TotalMechanicalEnergy_Run_10_result.xml | 9 ---- ...ody_TotalMechanicalEnergy_Run_5_result.xml | 9 ---- ...Body_TotalMechanicalEnergy_dtwdistance.xml | 4 -- ...terBody_TotalMechanicalEnergy_runtimes.dat | 3 -- .../regression_test_tool.py | 44 ------------------- 11 files changed, 112 deletions(-) delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_14_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_7_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_10_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml deleted file mode 100644 index fe63aab918..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_14_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_14_result.xml deleted file mode 100644 index 26f2c5636c..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_14_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_7_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_7_result.xml deleted file mode 100644 index 6e76b39aa6..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_7_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml deleted file mode 100644 index a11b3bba5e..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat deleted file mode 100644 index 9c41804468..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat +++ /dev/null @@ -1,3 +0,0 @@ -true -15 -4 \ No newline at end of file diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml deleted file mode 100644 index e3eefe99ba..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_10_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_10_result.xml deleted file mode 100644 index b9e557093d..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_10_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml deleted file mode 100644 index 859285cd4c..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml deleted file mode 100644 index eaf89cd547..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat deleted file mode 100644 index 452899ced3..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat +++ /dev/null @@ -1,3 +0,0 @@ -true -16 -4 \ No newline at end of file diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py deleted file mode 100644 index 8f3d795957..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py +++ /dev/null @@ -1,44 +0,0 @@ -# !/usr/bin/env python3 -import os -import sys - -path = os.path.abspath('../../../../../PythonScriptStore/RegressionTest') -sys.path.append(path) -from regression_test_base_tool import SphinxsysRegressionTest - -""" -case name: test_2d_dambreak -""" - -case_name = "test_2d_dambreak" -body_name = "WaterBody" -parameter_name = "TotalMechanicalEnergy" -body_name_1 = "FluidObserver" -parameter_name_1 = "Pressure" - -number_of_run_times = 0 -converged = 0 -sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name) -sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1) - - -while True: - print("Now start a new run......") - sphinxsys.run_case() - number_of_run_times += 1 - converged = sphinxsys.read_dat_file() - converged_1 = sphinxsys_1.read_dat_file() - print("Please note: This is the", number_of_run_times, "run!") - if number_of_run_times <= 200: - if (converged == "true") and (converged_1 == "true"): - print("The tested parameters of all variables are converged, and the run will stop here!") - break - elif converged != "true": - print("The tested parameters of", sphinxsys.sphinxsys_parameter_name, "are not converged!") - continue - elif converged_1 != "true": - print("The tested parameters of", sphinxsys_1.sphinxsys_parameter_name, "are not converged!") - continue - else: - print("It's too many runs but still not converged, please try again!") - break From bf8e2d185b76c7aea1d848f391bc85c08494fdc9 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 12 Jul 2023 10:46:42 +0200 Subject: [PATCH 3/8] Added dummy regression test --- .../FluidObserver_Pressure_Run_0_result.xml | 9 ++++ .../FluidObserver_Pressure_Run_10_result.xml | 9 ++++ .../FluidObserver_Pressure_Run_20_result.xml | 9 ++++ .../FluidObserver_Pressure_dtwdistance.xml | 4 ++ .../FluidObserver_Pressure_runtimes.dat | 3 ++ ...ody_TotalMechanicalEnergy_Run_0_result.xml | 9 ++++ ...dy_TotalMechanicalEnergy_Run_11_result.xml | 9 ++++ ...ody_TotalMechanicalEnergy_Run_6_result.xml | 9 ++++ ...Body_TotalMechanicalEnergy_dtwdistance.xml | 4 ++ ...terBody_TotalMechanicalEnergy_runtimes.dat | 3 ++ .../regression_test_tool.py | 44 +++++++++++++++++++ 11 files changed, 112 insertions(+) create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_10_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_20_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_11_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat create mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml new file mode 100644 index 0000000000..8c7499408f --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_10_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_10_result.xml new file mode 100644 index 0000000000..30e1e009d6 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_10_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_20_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_20_result.xml new file mode 100644 index 0000000000..4e82ba0c88 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_20_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml new file mode 100644 index 0000000000..937895ceed --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat new file mode 100644 index 0000000000..fd8ad08880 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat @@ -0,0 +1,3 @@ +true +21 +4 \ No newline at end of file diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml new file mode 100644 index 0000000000..040faac7d7 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_11_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_11_result.xml new file mode 100644 index 0000000000..a4f9d99f27 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_11_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml new file mode 100644 index 0000000000..2b0252d34c --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml new file mode 100644 index 0000000000..eaf89cd547 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat new file mode 100644 index 0000000000..5cc2fa0e29 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat @@ -0,0 +1,3 @@ +true +12 +4 \ No newline at end of file diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py new file mode 100644 index 0000000000..d9087964d4 --- /dev/null +++ b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py @@ -0,0 +1,44 @@ +# !/usr/bin/env python3 +import os +import sys + +path = os.path.abspath('../../../../../PythonScriptStore/RegressionTest') +sys.path.append(path) +from regression_test_base_tool import SphinxsysRegressionTest + +""" +case name: test_2d_dambreak_python +""" + +case_name = "test_2d_dambreak_python" +body_name = "WaterBody" +parameter_name = "TotalMechanicalEnergy" +body_name_1 = "FluidObserver" +parameter_name_1 = "Pressure" + +number_of_run_times = 0 +converged = 0 +sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name) +sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1) + + +while True: + print("Now start a new run......") + sphinxsys.run_case() + number_of_run_times += 1 + converged = sphinxsys.read_dat_file() + converged_1 = sphinxsys_1.read_dat_file() + print("Please note: This is the", number_of_run_times, "run!") + if number_of_run_times <= 200: + if (converged == "true") and (converged_1 == "true"): + print("The tested parameters of all variables are converged, and the run will stop here!") + break + elif converged != "true": + print("The tested parameters of", sphinxsys.sphinxsys_parameter_name, "are not converged!") + continue + elif converged_1 != "true": + print("The tested parameters of", sphinxsys_1.sphinxsys_parameter_name, "are not converged!") + continue + else: + print("It's too many runs but still not converged, please try again!") + break From a58fd9062f33df29d071f62b162ba81160d931c9 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Tue, 18 Jul 2023 11:15:17 +0200 Subject: [PATCH 4/8] Updated CMakelists and removed redundant dependencies --- tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt b/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt index f9b7740ee4..7fdc2d26e2 100644 --- a/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt +++ b/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt @@ -16,9 +16,6 @@ SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") SET(BUILD_BIND_PATH "${EXECUTABLE_OUTPUT_PATH}/bind") -file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ - DESTINATION ${BUILD_INPUT_PATH}) file(MAKE_DIRECTORY ${BUILD_BIND_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/pybind_tool/ @@ -30,5 +27,3 @@ set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY " target_link_libraries(${PROJECT_NAME} PRIVATE sphinxsys_3d) add_test(NAME ${PROJECT_NAME} COMMAND ${Python3_EXECUTABLE} "${EXECUTABLE_OUTPUT_PATH}/bind/pybind_test.py") -set_tests_properties(${PROJECT_NAME} PROPERTIES WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}/bind" - PASS_REGULAR_EXPRESSION "The result of Pressure is correct based on the dynamic time warping regression test!") From ed968211294f19ddf0010c0836ddcaeca93aa864 Mon Sep 17 00:00:00 2001 From: Durganshu Mishra <60805696+Durganshu@users.noreply.github.com> Date: Tue, 18 Jul 2023 16:29:34 +0200 Subject: [PATCH 5/8] Deleted redundant regression test files of dambreak --- .../FluidObserver_Pressure_Run_0_result.xml | 9 ---- .../FluidObserver_Pressure_Run_10_result.xml | 9 ---- .../FluidObserver_Pressure_Run_20_result.xml | 9 ---- .../FluidObserver_Pressure_dtwdistance.xml | 4 -- .../FluidObserver_Pressure_runtimes.dat | 3 -- ...ody_TotalMechanicalEnergy_Run_0_result.xml | 9 ---- ...dy_TotalMechanicalEnergy_Run_11_result.xml | 9 ---- ...ody_TotalMechanicalEnergy_Run_6_result.xml | 9 ---- ...Body_TotalMechanicalEnergy_dtwdistance.xml | 4 -- ...terBody_TotalMechanicalEnergy_runtimes.dat | 3 -- .../regression_test_tool.py | 44 ------------------- 11 files changed, 112 deletions(-) delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_10_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_20_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_11_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat delete mode 100644 tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml deleted file mode 100644 index 8c7499408f..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_0_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_10_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_10_result.xml deleted file mode 100644 index 30e1e009d6..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_10_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_20_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_20_result.xml deleted file mode 100644 index 4e82ba0c88..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_Run_20_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml deleted file mode 100644 index 937895ceed..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_dtwdistance.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat deleted file mode 100644 index fd8ad08880..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/FluidObserver_Pressure_runtimes.dat +++ /dev/null @@ -1,3 +0,0 @@ -true -21 -4 \ No newline at end of file diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml deleted file mode 100644 index 040faac7d7..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_11_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_11_result.xml deleted file mode 100644 index a4f9d99f27..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_11_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml deleted file mode 100644 index 2b0252d34c..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml deleted file mode 100644 index eaf89cd547..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat deleted file mode 100644 index 5cc2fa0e29..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat +++ /dev/null @@ -1,3 +0,0 @@ -true -12 -4 \ No newline at end of file diff --git a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py b/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py deleted file mode 100644 index d9087964d4..0000000000 --- a/tests/user_examples/test_3d_thin_plate_python/regression_test_tool/regression_test_tool.py +++ /dev/null @@ -1,44 +0,0 @@ -# !/usr/bin/env python3 -import os -import sys - -path = os.path.abspath('../../../../../PythonScriptStore/RegressionTest') -sys.path.append(path) -from regression_test_base_tool import SphinxsysRegressionTest - -""" -case name: test_2d_dambreak_python -""" - -case_name = "test_2d_dambreak_python" -body_name = "WaterBody" -parameter_name = "TotalMechanicalEnergy" -body_name_1 = "FluidObserver" -parameter_name_1 = "Pressure" - -number_of_run_times = 0 -converged = 0 -sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name) -sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1) - - -while True: - print("Now start a new run......") - sphinxsys.run_case() - number_of_run_times += 1 - converged = sphinxsys.read_dat_file() - converged_1 = sphinxsys_1.read_dat_file() - print("Please note: This is the", number_of_run_times, "run!") - if number_of_run_times <= 200: - if (converged == "true") and (converged_1 == "true"): - print("The tested parameters of all variables are converged, and the run will stop here!") - break - elif converged != "true": - print("The tested parameters of", sphinxsys.sphinxsys_parameter_name, "are not converged!") - continue - elif converged_1 != "true": - print("The tested parameters of", sphinxsys_1.sphinxsys_parameter_name, "are not converged!") - continue - else: - print("It's too many runs but still not converged, please try again!") - break From fed1b46775b6a531217dfb0d5716fd677b882741 Mon Sep 17 00:00:00 2001 From: Durganshu Mishra <60805696+Durganshu@users.noreply.github.com> Date: Tue, 18 Jul 2023 16:30:35 +0200 Subject: [PATCH 6/8] Removed tests from CMakeLists.txt --- tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt b/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt index 7fdc2d26e2..31f2038380 100644 --- a/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt +++ b/tests/user_examples/test_3d_thin_plate_python/CMakeLists.txt @@ -25,5 +25,3 @@ aux_source_directory(. DIR_SRCS) pybind11_add_module(${PROJECT_NAME} ${DIR_SRCS}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} PRIVATE sphinxsys_3d) - -add_test(NAME ${PROJECT_NAME} COMMAND ${Python3_EXECUTABLE} "${EXECUTABLE_OUTPUT_PATH}/bind/pybind_test.py") From 796fefa49b85d40aad181ddde5e8f750222acbd9 Mon Sep 17 00:00:00 2001 From: Winterless Date: Wed, 19 Jul 2023 20:48:04 +0200 Subject: [PATCH 7/8] I changed a little bit. For this quasi-static case, I only output the final body state after simulation is finished and set the file name as 'SPHBody_PlateBody_0000000001.vtp' because the last file name for some solid and fluid cases cannot be exactly same every time. --- .../pybind_tool/pybind_test.py | 17 +++++++------- .../thin_plate_python.cpp | 22 +++++-------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/tests/user_examples/test_3d_thin_plate_python/pybind_tool/pybind_test.py b/tests/user_examples/test_3d_thin_plate_python/pybind_tool/pybind_test.py index 1f175f5ee8..4ec076b804 100755 --- a/tests/user_examples/test_3d_thin_plate_python/pybind_tool/pybind_test.py +++ b/tests/user_examples/test_3d_thin_plate_python/pybind_tool/pybind_test.py @@ -56,8 +56,8 @@ def net_displacement(file_path, output_file): def copy_files(output_folder): - source_files = ['output/PlateObserver_Position.dat', 'output/SPHBody_PlateBody_0000000000.vtp', 'output/SPHBody_PlateBody_0000806458.vtp'] - destination_files = [output_folder + 'PlateObserver_Position.dat', output_folder + 'SPHBody_PlateBody_0000000000.vtp', output_folder + 'SPHBody_PlateBody_0000806458.vtp'] + source_files = ['output/PlateObserver_Position.dat', 'output/SPHBody_PlateBody_0000000000.vtp', 'output/SPHBody_PlateBody_0000000001.vtp'] + destination_files = [output_folder + 'PlateObserver_Position.dat', output_folder + 'SPHBody_PlateBody_0000000000.vtp', output_folder + 'SPHBody_PlateBody_0000000001.vtp'] for index, source_file in enumerate(source_files): # Read the content of the source file @@ -68,8 +68,8 @@ def copy_files(output_folder): destination.write(content) def rename_files(value, output_folder): - old_file_name = [output_folder + 'PlateObserver_Position.dat', output_folder + 'SPHBody_PlateBody_0000000000.vtp', output_folder + 'SPHBody_PlateBody_0000806458.vtp'] - new_file_name = [(output_folder + 'PlateObserver_Position_' + value + '.dat'), (output_folder + 'SPHBody_PlateBody_0000000000_' + value + '.vtp'), (output_folder + 'SPHBody_PlateBody_0000806458_' + value + '.vtp')] + old_file_name = [output_folder + 'PlateObserver_Position.dat', output_folder + 'SPHBody_PlateBody_0000000000.vtp', output_folder + 'SPHBody_PlateBody_0000000001.vtp'] + new_file_name = [(output_folder + 'PlateObserver_Position_' + value + '.dat'), (output_folder + 'SPHBody_PlateBody_0000000000_' + value + '.vtp'), (output_folder + 'SPHBody_PlateBody_0000000001_' + value + '.vtp')] for index, file in enumerate(old_file_name): try: @@ -84,9 +84,8 @@ def rename_files(value, output_folder): file_path = 'output/PlateObserver_Position.dat' output_folder = 'multiple_runs_output/' output_file = output_folder + 'Displacements.dat' - values = [6.5, 12.5, 25, 50, 75, 100, 125, 150, 175, 200] - #values = [6.5, 12.5] - displacement = list(range(len(values))) + #values = [6.5, 12.5, 25, 50, 75, 100, 125, 150, 175, 200] + values = [6.5, 12.5] displacement = list(range(len(values))) run_time = list(range(len(values))) @@ -103,7 +102,7 @@ def rename_files(value, output_folder): with open(output_file, 'a') as outfile: outfile.write("loading_factor = " + str(value) + '\n') run_case(value) - displacement[index], run_time[index] = net_displacement(file_path, output_file) + run_time[index], displacement[index] = net_displacement(file_path, output_file) with open(output_file, 'a') as outfile: outfile.write('\n') copy_files(output_folder) @@ -113,7 +112,7 @@ def rename_files(value, output_folder): print(f"All the cases finished! Files are saved as follows: ") for index,value in enumerate(values): print(f"For loading_factor = {value} :") - new_file_name = [(output_folder + 'PlateObserver_Position_' + str(index) + '.dat'), (output_folder + 'SPHBody_PlateBody_0000000000_' + str(index) + '.vtp'), (output_folder + 'SPHBody_PlateBody_0000806458_' + str(index) + '.vtp')] + new_file_name = [(output_folder + 'PlateObserver_Position_' + str(index) + '.dat'), (output_folder + 'SPHBody_PlateBody_0000000000_' + str(index) + '.vtp'), (output_folder + 'SPHBody_PlateBody_0000000001_' + str(index) + '.vtp')] print("\t" + new_file_name[0]) print("\t" + new_file_name[1]) print("\t" + new_file_name[2]) diff --git a/tests/user_examples/test_3d_thin_plate_python/thin_plate_python.cpp b/tests/user_examples/test_3d_thin_plate_python/thin_plate_python.cpp index cfc4f03e8b..33d3a8082f 100644 --- a/tests/user_examples/test_3d_thin_plate_python/thin_plate_python.cpp +++ b/tests/user_examples/test_3d_thin_plate_python/thin_plate_python.cpp @@ -37,13 +37,8 @@ class Parameter Real time_to_full_external_force = 0.1; Real gravitational_acceleration = 0.009646; - - Real observed_quantity_0 = 0.0; - Real observed_quantity_n = 0.0; - Real displ_max_reference = 1.8687; }; - /** Define application dependent particle generator for thin structure. */ class PlateParticleGenerator : public SurfaceParticleGenerator, public Parameter { @@ -238,8 +233,6 @@ class Environment : public PreSettingCase write_states.writeToFile(0); write_plate_max_displacement.writeToFile(0); - observed_quantity_0 = (*write_plate_max_displacement.getObservedQuantity())[0][2]; - } virtual ~Environment() {}; @@ -297,21 +290,18 @@ class Environment : public PreSettingCase GlobalStaticVariables::physical_time_ += dt; } write_plate_max_displacement.writeToFile(ite); - - + + TickCount t2 = TickCount::now(); + TickCount t3 = TickCount::now(); + interval += t3 - t2; } - TickCount t2 = TickCount::now(); - write_states.writeToFile(); - TickCount t3 = TickCount::now(); - interval = t3 - t2; TickCount t4 = TickCount::now(); + write_states.writeToFile(1); + TimeInterval tt; tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - - observed_quantity_n = (*write_plate_max_displacement.getObservedQuantity())[0][2]; - } }; From 21785dc7d953750ce0acc4850075c74da897ba1b Mon Sep 17 00:00:00 2001 From: Winterless Date: Sun, 23 Jul 2023 23:18:28 +0200 Subject: [PATCH 8/8] Modify shell hourglass control algorithm. --- .../solid_dynamics/thin_structure_dynamics.cpp | 2 +- .../solid_dynamics/thin_structure_dynamics.h | 18 ++++++++++-------- .../solid_dynamics/thin_structure_math.cpp | 17 ----------------- .../solid_dynamics/thin_structure_math.h | 4 ---- 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/src/shared/particle_dynamics/solid_dynamics/thin_structure_dynamics.cpp b/src/shared/particle_dynamics/solid_dynamics/thin_structure_dynamics.cpp index 3d7ffc08e7..c618f8b0b1 100644 --- a/src/shared/particle_dynamics/solid_dynamics/thin_structure_dynamics.cpp +++ b/src/shared/particle_dynamics/solid_dynamics/thin_structure_dynamics.cpp @@ -101,7 +101,7 @@ ShellStressRelaxationFirstHalf:: gaussian_weight_ = three_gaussian_weights_; } /** Define the factor of hourglass control algorithm. */ - hourglass_control_factor_ = 0.005; + hourglass_control_factor_ = 0.002; } //=================================================================================================// void ShellStressRelaxationFirstHalf::initialization(size_t index_i, Real dt) diff --git a/src/shared/particle_dynamics/solid_dynamics/thin_structure_dynamics.h b/src/shared/particle_dynamics/solid_dynamics/thin_structure_dynamics.h index d8cea3c57d..61dbfd100b 100644 --- a/src/shared/particle_dynamics/solid_dynamics/thin_structure_dynamics.h +++ b/src/shared/particle_dynamics/solid_dynamics/thin_structure_dynamics.h @@ -202,22 +202,24 @@ class ShellStressRelaxationFirstHalf : public BaseShellRelaxation { Vecd e_ij = inner_neighborhood.e_ij_[n]; Real r_ij = inner_neighborhood.r_ij_[n]; - Real dim_inv_r_ij = Dimensions / r_ij; Real weight = inner_neighborhood.W_ij_[n] * inv_W0_; Vecd pos_jump = getLinearVariableJump(e_ij, r_ij, pos_[index_i], transformation_matrix_[index_i].transpose() * F_[index_i] * transformation_matrix_[index_i], pos_[index_j], transformation_matrix_[index_i].transpose() * F_[index_j] * transformation_matrix_[index_i]); - acceleration += hourglass_control_factor_ * weight * G0_ * pos_jump * dim_inv_r_ij * - inner_neighborhood.dW_ijV_j_[n] * thickness_[index_i]; + Real limiter_pos = SMIN(2.0 * pos_jump.norm() / r_ij, 1.0); + acceleration += hourglass_control_factor_ * weight * G0_ * pos_jump * Dimensions * + inner_neighborhood.dW_ijV_j_[n] * limiter_pos; - Vecd pseudo_n_jump = getLinearVariableJump(e_ij, r_ij, pseudo_n_[index_i] - n0_[index_i], + Vecd pseudo_n_variation_i = pseudo_n_[index_i] - n0_[index_i]; + Vecd pseudo_n_variation_j = pseudo_n_[index_j] - n0_[index_j]; + Vecd pseudo_n_jump = getLinearVariableJump(e_ij, r_ij, pseudo_n_variation_i, transformation_matrix_[index_i].transpose() * F_bending_[index_i] * transformation_matrix_[index_i], - pseudo_n_[index_j] - n0_[index_j], + pseudo_n_variation_j, transformation_matrix_[index_j].transpose() * F_bending_[index_j] * transformation_matrix_[index_j]); - Vecd rotation_jump = getRotationJump(pseudo_n_jump, transformation_matrix_[index_i]); - pseudo_normal_acceleration += hourglass_control_factor_ * weight * G0_ * rotation_jump * dim_inv_r_ij * - inner_neighborhood.dW_ijV_j_[n] * pow(thickness_[index_i], 3); + Real limiter_pseudo_n = SMIN(2.0 * pseudo_n_jump.norm() / ((pseudo_n_variation_i- pseudo_n_variation_j).norm() + Eps), 1.0); + pseudo_normal_acceleration += hourglass_control_factor_ * weight * G0_ * pseudo_n_jump * Dimensions * + inner_neighborhood.dW_ijV_j_[n] * pow(thickness_[index_i], 2) * limiter_pseudo_n; } acceleration += (global_stress_i + global_stress_[index_j]) * inner_neighborhood.dW_ijV_j_[n] * inner_neighborhood.e_ij_[n]; diff --git a/src/shared/particle_dynamics/solid_dynamics/thin_structure_math.cpp b/src/shared/particle_dynamics/solid_dynamics/thin_structure_math.cpp index 130aa4e791..fd1c84537a 100644 --- a/src/shared/particle_dynamics/solid_dynamics/thin_structure_math.cpp +++ b/src/shared/particle_dynamics/solid_dynamics/thin_structure_math.cpp @@ -173,23 +173,6 @@ Vecd getWENORightState(const Vecd &e_ij, const Real &r_ij, const Vecd &particle_ return getWENOStateWithStencilPoints(v1, v2, v3, v4); } //=================================================================================================// -Vec2d getRotationJump(const Vec2d &pseudo_n_jump, const Mat2d &transformation_matrix) -{ - Vec2d local_rotation_jump = Vec2d::Zero(); - Vec2d local_pseuodo_n_jump = transformation_matrix * pseudo_n_jump; - local_rotation_jump[0] = local_pseuodo_n_jump[0]; - return transformation_matrix.transpose() * local_rotation_jump; -} -//=================================================================================================// -Vec3d getRotationJump(const Vec3d &pseudo_n_jump, const Mat3d &transformation_matrix) -{ - Vec3d local_rotation_jump = Vec3d::Zero(); - Vec3d local_pseuodo_n_jump = transformation_matrix * pseudo_n_jump; - local_rotation_jump[0] = local_pseuodo_n_jump[0]; - local_rotation_jump[1] = local_pseuodo_n_jump[1]; - return transformation_matrix.transpose() * local_rotation_jump; -} -//=================================================================================================// Mat2d getCorrectedAlmansiStrain(const Mat2d ¤t_local_almansi_strain, const Real &nu_) { Mat2d corrected_almansi_strain = current_local_almansi_strain; diff --git a/src/shared/particle_dynamics/solid_dynamics/thin_structure_math.h b/src/shared/particle_dynamics/solid_dynamics/thin_structure_math.h index 81fe69b861..bfada18d9e 100644 --- a/src/shared/particle_dynamics/solid_dynamics/thin_structure_math.h +++ b/src/shared/particle_dynamics/solid_dynamics/thin_structure_math.h @@ -76,10 +76,6 @@ Vecd getWENOLeftState(const Vecd &e_ij, const Real &r_ij, const Vecd &particle_i Vecd getWENORightState(const Vecd &e_ij, const Real &r_ij, const Vecd &particle_i_value, const Matd &gradient_particle_i_value, const Vecd &particle_j_value, const Matd &gradient_particle_j_value); -/** get the artificial rotation from the pseudo-normal jump. */ -Vec2d getRotationJump(const Vec2d &pseudo_n_jump, const Mat2d &transformation_matrix); -Vec3d getRotationJump(const Vec3d &pseudo_n_jump, const Mat3d &transformation_matrix); - /** get the corrected Eulerian Almansi strain tensor according to plane stress problem. */ Mat2d getCorrectedAlmansiStrain(const Mat2d ¤t_local_almansi_strain, const Real &nu_); Mat3d getCorrectedAlmansiStrain(const Mat3d ¤t_local_almansi_strain, const Real &nu_);