diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e651c79c7..bab3d93620 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,6 +140,7 @@ jobs: -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ -D SPHINXSYS_CI=ON \ -D SPHINXSYS_USE_FLOAT=OFF \ + -D TEST_STATE_RECORDING=OFF \ -D SPHINXSYS_MODULE_OPENCASCADE=ON \ -S ${{github.workspace}} \ -B ${{github.workspace}}/build @@ -292,6 +293,7 @@ jobs: -D CMAKE_TOOLCHAIN_FILE="${{github.workspace}}\vcpkg\scripts\buildsystems\vcpkg.cmake" ` -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache ` -D SPHINXSYS_CI=ON ` + -D TEST_STATE_RECORDING=OFF ` -S ${{github.workspace}} ` -B C:\build @@ -388,6 +390,7 @@ jobs: -D CMAKE_TOOLCHAIN_FILE="${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake" \ -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ -D SPHINXSYS_CI=ON \ + -D TEST_STATE_RECORDING=OFF \ -S ${{github.workspace}} \ -B ${{github.workspace}}/build diff --git a/CMakeLists.txt b/CMakeLists.txt index 397308311a..1fbca734a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ include(Common) # brings macro to current namespace option(SPHINXSYS_2D "Build sphinxsys_2d library" ON) option(SPHINXSYS_3D "Build sphinxsys_3d library" ON) option(SPHINXSYS_BUILD_TESTS "Build tests" ON) +option(TEST_STATE_RECORDING "State recording when run Ctest" ON) option(SPHINXSYS_DEVELOPER_MODE "Developer mode has more flags active for code quality" ON) option(SPHINXSYS_USE_FLOAT "Build using float (single-precision floating-point format) as primary type" OFF) option(SPHINXSYS_MODULE_OPENCASCADE "Build extension relying on OpenCASCADE" OFF) diff --git a/PythonScriptStore/RegressionTest/regression_test_base_tool.py b/PythonScriptStore/RegressionTest/regression_test_base_tool.py index d5fcf0ba84..022ad83b98 100644 --- a/PythonScriptStore/RegressionTest/regression_test_base_tool.py +++ b/PythonScriptStore/RegressionTest/regression_test_base_tool.py @@ -38,6 +38,14 @@ def run_particle_relaxation(self) -> None: def run_case(self) -> None: print('Start case simulation...') print(self.enter_sphinxsys_exec_folder) + command = f".{os.sep}{self.sphinxsys_case_name} --r=false --rt=true" + os.system(self.enter_sphinxsys_exec_folder) + os.system(command) + print('Simulating case is finished...') + + def run_case_with_reload(self) -> None: + print('Start case simulation with particle reload...') + print(self.enter_sphinxsys_exec_folder) command = f".{os.sep}{self.sphinxsys_case_name} --r=false --i=true --rt=true" os.system(self.enter_sphinxsys_exec_folder) os.system(command) @@ -96,6 +104,14 @@ def run_particle_relaxation(self) -> None: def run_case(self) -> None: print('Start case simulation...') print(self.enter_sphinxsys_exec_folder) + command = f".{os.sep}{self.sphinxsys_case_name} --r=false --rt=true" + os.chdir(self.sphinxsys_exec_path) + os.system(command) + print('Simulating case is finished...') + + def run_case_with_reload(self) -> None: + print('Start case simulation with particle reload...') + print(self.enter_sphinxsys_exec_folder) command = f".{os.sep}{self.sphinxsys_case_name} --r=false --i=true --rt=true" os.chdir(self.sphinxsys_exec_path) os.system(command) diff --git a/modules/opencascade/tests/test_3d_aortic_valve/CMakeLists.txt b/modules/opencascade/tests/test_3d_aortic_valve/CMakeLists.txt index 0029e7ea26..3091d87528 100644 --- a/modules/opencascade/tests/test_3d_aortic_valve/CMakeLists.txt +++ b/modules/opencascade/tests/test_3d_aortic_valve/CMakeLists.txt @@ -19,5 +19,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_opencascade) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp b/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp index 369b72eafa..f35a52dec7 100644 --- a/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp +++ b/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp @@ -4,11 +4,10 @@ * @details We use this case to test the particle generation and relaxation for a surface geometry (3D). */ -#include "sphinxsys.h" // SPHinXsys Library. #include "relax_dynamics_surface.h" +#include "sphinxsys.h" // SPHinXsys Library. #include "surface_shape.h" - using namespace SPH; //---------------------------------------------------------------------- // Set the file path to the data file. @@ -66,12 +65,12 @@ class CylinderParticleGenerator : public SurfaceParticleGenerator Standard_Real v2 = DELTA2; std::vector points; - for (size_t k = 0; k <= 1 / DELTA1; k++) + for (size_t k = 0; k <= 1 / DELTA1; k++) { Standard_Real u = u1 + k * DELTA1; points.push_back(a->getCartesianPoint(u, 0)); } - for (size_t k = 0; k <= 1 / DELTA1-1; k++) + for (size_t k = 0; k <= 1 / DELTA1 - 1; k++) { Standard_Real v = v1 + k * DELTA1; points.push_back(a->getCartesianPoint(0, v)); @@ -93,12 +92,12 @@ class CylinderParticleGenerator : public SurfaceParticleGenerator { v1 = 0.5; u1 = 0.5; - double VDELTA = 0.005; - double UDELTA = 0.005; - Standard_Real v = v1 + k * VDELTA; + double V_DELTA = 0.005; + double U_DELTA = 0.005; + Standard_Real v = v1 + k * V_DELTA; for (size_t n = 0; n <= 20; n++) { - Standard_Real u = u1 + n * UDELTA; + Standard_Real u = u1 + n * U_DELTA; points.push_back(a->getCartesianPoint(u, v)); } } @@ -121,19 +120,20 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up a SPHSystem. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, particle_spacing_ref); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); // handle command line arguments + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody leaflet(system, makeShared(full_path_to_geometry, "Leaflet")); + SolidBody leaflet(sph_system, makeShared(full_path_to_geometry, "Leaflet")); // here dummy linear elastic solid is use because no solid dynamics in particle relaxation leaflet.defineParticlesAndMaterial(1.0, 1.0, 0.0); leaflet.generateParticles(); //---------------------------------------------------------------------- // Define simple file input and outputs functions. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_relaxed_particles(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_relaxed_particles(io_environment, sph_system.real_bodies_); MeshRecordingToPlt write_mesh_cell_linked_list(io_environment, leaflet.getCellLinkedList()); //---------------------------------------------------------------------- // Define body relation map. @@ -149,7 +149,7 @@ int main(int ac, char *av[]) relax_dynamics::RelaxationStepInnerSecondHalf leaflet_relaxation_second_half(leaflet_inner); /** Constrain the boundary. */ BoundaryGeometry boundary_geometry(leaflet, "BoundaryGeometry"); - SimpleDynamics constrain_holder(boundary_geometry); + SimpleDynamics constrain_holder(boundary_geometry); SimpleDynamics surface_normal_direction(leaflet); //---------------------------------------------------------------------- // Particle relaxation starts here. diff --git a/src/shared/io_system/io_base.h b/src/shared/io_system/io_base.h index e4354ba53e..e49df7c5a0 100644 --- a/src/shared/io_system/io_base.h +++ b/src/shared/io_system/io_base.h @@ -100,7 +100,8 @@ class BodyStatesRecording : public BaseIO { public: BodyStatesRecording(IOEnvironment &io_environment, SPHBodyVector bodies) - : BaseIO(io_environment), bodies_(bodies){}; + : BaseIO(io_environment), bodies_(bodies), + state_recording_(io_environment.sph_system_.StateRecording()){}; BodyStatesRecording(IOEnvironment &io_environment, SPHBody &body) : BodyStatesRecording(io_environment, {&body}){}; virtual ~BodyStatesRecording(){}; @@ -110,6 +111,7 @@ class BodyStatesRecording : public BaseIO protected: SPHBodyVector bodies_; + bool state_recording_; virtual void writeWithFileName(const std::string &sequence) = 0; }; diff --git a/src/shared/io_system/io_plt.cpp b/src/shared/io_system/io_plt.cpp index 8c786a627e..8483deed7d 100644 --- a/src/shared/io_system/io_plt.cpp +++ b/src/shared/io_system/io_plt.cpp @@ -41,15 +41,21 @@ void BodyStatesRecordingToPlt::writeWithFileName(const std::string &sequence) { if (body->checkNewlyUpdated()) { - std::string filefullpath = io_environment_.output_folder_ + - "/SPHBody_" + body->getName() + "_" + sequence + ".plt"; - if (fs::exists(filefullpath)) + BaseParticles &base_particles = body->getBaseParticles(); + base_particles.computeDrivedVariables(); + + if (state_recording_) { - fs::remove(filefullpath); + std::string filefullpath = io_environment_.output_folder_ + + "/SPHBody_" + body->getName() + "_" + sequence + ".plt"; + if (fs::exists(filefullpath)) + { + fs::remove(filefullpath); + } + std::ofstream out_file(filefullpath.c_str(), std::ios::trunc); + body->writeParticlesToPltFile(out_file); + out_file.close(); } - std::ofstream out_file(filefullpath.c_str(), std::ios::trunc); - body->writeParticlesToPltFile(out_file); - out_file.close(); } body->setNotNewlyUpdated(); } diff --git a/src/shared/io_system/io_vtk.cpp b/src/shared/io_system/io_vtk.cpp index c8f59499f3..f43122539b 100644 --- a/src/shared/io_system/io_vtk.cpp +++ b/src/shared/io_system/io_vtk.cpp @@ -14,67 +14,72 @@ void BodyStatesRecordingToVtp::writeWithFileName(const std::string &sequence) { if (body->checkNewlyUpdated()) { - std::string filefullpath = io_environment_.output_folder_ + "/" + body->getName() + "_" + sequence + ".vtp"; - if (fs::exists(filefullpath)) - { - fs::remove(filefullpath); - } - std::ofstream out_file(filefullpath.c_str(), std::ios::trunc); - // begin of the XML file - out_file << "\n"; - out_file << "\n"; - out_file << " \n"; - BaseParticles &base_particles = body->getBaseParticles(); - size_t total_real_particles = base_particles.total_real_particles_; - out_file << " getName() << "\" NumberOfPoints=\"" << total_real_particles - << "\" NumberOfVerts=\"" << total_real_particles << "\">\n"; - - // write current/final particle positions first - out_file << " \n"; - out_file << " \n"; - out_file << " "; - for (size_t i = 0; i != total_real_particles; ++i) + base_particles.computeDrivedVariables(); + + if (state_recording_) { - Vec3d particle_position = upgradeToVec3d(base_particles.pos_[i]); - out_file << particle_position[0] << " " << particle_position[1] << " " << particle_position[2] << " "; + std::string filefullpath = io_environment_.output_folder_ + "/" + body->getName() + "_" + sequence + ".vtp"; + if (fs::exists(filefullpath)) + { + fs::remove(filefullpath); + } + std::ofstream out_file(filefullpath.c_str(), std::ios::trunc); + // begin of the XML file + out_file << "\n"; + out_file << "\n"; + out_file << " \n"; + + size_t total_real_particles = base_particles.total_real_particles_; + out_file << " getName() << "\" NumberOfPoints=\"" << total_real_particles + << "\" NumberOfVerts=\"" << total_real_particles << "\">\n"; + + // write current/final particle positions first + out_file << " \n"; + out_file << " \n"; + out_file << " "; + for (size_t i = 0; i != total_real_particles; ++i) + { + Vec3d particle_position = upgradeToVec3d(base_particles.pos_[i]); + out_file << particle_position[0] << " " << particle_position[1] << " " << particle_position[2] << " "; + } + out_file << std::endl; + out_file << " \n"; + out_file << " \n"; + + // write header of particles data + out_file << " \n"; + body->writeParticlesToVtpFile(out_file); + + out_file << " \n"; + + // write empty cells + out_file << " \n"; + out_file << " \n"; + out_file << " "; + for (size_t i = 0; i != total_real_particles; ++i) + { + out_file << i << " "; + } + out_file << std::endl; + out_file << " \n"; + out_file << " \n"; + out_file << " "; + for (size_t i = 0; i != total_real_particles; ++i) + { + out_file << i + 1 << " "; + } + out_file << std::endl; + out_file << " \n"; + out_file << " \n"; + + out_file << " \n"; + + out_file << " \n"; + out_file << "\n"; + + out_file.close(); } - out_file << std::endl; - out_file << " \n"; - out_file << " \n"; - - // write header of particles data - out_file << " \n"; - body->writeParticlesToVtpFile(out_file); - - out_file << " \n"; - - // write empty cells - out_file << " \n"; - out_file << " \n"; - out_file << " "; - for (size_t i = 0; i != total_real_particles; ++i) - { - out_file << i << " "; - } - out_file << std::endl; - out_file << " \n"; - out_file << " \n"; - out_file << " "; - for (size_t i = 0; i != total_real_particles; ++i) - { - out_file << i + 1 << " "; - } - out_file << std::endl; - out_file << " \n"; - out_file << " \n"; - - out_file << " \n"; - - out_file << " \n"; - out_file << "\n"; - - out_file.close(); } body->setNotNewlyUpdated(); } @@ -86,11 +91,17 @@ void BodyStatesRecordingToVtpString::writeWithFileName(const std::string &sequen { if (body->checkNewlyUpdated()) { - const auto &vtuName = body->getName() + "_" + sequence + ".vtu"; - std::stringstream sstream; - // begin of the XML file - writeVtu(sstream, body); - _vtuData[vtuName] = sstream.str(); + BaseParticles &base_particles = body->getBaseParticles(); + base_particles.computeDrivedVariables(); + + if (state_recording_) + { + const auto &vtuName = body->getName() + "_" + sequence + ".vtu"; + std::stringstream sstream; + // begin of the XML file + writeVtu(sstream, body); + _vtuData[vtuName] = sstream.str(); + } } body->setNotNewlyUpdated(); } diff --git a/src/shared/particles/base_particles.cpp b/src/shared/particles/base_particles.cpp index 5ce494facb..f9d0187938 100644 --- a/src/shared/particles/base_particles.cpp +++ b/src/shared/particles/base_particles.cpp @@ -152,6 +152,14 @@ void BaseParticles::writePltFileHeader(std::ofstream &output_file) }; } //=================================================================================================// +void BaseParticles::computeDrivedVariables() +{ + for (auto &derived_variable : derived_variables_) + { + derived_variable->exec(); + } +} +//=================================================================================================// void BaseParticles::writePltFileParticleData(std::ofstream &output_file, size_t index) { // write particle positions and index first @@ -187,12 +195,6 @@ void BaseParticles::writeParticlesToPltFile(std::ofstream &output_file) writePltFileHeader(output_file); output_file << "\n"; - // compute derived particle variables - for (auto &derived_variable : derived_variables_) - { - derived_variable->exec(); - } - size_t total_real_particles = total_real_particles_; for (size_t i = 0; i != total_real_particles; ++i) { diff --git a/src/shared/particles/base_particles.h b/src/shared/particles/base_particles.h index e7f259da25..29500e735e 100644 --- a/src/shared/particles/base_particles.h +++ b/src/shared/particles/base_particles.h @@ -158,6 +158,7 @@ class BaseParticles template void addDerivedVariableToWrite(Ts &&...); + void computeDrivedVariables(); //---------------------------------------------------------------------- // Particle data for sorting //---------------------------------------------------------------------- diff --git a/src/shared/particles/base_particles.hpp b/src/shared/particles/base_particles.hpp index 6ce18d3bef..3ebe7a46e1 100644 --- a/src/shared/particles/base_particles.hpp +++ b/src/shared/particles/base_particles.hpp @@ -247,7 +247,7 @@ void BaseParticles::writeParticlesToVtk(StreamType &output_stream) output_stream << std::endl; output_stream << " \n"; - //write unsorted particles ID + // write unsorted particles ID output_stream << " \n"; output_stream << " "; for (size_t i = 0; i != total_real_particles; ++i) @@ -257,12 +257,6 @@ void BaseParticles::writeParticlesToVtk(StreamType &output_stream) output_stream << std::endl; output_stream << " \n"; - // compute derived particle variables - for (auto &derived_variable : derived_variables_) - { - derived_variable->exec(); - } - // write integers constexpr int type_index_int = DataTypeIndex::value; for (DiscreteVariable *variable : std::get(variables_to_write_)) diff --git a/src/shared/sphinxsys_system/sph_system.cpp b/src/shared/sphinxsys_system/sph_system.cpp index e9686d540a..c5f906f5d4 100644 --- a/src/shared/sphinxsys_system/sph_system.cpp +++ b/src/shared/sphinxsys_system/sph_system.cpp @@ -11,8 +11,8 @@ SPHSystem::SPHSystem(BoundingBox system_domain_bounds, Real resolution_ref, size : system_domain_bounds_(system_domain_bounds), resolution_ref_(resolution_ref), tbb_global_control_(tbb::global_control::max_allowed_parallelism, number_of_threads), - io_environment_(nullptr), generate_regression_data_(false), run_particle_relaxation_(false), - reload_particles_(false), restart_step_(0) {} + io_environment_(nullptr), run_particle_relaxation_(false), reload_particles_(false), + restart_step_(0), generate_regression_data_(false), state_recording_(true) {} //=================================================================================================// void SPHSystem::initializeSystemCellLinkedLists() { @@ -57,6 +57,7 @@ void SPHSystem::handleCommandlineOptions(int ac, char *av[]) desc.add_options()("r", po::value(), "Particle relaxation."); desc.add_options()("i", po::value(), "Particle reload from input file."); desc.add_options()("rt", po::value(), "Regression test."); + desc.add_options()("state_recording", po::value(), "State recording in output folder."); desc.add_options()("restart_step", po::value(), "Run form a restart file."); po::variables_map vm; @@ -105,6 +106,18 @@ void SPHSystem::handleCommandlineOptions(int ac, char *av[]) << generate_regression_data_ << ").\n"; } + if (vm.count("state_recording")) + { + state_recording_ = vm["state_recording"].as(); + std::cout << "Delete all files in output folder after run was set to " + << vm["state_recording"].as() << ".\n"; + } + else + { + std::cout << "Delete all files in output folder after run was set to default (" + << state_recording_ << ").\n"; + } + if (vm.count("restart_step")) { restart_step_ = vm["restart_step"].as(); diff --git a/src/shared/sphinxsys_system/sph_system.h b/src/shared/sphinxsys_system/sph_system.h index 89896325b1..cdfddbbd82 100644 --- a/src/shared/sphinxsys_system/sph_system.h +++ b/src/shared/sphinxsys_system/sph_system.h @@ -69,15 +69,16 @@ class SPHSystem bool RunParticleRelaxation() { return run_particle_relaxation_; }; void setReloadParticles(bool reload_particles) { reload_particles_ = reload_particles; }; bool ReloadParticles() { return reload_particles_; }; + bool GenerateRegressionData() { return generate_regression_data_; }; + bool StateRecording() { return state_recording_; }; + void setStateRecording(bool state_recording) { state_recording_ = state_recording; }; void setRestartStep(size_t restart_step) { restart_step_ = restart_step; }; size_t RestartStep() { return restart_step_; }; BoundingBox system_domain_bounds_; /**< Lower and Upper domain bounds. */ Real resolution_ref_; /**< reference resolution of the SPH system */ tbb::global_control tbb_global_control_; /**< global controlling on the total number parallel threads */ - IOEnvironment *io_environment_; /**< io_environment setup */ - bool generate_regression_data_; /**< run and generate or enhance the regression test data set. */ - + IOEnvironment *io_environment_; /**< io_environment setup */ SPHBodyVector sph_bodies_; /**< All sph bodies. */ SPHBodyVector observation_bodies_; /**< The bodies without inner particle configuration. */ SPHBodyVector real_bodies_; /**< The bodies with inner particle configuration. */ @@ -93,9 +94,11 @@ class SPHSystem void handleCommandlineOptions(int ac, char *av[]); #endif protected: - bool run_particle_relaxation_; /**< run particle relaxation for body fitted particle distribution */ - bool reload_particles_; /**< start the simulation with relaxed particles. */ - size_t restart_step_; /**< restart step */ + bool run_particle_relaxation_; /**< run particle relaxation for body fitted particle distribution */ + bool reload_particles_; /**< start the simulation with relaxed particles. */ + size_t restart_step_; /**< restart step */ + bool generate_regression_data_; /**< run and generate or enhance the regression test data set. */ + bool state_recording_; /**< Record state in output folder. */ }; } // namespace SPH #endif // SPH_SYSTEM_H \ No newline at end of file diff --git a/tests/2d_examples/test_0d_regression_test/regression_test.cpp b/tests/2d_examples/test_0d_regression_test/regression_test.cpp index 95f7ed158c..c7bad2ca38 100644 --- a/tests/2d_examples/test_0d_regression_test/regression_test.cpp +++ b/tests/2d_examples/test_0d_regression_test/regression_test.cpp @@ -186,12 +186,13 @@ class TemperatureObserverParticleGenerator : public ObserverParticleGenerator //---------------------------------------------------------------------- // Main program starts here. //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Create body, materials and particles. diff --git a/tests/2d_examples/test_1d_shock_tube/src/CMakeLists.txt b/tests/2d_examples/test_1d_shock_tube/src/CMakeLists.txt index da3e5a86aa..7ae0e04485 100644 --- a/tests/2d_examples/test_1d_shock_tube/src/CMakeLists.txt +++ b/tests/2d_examples/test_1d_shock_tube/src/CMakeLists.txt @@ -2,8 +2,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) - - set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) @@ -11,5 +9,5 @@ aux_source_directory(. DIR_SRCS) add_executable(${PROJECT_NAME} ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} extra_sources_2d) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, Eulerian") diff --git a/tests/2d_examples/test_2d_T_shaped_pipe/src/CMakeLists.txt b/tests/2d_examples/test_2d_T_shaped_pipe/src/CMakeLists.txt index d1fd0f4825..bb41876173 100644 --- a/tests/2d_examples/test_2d_T_shaped_pipe/src/CMakeLists.txt +++ b/tests/2d_examples/test_2d_T_shaped_pipe/src/CMakeLists.txt @@ -2,16 +2,14 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) - - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, inlet, outlet") - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_T_shaped_pipe/src/T_shaped_pipe.cpp b/tests/2d_examples/test_2d_T_shaped_pipe/src/T_shaped_pipe.cpp index 0bad0c1e9b..fbabe61bbf 100644 --- a/tests/2d_examples/test_2d_T_shaped_pipe/src/T_shaped_pipe.cpp +++ b/tests/2d_examples/test_2d_T_shaped_pipe/src/T_shaped_pipe.cpp @@ -98,17 +98,17 @@ int main(int ac, char *av[]) // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- BoundingBox system_domain_bounds(Vec2d(-DL_sponge - BW, -DH - BW), Vec2d(DL + BW, 2.0 * DH + BW)); - SPHSystem system(system_domain_bounds, resolution_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles.cd //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); //---------------------------------------------------------------------- @@ -129,7 +129,7 @@ int main(int ac, char *av[]) InteractionWithUpdate inlet_outlet_surface_particle_indicator(water_block_complex_relation); InteractionWithUpdate update_density_by_summation(water_block_complex_relation); - water_block.addBodyStateForRecording("Pressure"); // output for debug + water_block.addBodyStateForRecording("Pressure"); // output for debug water_block.addBodyStateForRecording("Indicator"); // output for debug SimpleDynamics initialize_a_fluid_step(water_block); @@ -163,18 +163,18 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_body_states(io_environment, sph_system.real_bodies_); //---------------------------------------------------------------------- // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); //---------------------------------------------------------------------- // Setup computing and initial conditions. //---------------------------------------------------------------------- - size_t number_of_iterations = system.RestartStep(); + size_t number_of_iterations = sph_system.RestartStep(); int screen_output_interval = 100; Real end_time = 100.0; Real output_interval = end_time / 200.0; /**< Time stamps for output of body states. */ @@ -248,5 +248,6 @@ int main(int ac, char *av[]) std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } diff --git a/tests/2d_examples/test_2d_airfoil/CMakeLists.txt b/tests/2d_examples/test_2d_airfoil/CMakeLists.txt index dde7f28e14..99b3a3f7d7 100644 --- a/tests/2d_examples/test_2d_airfoil/CMakeLists.txt +++ b/tests/2d_examples/test_2d_airfoil/CMakeLists.txt @@ -3,25 +3,24 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/ +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) -add_test(NAME ${PROJECT_NAME}_particle_relaxation - COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME}_particle_relaxation + COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME}_particle_relaxation PROPERTIES LABELS "particle relaxation") diff --git a/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp b/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp index f8a14922af..b316a392cb 100644 --- a/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp +++ b/tests/2d_examples/test_2d_airfoil/airfoil_2d.cpp @@ -42,16 +42,16 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up -- a SPHSystem //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); - system.setRunParticleRelaxation(true); // tag to run particle relaxation when no commandline option + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.setRunParticleRelaxation(true); // tag to run particle relaxation when no commandline option #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody airfoil(system, makeShared("AirFoil")); + RealBody airfoil(sph_system, makeShared("AirFoil")); airfoil.defineAdaptation(1.15, 1.0, 3); airfoil.defineBodyLevelSetShape()->cleanLevelSet()->writeLevelSet(io_environment); airfoil.defineParticlesAndMaterial(); diff --git a/tests/2d_examples/test_2d_ball_shell_collision/CMakeLists.txt b/tests/2d_examples/test_2d_ball_shell_collision/CMakeLists.txt index f83e23663b..7a01241476 100644 --- a/tests/2d_examples/test_2d_ball_shell_collision/CMakeLists.txt +++ b/tests/2d_examples/test_2d_ball_shell_collision/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") - - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") @@ -21,17 +19,9 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif() +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "particle_relaxation, thick_surface, solid_dynamics, contact") - diff --git a/tests/2d_examples/test_2d_ball_shell_collision/ball_shell_collision.cpp b/tests/2d_examples/test_2d_ball_shell_collision/ball_shell_collision.cpp index 4399691b14..a512ca3098 100644 --- a/tests/2d_examples/test_2d_ball_shell_collision/ball_shell_collision.cpp +++ b/tests/2d_examples/test_2d_ball_shell_collision/ball_shell_collision.cpp @@ -254,7 +254,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_ball_center_displacement.generateDataBase(1.0e-2); } diff --git a/tests/2d_examples/test_2d_ball_shell_collision/regression_test_tool/regression_test_tool.py b/tests/2d_examples/test_2d_ball_shell_collision/regression_test_tool/regression_test_tool.py index cfde50a214..b5faecbe81 100644 --- a/tests/2d_examples/test_2d_ball_shell_collision/regression_test_tool/regression_test_tool.py +++ b/tests/2d_examples/test_2d_ball_shell_collision/regression_test_tool/regression_test_tool.py @@ -22,7 +22,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() print("Please note: This is the", number_of_run_times, "run!") diff --git a/tests/2d_examples/test_2d_ball_shell_collision/run_test.sh b/tests/2d_examples/test_2d_ball_shell_collision/run_test.sh deleted file mode 100644 index a5e852031a..0000000000 --- a/tests/2d_examples/test_2d_ball_shell_collision/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_2d_ball_shell_collision --r=true -./test_2d_ball_shell_collision --r=false --i=true diff --git a/tests/2d_examples/test_2d_collision/CMakeLists.txt b/tests/2d_examples/test_2d_collision/CMakeLists.txt index 00d2b19061..da1fed2fc0 100644 --- a/tests/2d_examples/test_2d_collision/CMakeLists.txt +++ b/tests/2d_examples/test_2d_collision/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") - - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") @@ -21,14 +19,7 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif() +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/2d_examples/test_2d_collision/regression_test_tool/regression_test_tool.py b/tests/2d_examples/test_2d_collision/regression_test_tool/regression_test_tool.py index 6b87027410..c4d5cfa239 100644 --- a/tests/2d_examples/test_2d_collision/regression_test_tool/regression_test_tool.py +++ b/tests/2d_examples/test_2d_collision/regression_test_tool/regression_test_tool.py @@ -25,7 +25,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() converged_1 = sphinxsys_1.read_dat_file() diff --git a/tests/2d_examples/test_2d_collision/run_test.sh b/tests/2d_examples/test_2d_collision/run_test.sh deleted file mode 100644 index 32a4914dfe..0000000000 --- a/tests/2d_examples/test_2d_collision/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_2d_collision --r=true -./test_2d_collision --r=false --i=true diff --git a/tests/2d_examples/test_2d_dambreak/CMakeLists.txt b/tests/2d_examples/test_2d_dambreak/CMakeLists.txt index 397632d8b9..061d2dc093 100644 --- a/tests/2d_examples/test_2d_dambreak/CMakeLists.txt +++ b/tests/2d_examples/test_2d_dambreak/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # main (to set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) @@ -15,11 +15,11 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -add_executable(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +add_executable(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME}_restart COMMAND ${PROJECT_NAME} --restart_step=4000 - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME}_restart COMMAND ${PROJECT_NAME} --restart_step=4000 --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/2d_examples/test_2d_dambreak/Dambreak.cpp b/tests/2d_examples/test_2d_dambreak/Dambreak.cpp index 0216990747..0cee2b5495 100644 --- a/tests/2d_examples/test_2d_dambreak/Dambreak.cpp +++ b/tests/2d_examples/test_2d_dambreak/Dambreak.cpp @@ -218,7 +218,7 @@ int main(int ac, char *av[]) std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_water_mechanical_energy.generateDataBase(1.0e-3); write_recorded_water_pressure.generateDataBase(1.0e-3); diff --git a/tests/2d_examples/test_2d_dambreak_multi_resolution/CMakeLists.txt b/tests/2d_examples/test_2d_dambreak_multi_resolution/CMakeLists.txt index cef505fe38..0a25bda148 100644 --- a/tests/2d_examples/test_2d_dambreak_multi_resolution/CMakeLists.txt +++ b/tests/2d_examples/test_2d_dambreak_multi_resolution/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # main (to set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) @@ -11,10 +11,10 @@ SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_dambreak_multi_resolution/dambreak_multi_resolution.cpp b/tests/2d_examples/test_2d_dambreak_multi_resolution/dambreak_multi_resolution.cpp index 14f944f2d0..f9cf4da9c3 100644 --- a/tests/2d_examples/test_2d_dambreak_multi_resolution/dambreak_multi_resolution.cpp +++ b/tests/2d_examples/test_2d_dambreak_multi_resolution/dambreak_multi_resolution.cpp @@ -244,11 +244,5 @@ int main(int ac, char *av[]) std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; - /* if (sph_system.RestartStep() == 0) - { - write_water_mechanical_energy.testResult(); - write_recorded_water_pressure.testResult(); - } */ - return 0; }; diff --git a/tests/2d_examples/test_2d_dambreak_python/dambreak_python.cpp b/tests/2d_examples/test_2d_dambreak_python/dambreak_python.cpp index 99ca1f275a..3e4aab9dc8 100644 --- a/tests/2d_examples/test_2d_dambreak_python/dambreak_python.cpp +++ b/tests/2d_examples/test_2d_dambreak_python/dambreak_python.cpp @@ -270,7 +270,7 @@ class Environment : public PreSettingCase std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_water_mechanical_energy.generateDataBase(1.0e-3); write_recorded_water_pressure.generateDataBase(1.0e-3); diff --git a/tests/2d_examples/test_2d_depolarization/CMakeLists.txt b/tests/2d_examples/test_2d_depolarization/CMakeLists.txt index 3bf1a9522d..8712cd465e 100644 --- a/tests/2d_examples/test_2d_depolarization/CMakeLists.txt +++ b/tests/2d_examples/test_2d_depolarization/CMakeLists.txt @@ -17,7 +17,7 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") diff --git a/tests/2d_examples/test_2d_depolarization/depolarization.cpp b/tests/2d_examples/test_2d_depolarization/depolarization.cpp index 8bbc294d1d..706fd50ecc 100644 --- a/tests/2d_examples/test_2d_depolarization/depolarization.cpp +++ b/tests/2d_examples/test_2d_depolarization/depolarization.cpp @@ -34,155 +34,156 @@ Real k_a = 0.0; //---------------------------------------------------------------------- class MuscleBlock : public MultiPolygonShape { -public: - explicit MuscleBlock(const std::string &shape_name) : MultiPolygonShape(shape_name) - { - std::vector shape; - shape.push_back(Vecd(0.0, 0.0)); - shape.push_back(Vecd(0.0, H)); - shape.push_back(Vecd(L, H)); - shape.push_back(Vecd(L, 0.0)); - shape.push_back(Vecd(0.0, 0.0)); - multi_polygon_.addAPolygon(shape, ShapeBooleanOps::add); - } + public: + explicit MuscleBlock(const std::string &shape_name) : MultiPolygonShape(shape_name) + { + std::vector shape; + shape.push_back(Vecd(0.0, 0.0)); + shape.push_back(Vecd(0.0, H)); + shape.push_back(Vecd(L, H)); + shape.push_back(Vecd(L, 0.0)); + shape.push_back(Vecd(0.0, 0.0)); + multi_polygon_.addAPolygon(shape, ShapeBooleanOps::add); + } }; //---------------------------------------------------------------------- // Application dependent initial condition. //---------------------------------------------------------------------- class DepolarizationInitialCondition - : public electro_physiology::ElectroPhysiologyInitialCondition + : public electro_physiology::ElectroPhysiologyInitialCondition { -protected: - size_t voltage_; + protected: + size_t voltage_; -public: - explicit DepolarizationInitialCondition(SPHBody &sph_body) - : electro_physiology::ElectroPhysiologyInitialCondition(sph_body) - { - voltage_ = particles_->diffusion_reaction_material_.AllSpeciesIndexMap()["Voltage"]; - }; + public: + explicit DepolarizationInitialCondition(SPHBody &sph_body) + : electro_physiology::ElectroPhysiologyInitialCondition(sph_body) + { + voltage_ = particles_->diffusion_reaction_material_.AllSpeciesIndexMap()["Voltage"]; + }; - void update(size_t index_i, Real dt) - { - all_species_[voltage_][index_i] = exp(-4.0 * ((pos_[index_i][0] - 1.0) * (pos_[index_i][0] - 1.0) + pos_[index_i][1] * pos_[index_i][1])); - }; + void update(size_t index_i, Real dt) + { + all_species_[voltage_][index_i] = exp(-4.0 * ((pos_[index_i][0] - 1.0) * (pos_[index_i][0] - 1.0) + pos_[index_i][1] * pos_[index_i][1])); + }; }; //---------------------------------------------------------------------- // Main program starts here. //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { - //---------------------------------------------------------------------- - // Build up the environment of a SPHSystem. - //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); - IOEnvironment io_environment(system); - //---------------------------------------------------------------------- - // Creating body, materials and particles. - //---------------------------------------------------------------------- - SolidBody muscle_body(system, makeShared("MuscleBlock")); - SharedPtr muscle_reaction_model_ptr = makeShared(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); - muscle_body.defineParticlesAndMaterial( - muscle_reaction_model_ptr, TypeIdentity(), diffusion_coeff, bias_coeff, fiber_direction); - muscle_body.generateParticles(); + //---------------------------------------------------------------------- + // Build up the environment of a SPHSystem. + //---------------------------------------------------------------------- + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); + //---------------------------------------------------------------------- + // Creating body, materials and particles. + //---------------------------------------------------------------------- + SolidBody muscle_body(sph_system, makeShared("MuscleBlock")); + SharedPtr muscle_reaction_model_ptr = makeShared(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); + muscle_body.defineParticlesAndMaterial( + muscle_reaction_model_ptr, TypeIdentity(), diffusion_coeff, bias_coeff, fiber_direction); + muscle_body.generateParticles(); - ObserverBody voltage_observer(system, "VoltageObserver"); - voltage_observer.generateParticles(observation_location); - //---------------------------------------------------------------------- - // Define body relation map. - // The contact map gives the topological connections between the bodies. - // Basically the the range of bodies to build neighbor particle lists. - //---------------------------------------------------------------------- - InnerRelation muscle_body_inner_relation(muscle_body); - ContactRelation voltage_observer_contact_relation(voltage_observer, {&muscle_body}); - //---------------------------------------------------------------------- - // Define the main numerical methods used in the simulation. - // Note that there may be data dependence on the constructors of these methods. - //---------------------------------------------------------------------- - SimpleDynamics initialization(muscle_body); - InteractionWithUpdate correct_configuration(muscle_body_inner_relation); - electro_physiology::GetElectroPhysiologyTimeStepSize get_time_step_size(muscle_body); - // Diffusion process for diffusion body. - electro_physiology::ElectroPhysiologyDiffusionInnerRK2 diffusion_relaxation(muscle_body_inner_relation); - // Solvers for ODE system or reactions - electro_physiology::ElectroPhysiologyReactionRelaxationForward reaction_relaxation_forward(muscle_body); - electro_physiology::ElectroPhysiologyReactionRelaxationBackward reaction_relaxation_backward(muscle_body); - //---------------------------------------------------------------------- - // Define the methods for I/O operations and observations of the simulation. - //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); - RegressionTestEnsembleAverage> - write_recorded_voltage("Voltage", io_environment, voltage_observer_contact_relation); - //---------------------------------------------------------------------- - // Prepare the simulation with cell linked list, configuration - // and case specified initial condition if necessary. - //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); - initialization.exec(); - correct_configuration.exec(); - //---------------------------------------------------------------------- - // Initial states output. - //---------------------------------------------------------------------- - write_states.writeToFile(0); - write_recorded_voltage.writeToFile(0); - //---------------------------------------------------------------------- - // Setup for time-stepping control - //---------------------------------------------------------------------- - int ite = 0; - Real T0 = 16.0; - Real end_time = T0; - Real output_interval = 0.5; /**< Time period for output */ - Real Dt = 0.01 * output_interval; /**< Time period for data observing */ - Real dt = 0.0; - //---------------------------------------------------------------------- - // Statistics for CPU time - //---------------------------------------------------------------------- - TickCount t1 = TickCount::now(); - TimeInterval interval; - //---------------------------------------------------------------------- - // Main loop starts here. - //---------------------------------------------------------------------- - while (GlobalStaticVariables::physical_time_ < end_time) - { - Real integration_time = 0.0; - while (integration_time < output_interval) - { - Real relaxation_time = 0.0; - while (relaxation_time < Dt) - { - if (ite % 1000 == 0) - { - std::cout << "N=" << ite << " Time: " - << GlobalStaticVariables::physical_time_ << " dt: " - << dt << "\n"; - } - /**Strang splitting method. */ - reaction_relaxation_forward.exec(0.5 * dt); - diffusion_relaxation.exec(dt); - reaction_relaxation_backward.exec(0.5 * dt); + ObserverBody voltage_observer(sph_system, "VoltageObserver"); + voltage_observer.generateParticles(observation_location); + //---------------------------------------------------------------------- + // Define body relation map. + // The contact map gives the topological connections between the bodies. + // Basically the the range of bodies to build neighbor particle lists. + //---------------------------------------------------------------------- + InnerRelation muscle_body_inner_relation(muscle_body); + ContactRelation voltage_observer_contact_relation(voltage_observer, {&muscle_body}); + //---------------------------------------------------------------------- + // Define the main numerical methods used in the simulation. + // Note that there may be data dependence on the constructors of these methods. + //---------------------------------------------------------------------- + SimpleDynamics initialization(muscle_body); + InteractionWithUpdate correct_configuration(muscle_body_inner_relation); + electro_physiology::GetElectroPhysiologyTimeStepSize get_time_step_size(muscle_body); + // Diffusion process for diffusion body. + electro_physiology::ElectroPhysiologyDiffusionInnerRK2 diffusion_relaxation(muscle_body_inner_relation); + // Solvers for ODE system or reactions + electro_physiology::ElectroPhysiologyReactionRelaxationForward reaction_relaxation_forward(muscle_body); + electro_physiology::ElectroPhysiologyReactionRelaxationBackward reaction_relaxation_backward(muscle_body); + //---------------------------------------------------------------------- + // Define the methods for I/O operations and observations of the simulation. + //---------------------------------------------------------------------- + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); + RegressionTestEnsembleAverage> + write_recorded_voltage("Voltage", io_environment, voltage_observer_contact_relation); + //---------------------------------------------------------------------- + // Prepare the simulation with cell linked list, configuration + // and case specified initial condition if necessary. + //---------------------------------------------------------------------- + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); + initialization.exec(); + correct_configuration.exec(); + //---------------------------------------------------------------------- + // Initial states output. + //---------------------------------------------------------------------- + write_states.writeToFile(0); + write_recorded_voltage.writeToFile(0); + //---------------------------------------------------------------------- + // Setup for time-stepping control + //---------------------------------------------------------------------- + int ite = 0; + Real T0 = 16.0; + Real end_time = T0; + Real output_interval = 0.5; /**< Time period for output */ + Real Dt = 0.01 * output_interval; /**< Time period for data observing */ + Real dt = 0.0; + //---------------------------------------------------------------------- + // Statistics for CPU time + //---------------------------------------------------------------------- + TickCount t1 = TickCount::now(); + TimeInterval interval; + //---------------------------------------------------------------------- + // Main loop starts here. + //---------------------------------------------------------------------- + while (GlobalStaticVariables::physical_time_ < end_time) + { + Real integration_time = 0.0; + while (integration_time < output_interval) + { + Real relaxation_time = 0.0; + while (relaxation_time < Dt) + { + if (ite % 1000 == 0) + { + std::cout << "N=" << ite << " Time: " + << GlobalStaticVariables::physical_time_ << " dt: " + << dt << "\n"; + } + /**Strang splitting method. */ + reaction_relaxation_forward.exec(0.5 * dt); + diffusion_relaxation.exec(dt); + reaction_relaxation_backward.exec(0.5 * dt); - ite++; - dt = get_time_step_size.exec(); - relaxation_time += dt; - integration_time += dt; - GlobalStaticVariables::physical_time_ += dt; - } - write_recorded_voltage.writeToFile(ite); - } + ite++; + dt = get_time_step_size.exec(); + relaxation_time += dt; + integration_time += dt; + GlobalStaticVariables::physical_time_ += dt; + } + write_recorded_voltage.writeToFile(ite); + } - TickCount t2 = TickCount::now(); - write_states.writeToFile(); - TickCount t3 = TickCount::now(); - interval += t3 - t2; - } - TickCount t4 = TickCount::now(); + 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; + TimeInterval tt; + tt = t4 - t1 - interval; + std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - write_recorded_voltage.testResult(); + write_recorded_voltage.testResult(); - return 0; + return 0; } diff --git a/tests/2d_examples/test_2d_diffusion/CMakeLists.txt b/tests/2d_examples/test_2d_diffusion/CMakeLists.txt index 30b91f94bb..043177728b 100644 --- a/tests/2d_examples/test_2d_diffusion/CMakeLists.txt +++ b/tests/2d_examples/test_2d_diffusion/CMakeLists.txt @@ -17,7 +17,7 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, diffusion reaction") diff --git a/tests/2d_examples/test_2d_diffusion/diffusion.cpp b/tests/2d_examples/test_2d_diffusion/diffusion.cpp index cbf545e18e..241eaa931e 100644 --- a/tests/2d_examples/test_2d_diffusion/diffusion.cpp +++ b/tests/2d_examples/test_2d_diffusion/diffusion.cpp @@ -112,12 +112,13 @@ class TemperatureObserverParticleGenerator : public ObserverParticleGenerator //---------------------------------------------------------------------- // Main program starts here. //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up the environment of a SPHSystem. //---------------------------------------------------------------------- SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. diff --git a/tests/2d_examples/test_2d_diffusion_NeumannBC/CMakeLists.txt b/tests/2d_examples/test_2d_diffusion_NeumannBC/CMakeLists.txt index ad74e8da0e..9997c3fb53 100644 --- a/tests/2d_examples/test_2d_diffusion_NeumannBC/CMakeLists.txt +++ b/tests/2d_examples/test_2d_diffusion_NeumannBC/CMakeLists.txt @@ -17,7 +17,7 @@ target_link_libraries(${PROJECT_NAME} extra_sources_2d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "diffusion reaction") \ No newline at end of file diff --git a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp index c82178dc43..c3f2ca31a6 100644 --- a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp +++ b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.cpp @@ -143,7 +143,7 @@ int main(int ac, char *av[]) std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; std::cout << "Total physical time for computation: " << GlobalStaticVariables::physical_time_ << " seconds." << std::endl; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_solid_temperature.generateDataBase(1.0e-3, 1.0e-3); } diff --git a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.h b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.h index bf3d1da777..6438ee1ac6 100644 --- a/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.h +++ b/tests/2d_examples/test_2d_diffusion_NeumannBC/diffusion_NeumannBC.h @@ -3,8 +3,8 @@ * @brief This is the head files used by diffusion_NeumannBC.cpp. * @author Chenxi Zhao, Bo Zhang, Chi Zhang and Xiangyu Hu */ -#ifndef DIFFUSION_NEUMANNBC_H -#define DIFFUSION_NEUMANNBC_H +#ifndef DIFFUSION_NEUMANN_BC_H +#define DIFFUSION_NEUMANN_BC_H #include "sphinxsys.h" using namespace SPH; @@ -129,8 +129,8 @@ class DirichletWallBoundaryInitialCondition size_t phi_; public: - explicit DirichletWallBoundaryInitialCondition(SolidBody &diffusion_body) - : DiffusionReactionInitialCondition(diffusion_body) + explicit DirichletWallBoundaryInitialCondition(SolidBody &diffusion_body) + : DiffusionReactionInitialCondition(diffusion_body) { phi_ = particles_->diffusion_reaction_material_.AllSpeciesIndexMap()["Phi"]; } @@ -158,9 +158,9 @@ class NeumannWallBoundaryInitialCondition StdLargeVec &heat_flux_; public: - explicit NeumannWallBoundaryInitialCondition(SolidBody &diffusion_body) - : DiffusionReactionInitialCondition(diffusion_body), - heat_flux_(*(particles_->getVariableByName("HeatFlux"))) + explicit NeumannWallBoundaryInitialCondition(SolidBody &diffusion_body) + : DiffusionReactionInitialCondition(diffusion_body), + heat_flux_(*(particles_->getVariableByName("HeatFlux"))) { phi_ = particles_->diffusion_reaction_material_.AllSpeciesIndexMap()["Phi"]; } @@ -215,4 +215,4 @@ class TemperatureObserverParticleGenerator : public ObserverParticleGenerator } } }; -#endif // DIFFUSION_NEUMANNBC_H \ No newline at end of file +#endif // DIFFUSION_NEUMANN_BC_H \ No newline at end of file diff --git a/tests/2d_examples/test_2d_diffusion_RobinBC/CMakeLists.txt b/tests/2d_examples/test_2d_diffusion_RobinBC/CMakeLists.txt index f556a1622e..ab23902f40 100644 --- a/tests/2d_examples/test_2d_diffusion_RobinBC/CMakeLists.txt +++ b/tests/2d_examples/test_2d_diffusion_RobinBC/CMakeLists.txt @@ -17,7 +17,7 @@ target_link_libraries(${PROJECT_NAME} extra_sources_2d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "diffusion reaction") \ No newline at end of file diff --git a/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.cpp b/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.cpp index 8db91c5ab4..1b949c9355 100644 --- a/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.cpp +++ b/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.cpp @@ -146,7 +146,7 @@ int main(int ac, char *av[]) std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; std::cout << "Total physical time for computation: " << GlobalStaticVariables::physical_time_ << " seconds." << std::endl; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_solid_temperature.generateDataBase(1.0e-3, 1.0e-3); } @@ -156,4 +156,4 @@ int main(int ac, char *av[]) } return 0; -} \ No newline at end of file +} diff --git a/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.h b/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.h index 343d019e95..4890f7f2d3 100644 --- a/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.h +++ b/tests/2d_examples/test_2d_diffusion_RobinBC/diffusion_RobinBC.h @@ -3,8 +3,8 @@ * @brief This is the head files used by diffusion_RobinBC.cpp. * @author Chenxi Zhao, Bo Zhang, Chi Zhang and Xiangyu Hu */ -#ifndef DIFFUSION_ROBINBC_H -#define DIFFUSION_ROBINBC_H +#ifndef DIFFUSION_ROBIN_BC_H +#define DIFFUSION_ROBIN_BC_H #include "sphinxsys.h" using namespace SPH; @@ -217,4 +217,4 @@ class TemperatureObserverParticleGenerator : public ObserverParticleGenerator } } }; -#endif // DIFFUSION_ROBINBC_H \ No newline at end of file +#endif // DIFFUSION_ROBIN_BC_H \ No newline at end of file diff --git a/tests/2d_examples/test_2d_elastic_gate/CMakeLists.txt b/tests/2d_examples/test_2d_elastic_gate/CMakeLists.txt index fd5b7fc2ce..abe6bde16a 100644 --- a/tests/2d_examples/test_2d_elastic_gate/CMakeLists.txt +++ b/tests/2d_examples/test_2d_elastic_gate/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") - - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") @@ -19,7 +17,8 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_elastic_gate/elastic_gate.cpp b/tests/2d_examples/test_2d_elastic_gate/elastic_gate.cpp index d238501c5b..86699f3ce5 100644 --- a/tests/2d_examples/test_2d_elastic_gate/elastic_gate.cpp +++ b/tests/2d_examples/test_2d_elastic_gate/elastic_gate.cpp @@ -140,26 +140,26 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBlock")); + FluidBody water_block(sph_system, makeShared("WaterBlock")); water_block.defineParticlesAndMaterial(rho0_f, c_f); water_block.generateParticles(); - SolidBody wall_boundary(system, makeShared("WallBoundary")); + SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); - SolidBody gate(system, makeShared(createGateShape(), "Gate")); + SolidBody gate(sph_system, makeShared(createGateShape(), "Gate")); gate.defineAdaptationRatios(1.15, 2.0); gate.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); gate.generateParticles(); - ObserverBody gate_observer(system, "Observer"); + ObserverBody gate_observer(sph_system, "Observer"); gate_observer.defineAdaptationRatios(1.15, 2.0); gate_observer.generateParticles(observation_location); //---------------------------------------------------------------------- @@ -206,8 +206,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToPlt write_real_body_states_to_plt(io_environment, system.real_bodies_); - BodyStatesRecordingToVtp write_real_body_states_to_vtp(io_environment, system.real_bodies_); + BodyStatesRecordingToPlt write_real_body_states_to_plt(io_environment, sph_system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states_to_vtp(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_beam_tip_displacement("Position", io_environment, gate_observer_contact_relation); // TODO: observing position is not as good observing displacement. @@ -216,8 +216,8 @@ int main(int ac, char *av[]) // and case specified initial condition if necessary. //---------------------------------------------------------------------- gate_offset_position.exec(); - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); gate_normal_direction.exec(); gate_corrected_configuration.exec(); @@ -305,14 +305,15 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_beam_tip_displacement.generateDataBase(1.0e-3); } - else if (system.RestartStep() == 0) + else if (sph_system.RestartStep() == 0) { write_beam_tip_displacement.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/2d_eulerian_flow_around_cylinder.cpp b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/2d_eulerian_flow_around_cylinder.cpp index 5f1c00d020..74135508ef 100644 --- a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/2d_eulerian_flow_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/2d_eulerian_flow_around_cylinder.cpp @@ -192,5 +192,6 @@ int main(int ac, char *av[]) write_total_viscous_force_on_inserted_body.testResult(); + return 0; } diff --git a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/CMakeLists.txt b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/CMakeLists.txt index 9f3fe9c52e..eb626b0635 100644 --- a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/CMakeLists.txt +++ b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/CMakeLists.txt @@ -9,20 +9,18 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) - + add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} extra_sources_2d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - -add_test(NAME ${PROJECT_NAME}_particle_relaxation - COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME}_particle_relaxation + COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, Eulerian") - diff --git a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/regression_test_tool/regression_test_tool.py b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/regression_test_tool/regression_test_tool.py index d0b12d13e2..bc53b00069 100644 --- a/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/regression_test_tool/regression_test_tool.py +++ b/tests/2d_examples/test_2d_eulerian_flow_around_cylinder/regression_test_tool/regression_test_tool.py @@ -21,7 +21,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() print("Please note: This is the", number_of_run_times, "run!") diff --git a/tests/2d_examples/test_2d_eulerian_taylor_green/2d_eulerian_taylor_green.cpp b/tests/2d_examples/test_2d_eulerian_taylor_green/2d_eulerian_taylor_green.cpp index 5fef5b9cdc..67a24c5d89 100644 --- a/tests/2d_examples/test_2d_eulerian_taylor_green/2d_eulerian_taylor_green.cpp +++ b/tests/2d_examples/test_2d_eulerian_taylor_green/2d_eulerian_taylor_green.cpp @@ -136,5 +136,6 @@ int main(int ac, char *av[]) write_total_mechanical_energy.testResult(); write_maximum_speed.testResult(); + return 0; } diff --git a/tests/2d_examples/test_2d_eulerian_taylor_green/2d_eulerian_taylor_green.h b/tests/2d_examples/test_2d_eulerian_taylor_green/2d_eulerian_taylor_green.h index 83f9925b4c..20111f1788 100644 --- a/tests/2d_examples/test_2d_eulerian_taylor_green/2d_eulerian_taylor_green.h +++ b/tests/2d_examples/test_2d_eulerian_taylor_green/2d_eulerian_taylor_green.h @@ -1,6 +1,6 @@ /** * @file eulerian_taylor_green.h - * @brief This is a test to show the standard eluerian taylor green case. + * @brief This is a test to show the standard Eluerian Taylor-Green case. * @details See https://doi.org/10.1016/j.jcp.2010.08.019 for the detailed problem setup. * @author Zhentong Wang and Xiangyu Hu */ diff --git a/tests/2d_examples/test_2d_eulerian_taylor_green/CMakeLists.txt b/tests/2d_examples/test_2d_eulerian_taylor_green/CMakeLists.txt index 96d0aa42d2..9ff12323cd 100644 --- a/tests/2d_examples/test_2d_eulerian_taylor_green/CMakeLists.txt +++ b/tests/2d_examples/test_2d_eulerian_taylor_green/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") @@ -13,14 +13,14 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) - + aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, Eulerian") - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} extra_sources_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} extra_sources_2d) diff --git a/tests/2d_examples/test_2d_filling_tank/CMakeLists.txt b/tests/2d_examples/test_2d_filling_tank/CMakeLists.txt index 875ac5b9cc..717f51ea3e 100644 --- a/tests/2d_examples/test_2d_filling_tank/CMakeLists.txt +++ b/tests/2d_examples/test_2d_filling_tank/CMakeLists.txt @@ -3,11 +3,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -20,8 +18,8 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) \ No newline at end of file +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) \ No newline at end of file diff --git a/tests/2d_examples/test_2d_filling_tank/filling_tank.cpp b/tests/2d_examples/test_2d_filling_tank/filling_tank.cpp index 5ccb026297..5e34c9a194 100644 --- a/tests/2d_examples/test_2d_filling_tank/filling_tank.cpp +++ b/tests/2d_examples/test_2d_filling_tank/filling_tank.cpp @@ -85,27 +85,28 @@ class InletInflowCondition : public fluid_dynamics::EmitterInflowCondition //---------------------------------------------------------------------- // Main program starts here. //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { /** Build up a SPHSystem */ - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); /** Set the starting time. */ GlobalStaticVariables::physical_time_ = 0.0; //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_body(system, makeShared>( - Transform(inlet_translation), inlet_halfsize, "WaterBody")); + FluidBody water_body(sph_system, makeShared>( + Transform(inlet_translation), inlet_halfsize, "WaterBody")); water_body.sph_adaptation_->resetKernel>(20); water_body.defineParticlesAndMaterial(rho0_f, c_f); water_body.generateParticles(); /**note that, as particle sort is activated (by default) for fluid particles, * the output occasionally does not reflect the real free surface indication due to sorting. */ - SolidBody wall(system, makeShared("Wall")); + SolidBody wall(sph_system, makeShared("Wall")); wall.defineParticlesAndMaterial(); wall.generateParticles(); - ObserverBody fluid_observer(system, "FluidObserver"); + ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(observation_location); //---------------------------------------------------------------------- // Define body relation map. @@ -123,7 +124,7 @@ int main() InteractionWithUpdate indicate_free_surface(water_body_complex); water_body.addBodyStateForRecording("PositionDivergence"); // for debug - water_body.addBodyStateForRecording("Indicator"); // for debug + water_body.addBodyStateForRecording("Indicator"); // for debug SharedPtr gravity_ptr = makeShared(Vecd(0.0, -gravity_g)); SimpleDynamics initialize_a_fluid_step(water_body, gravity_ptr); @@ -138,8 +139,8 @@ int main() //---------------------------------------------------------------------- // File Output //---------------------------------------------------------------------- - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp body_states_recording(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp body_states_recording(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping>> write_water_mechanical_energy(io_environment, water_body, gravity_ptr); RegressionTestDynamicTimeWarping> @@ -148,14 +149,14 @@ int main() // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_normal_direction.exec(); indicate_free_surface.exec(); //---------------------------------------------------------------------- // Time stepping control parameters. //---------------------------------------------------------------------- - size_t number_of_iterations = system.RestartStep(); + size_t number_of_iterations = sph_system.RestartStep(); int screen_output_interval = 100; Real end_time = 30.0; Real output_interval = 0.1; @@ -231,5 +232,6 @@ int main() write_water_mechanical_energy.testResult(); write_recorded_water_pressure.testResult(); + return 0; } diff --git a/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp b/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp index a8b452e5a1..fe09bd7abd 100644 --- a/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_flow_around_cylinder/2d_flow_around_cylinder.cpp @@ -245,5 +245,6 @@ int main(int ac, char *av[]) write_total_viscous_force_on_inserted_body.testResult(); + return 0; } diff --git a/tests/2d_examples/test_2d_flow_around_cylinder/CMakeLists.txt b/tests/2d_examples/test_2d_flow_around_cylinder/CMakeLists.txt index 69a88954e3..80da4f283b 100644 --- a/tests/2d_examples/test_2d_flow_around_cylinder/CMakeLists.txt +++ b/tests/2d_examples/test_2d_flow_around_cylinder/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -18,19 +16,12 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) - -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") -add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif() +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) + +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary") diff --git a/tests/2d_examples/test_2d_flow_around_cylinder/regression_test_tool/regression_test_tool.py b/tests/2d_examples/test_2d_flow_around_cylinder/regression_test_tool/regression_test_tool.py index 230bc8d729..403dbed8c5 100644 --- a/tests/2d_examples/test_2d_flow_around_cylinder/regression_test_tool/regression_test_tool.py +++ b/tests/2d_examples/test_2d_flow_around_cylinder/regression_test_tool/regression_test_tool.py @@ -22,7 +22,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() print("Please note: This is the", number_of_run_times, "run!") diff --git a/tests/2d_examples/test_2d_flow_around_cylinder/run_test.sh b/tests/2d_examples/test_2d_flow_around_cylinder/run_test.sh deleted file mode 100644 index ca5361b136..0000000000 --- a/tests/2d_examples/test_2d_flow_around_cylinder/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_2d_flow_around_cylinder --r=true -./test_2d_flow_around_cylinder --r=false --i=true diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp b/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp index 760afcf767..c0de1cc63f 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder/2d_free_stream_around_cylinder.cpp @@ -245,7 +245,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { // The lift force at the cylinder is very small and not important in this case. write_total_viscous_force_on_inserted_body.generateDataBase({1.0e-2, 1.0e-2}, {1.0e-2, 1.0e-2}); @@ -255,5 +255,6 @@ int main(int ac, char *av[]) write_total_viscous_force_on_inserted_body.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder/CMakeLists.txt b/tests/2d_examples/test_2d_free_stream_around_cylinder/CMakeLists.txt index 7b448a8962..04b29a4e18 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder/CMakeLists.txt +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -17,19 +15,12 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) - -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif() +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) + +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, free stream") diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder/regression_test_tool/regression_test_tool.py b/tests/2d_examples/test_2d_free_stream_around_cylinder/regression_test_tool/regression_test_tool.py index bda1418713..ac6a3dc7c4 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder/regression_test_tool/regression_test_tool.py +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder/regression_test_tool/regression_test_tool.py @@ -21,7 +21,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() print("Please note: This is the run number", number_of_run_times,".") diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder/run_test.sh b/tests/2d_examples/test_2d_free_stream_around_cylinder/run_test.sh deleted file mode 100644 index 52a212cd2e..0000000000 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_2d_free_stream_around_cylinder --r=true -./test_2d_free_stream_around_cylinder --r=false --i=true diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/CMakeLists.txt b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/CMakeLists.txt index 7b448a8962..04b29a4e18 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/CMakeLists.txt +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -17,19 +15,12 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) - -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif() +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) + +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, free stream") diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp index 727e6e3dd1..5ec7df6abb 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.cpp @@ -260,5 +260,6 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/regression_test_tool/regression_test_tool.py b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/regression_test_tool/regression_test_tool.py index bda1418713..ac6a3dc7c4 100644 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/regression_test_tool/regression_test_tool.py +++ b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/regression_test_tool/regression_test_tool.py @@ -21,7 +21,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() print("Please note: This is the run number", number_of_run_times,".") diff --git a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/run_test.sh b/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/run_test.sh deleted file mode 100644 index 1628ae93ab..0000000000 --- a/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_2d_free_stream_around_cylinder_mr --r=true -./test_2d_free_stream_around_cylinder_mr --r=false --i=true \ No newline at end of file diff --git a/tests/2d_examples/test_2d_fsi2/CMakeLists.txt b/tests/2d_examples/test_2d_fsi2/CMakeLists.txt index 6cf993eaca..4ca3a9cfd5 100644 --- a/tests/2d_examples/test_2d_fsi2/CMakeLists.txt +++ b/tests/2d_examples/test_2d_fsi2/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -18,17 +16,10 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif() +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary") diff --git a/tests/2d_examples/test_2d_fsi2/fsi2.cpp b/tests/2d_examples/test_2d_fsi2/fsi2.cpp index d1619dd8e8..9c088250a6 100644 --- a/tests/2d_examples/test_2d_fsi2/fsi2.cpp +++ b/tests/2d_examples/test_2d_fsi2/fsi2.cpp @@ -290,7 +290,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { // The lift force at the cylinder is very small and not important in this case. write_total_viscous_force_on_insert_body.generateDataBase({1.0e-2, 1.0e-2}, {1.0e-2, 1.0e-2}); @@ -302,5 +302,6 @@ int main(int ac, char *av[]) write_beam_tip_displacement.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_fsi2/regression_test_tool/regression_test_tool.py b/tests/2d_examples/test_2d_fsi2/regression_test_tool/regression_test_tool.py index 01df9624f1..4ed9b79340 100644 --- a/tests/2d_examples/test_2d_fsi2/regression_test_tool/regression_test_tool.py +++ b/tests/2d_examples/test_2d_fsi2/regression_test_tool/regression_test_tool.py @@ -24,7 +24,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() converged_1 = sphinxsys_1.read_dat_file() diff --git a/tests/2d_examples/test_2d_fsi2/run_test.sh b/tests/2d_examples/test_2d_fsi2/run_test.sh deleted file mode 100644 index e356f779cf..0000000000 --- a/tests/2d_examples/test_2d_fsi2/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_2d_fsi2 --r=true -./test_2d_fsi2 --r=false --i=true diff --git a/tests/2d_examples/test_2d_heat_transfer/CMakeLists.txt b/tests/2d_examples/test_2d_heat_transfer/CMakeLists.txt index a13a7ec7d4..c07c911a05 100644 --- a/tests/2d_examples/test_2d_heat_transfer/CMakeLists.txt +++ b/tests/2d_examples/test_2d_heat_transfer/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -19,9 +17,8 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) - -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, diffusion reaction") set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") diff --git a/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp b/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp index 00fcd2b1e7..ef85aa96dc 100644 --- a/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp +++ b/tests/2d_examples/test_2d_heat_transfer/heat_transfer.cpp @@ -216,26 +216,26 @@ struct InflowVelocity //---------------------------------------------------------------------- // Main program starts here. //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); - GlobalStaticVariables::physical_time_ = 0.0; - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); // handle command line arguments + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody thermofluid_body(system, makeShared("ThermofluidBody")); + FluidBody thermofluid_body(sph_system, makeShared("ThermofluidBody")); thermofluid_body.defineParticlesAndMaterial(); thermofluid_body.generateParticles(); - SolidBody thermosolid_body(system, makeShared("ThermosolidBody")); + SolidBody thermosolid_body(sph_system, makeShared("ThermosolidBody")); thermosolid_body.defineParticlesAndMaterial(); thermosolid_body.generateParticles(); - ObserverBody temperature_observer(system, "FluidObserver"); + ObserverBody temperature_observer(sph_system, "FluidObserver"); temperature_observer.generateParticles(observation_location); //---------------------------------------------------------------------- // Define body relation map. @@ -284,7 +284,7 @@ int main() //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); RegressionTestEnsembleAverage> write_fluid_phi("Phi", io_environment, fluid_observer_contact); ObservedQuantityRecording @@ -293,12 +293,12 @@ int main() // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemCellLinkedLists(); /** periodic condition applied after the mesh cell linked list build up * but before the configuration build up. */ periodic_condition.update_cell_linked_list_.exec(); /** initialize configurations for all bodies. */ - system.initializeSystemConfigurations(); + sph_system.initializeSystemConfigurations(); /** computing surface normal direction for the wall. */ thermosolid_body_normal_direction.exec(); thermosolid_condition.exec(); @@ -386,5 +386,6 @@ int main() write_fluid_phi.testResult(); + return 0; } diff --git a/tests/2d_examples/test_2d_hydrostatic_fsi/CMakeLists.txt b/tests/2d_examples/test_2d_hydrostatic_fsi/CMakeLists.txt index fbb2e370ef..b4fd0c17fd 100644 --- a/tests/2d_examples/test_2d_hydrostatic_fsi/CMakeLists.txt +++ b/tests/2d_examples/test_2d_hydrostatic_fsi/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -17,9 +15,10 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_hydrostatic_fsi/hydrostatic_fsi.cpp b/tests/2d_examples/test_2d_hydrostatic_fsi/hydrostatic_fsi.cpp index d66a2d277c..97c56d6138 100644 --- a/tests/2d_examples/test_2d_hydrostatic_fsi/hydrostatic_fsi.cpp +++ b/tests/2d_examples/test_2d_hydrostatic_fsi/hydrostatic_fsi.cpp @@ -189,33 +189,32 @@ std::vector createGateConstrainShapeRight() //---------------------------------------------------------------------- // Main program starts here. //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up -- a SPHSystem //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, particle_spacing_ref); - /** Set the starting time to zero. */ - GlobalStaticVariables::physical_time_ = 0.0; - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f); water_block.generateParticles(); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); - SolidBody gate(system, makeShared("Gate")); + SolidBody gate(sph_system, makeShared("Gate")); gate.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); gate.generateParticles(); //---------------------------------------------------------------------- // Particle and body creation of gate observer. //---------------------------------------------------------------------- - ObserverBody gate_observer(system, "Observer"); + ObserverBody gate_observer(sph_system, "Observer"); gate_observer.generateParticles(observation_location); //---------------------------------------------------------------------- // Define body relation map. @@ -266,7 +265,7 @@ int main() // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- /** Output body states for visualization. */ - BodyStatesRecordingToVtp write_real_body_states_to_vtp(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states_to_vtp(io_environment, sph_system.real_bodies_); /** Output the observed displacement of gate free end. */ RegressionTestEnsembleAverage> write_beam_tip_displacement("Position", io_environment, gate_observer_contact); @@ -275,9 +274,9 @@ int main() // and case specified initial condition if necessary. //---------------------------------------------------------------------- /** initialize cell linked lists for all bodies. */ - system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemCellLinkedLists(); /** initialize configurations for all bodies. */ - system.initializeSystemConfigurations(); + sph_system.initializeSystemConfigurations(); /** computing surface normal direction for the wall. */ wall_boundary_normal_direction.exec(); /** computing surface normal direction for the insert body. */ @@ -373,5 +372,6 @@ int main() write_beam_tip_displacement.testResult(); + return 0; } diff --git a/tests/2d_examples/test_2d_nonlinear_wave_fsi/CMakeLists.txt b/tests/2d_examples/test_2d_nonlinear_wave_fsi/CMakeLists.txt index a2159e04f0..3af6a9af7c 100644 --- a/tests/2d_examples/test_2d_nonlinear_wave_fsi/CMakeLists.txt +++ b/tests/2d_examples/test_2d_nonlinear_wave_fsi/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -18,12 +16,12 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "fluid dynamics, Simbody") - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} extra_sources_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} extra_sources_2d) diff --git a/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp b/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp index 54ed0de02e..31961ff435 100644 --- a/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp +++ b/tests/2d_examples/test_2d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp @@ -14,26 +14,26 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); - SolidBody structure(system, makeShared("Structure")); + SolidBody structure(sph_system, makeShared("Structure")); structure.defineParticlesAndMaterial(rho_s); structure.generateParticles(); - ObserverBody observer(system, "Observer"); + ObserverBody observer(sph_system, "Observer"); observer.defineAdaptationRatios(1.15, 2.0); observer.generateParticles( StdVec{obs}); @@ -41,13 +41,13 @@ int main(int ac, char *av[]) //--------------------------------------------------------- // PRESSURE PROBES //--------------------------------------------------------- - ObserverBody fp2(system, "FluidObserver2"); + ObserverBody fp2(sph_system, "FluidObserver2"); Real fp2x = 12.466; Real fp2y = 0.968; StdVec fp2l = {Vecd(fp2x, fp2y)}; fp2.defineAdaptationRatios(1.15, 2.0); fp2.generateParticles(fp2l); - ObserverBody fp3(system, "FluidObserver3"); + ObserverBody fp3(sph_system, "FluidObserver3"); Real fp3x = 12.466; Real fp3y = 1.013; StdVec fp3l = {Vecd(fp3x, fp3y)}; @@ -174,7 +174,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); /** WaveProbe. */ BodyRegionByCell wave_probe_buffer(water_block, makeShared(createWaveGauge(), "WaveGauge")); RegressionTestDynamicTimeWarping>> @@ -193,15 +193,15 @@ int main(int ac, char *av[]) write_recorded_pressure_fp2("Pressure", io_environment, fp2_contact_w); RegressionTestDynamicTimeWarping> write_recorded_pressure_fp3("Pressure", io_environment, fp3_contact_w); - RestartIO restart_io(io_environment, system.real_bodies_); + RestartIO restart_io(io_environment, sph_system.real_bodies_); //---------------------------------------------------------------------- // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- structure_offset_position.exec(); - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); structure_normal_direction.exec(); structure_corrected_configuration.exec(); @@ -209,9 +209,9 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Load restart file if necessary. //---------------------------------------------------------------------- - if (system.RestartStep() != 0) + if (sph_system.RestartStep() != 0) { - GlobalStaticVariables::physical_time_ = restart_io.readRestartFiles(system.RestartStep()); + GlobalStaticVariables::physical_time_ = restart_io.readRestartFiles(sph_system.RestartStep()); water_block.updateCellLinkedListWithParticleSort(100); wall_boundary.updateCellLinkedList(); structure.updateCellLinkedList(); @@ -225,7 +225,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Basic control parameters for time stepping. //---------------------------------------------------------------------- - size_t number_of_iterations = system.RestartStep(); + size_t number_of_iterations = sph_system.RestartStep(); int screen_output_interval = 1000; int restart_output_interval = screen_output_interval * 10; Real end_time = total_physical_time; @@ -342,16 +342,17 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_str_displacement.generateDataBase(1.0e-3); write_recorded_pressure_fp2.generateDataBase(1.0e-3); } - else if (system.RestartStep() == 0) + else if (sph_system.RestartStep() == 0) { write_str_displacement.testResult(); write_recorded_pressure_fp2.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_oscillating_beam/CMakeLists.txt b/tests/2d_examples/test_2d_oscillating_beam/CMakeLists.txt index 756eda1151..075ba4a3da 100644 --- a/tests/2d_examples/test_2d_oscillating_beam/CMakeLists.txt +++ b/tests/2d_examples/test_2d_oscillating_beam/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # main (to set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -19,7 +17,8 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_oscillating_beam/oscillating_beam.cpp b/tests/2d_examples/test_2d_oscillating_beam/oscillating_beam.cpp index 4bfc2dbde3..c90ff2545f 100644 --- a/tests/2d_examples/test_2d_oscillating_beam/oscillating_beam.cpp +++ b/tests/2d_examples/test_2d_oscillating_beam/oscillating_beam.cpp @@ -98,18 +98,18 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); #ifdef BOOST_AVAILABLE // handle command line arguments - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(system, makeShared("BeamBody")); + SolidBody beam_body(sph_system, makeShared("BeamBody")); beam_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); beam_body.generateParticles(); - ObserverBody beam_observer(system, "BeamObserver"); + ObserverBody beam_observer(sph_system, "BeamObserver"); beam_observer.defineAdaptationRatios(1.15, 2.0); beam_observer.generateParticles(observation_location); //---------------------------------------------------------------------- @@ -136,15 +136,15 @@ int main(int ac, char *av[]) //----------------------------------------------------------------------------- // outputs //----------------------------------------------------------------------------- - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_beam_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_beam_states(io_environment, sph_system.real_bodies_); RegressionTestEnsembleAverage> write_beam_tip_displacement("Position", io_environment, beam_observer_contact); //---------------------------------------------------------------------- // Setup computing and initial conditions. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); beam_initial_velocity.exec(); beam_corrected_configuration.exec(); //---------------------------------------------------------------------- @@ -210,7 +210,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { // The lift force at the cylinder is very small and not important in this case. write_beam_tip_displacement.generateDataBase(Vec2d(1.0e-2, 1.0e-2), Vec2d(1.0e-2, 1.0e-2)); @@ -220,5 +220,6 @@ int main(int ac, char *av[]) write_beam_tip_displacement.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_oscillating_beam_cauchy/CMakeLists.txt b/tests/2d_examples/test_2d_oscillating_beam_cauchy/CMakeLists.txt index ec6b556b8e..953241746b 100644 --- a/tests/2d_examples/test_2d_oscillating_beam_cauchy/CMakeLists.txt +++ b/tests/2d_examples/test_2d_oscillating_beam_cauchy/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # main (to set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -21,4 +19,5 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} extra_sources_2d) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/2d_examples/test_2d_oscillating_beam_cauchy/cauchy_oscillating_beam.cpp b/tests/2d_examples/test_2d_oscillating_beam_cauchy/cauchy_oscillating_beam.cpp index d81e214f6a..98330f69bc 100644 --- a/tests/2d_examples/test_2d_oscillating_beam_cauchy/cauchy_oscillating_beam.cpp +++ b/tests/2d_examples/test_2d_oscillating_beam_cauchy/cauchy_oscillating_beam.cpp @@ -99,19 +99,18 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); - system.generate_regression_data_ = false; + SPHSystem sph_system(system_domain_bounds, resolution_ref); #ifdef BOOST_AVAILABLE // handle command line arguments - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(system, makeShared("BeamBody")); + SolidBody beam_body(sph_system, makeShared("BeamBody")); beam_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); beam_body.generateParticles(); - ObserverBody beam_observer(system, "BeamObserver"); + ObserverBody beam_observer(sph_system, "BeamObserver"); beam_observer.defineAdaptationRatios(1.15, 2.0); beam_observer.generateParticles(observation_location); //---------------------------------------------------------------------- @@ -138,15 +137,15 @@ int main(int ac, char *av[]) //----------------------------------------------------------------------------- // outputs //----------------------------------------------------------------------------- - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_beam_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_beam_states(io_environment, sph_system.real_bodies_); RegressionTestEnsembleAverage> write_beam_tip_displacement("Position", io_environment, beam_observer_contact); //---------------------------------------------------------------------- // Setup computing and initial conditions. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); beam_initial_velocity.exec(); beam_corrected_configuration.exec(); //---------------------------------------------------------------------- @@ -212,7 +211,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { // The lift force at the cylinder is very small and not important in this case. write_beam_tip_displacement.generateDataBase(Vec2d(1.0e-2, 1.0e-2), Vec2d(1.0e-2, 1.0e-2)); @@ -222,5 +221,6 @@ int main(int ac, char *av[]) write_beam_tip_displacement.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_owsc/CMakeLists.txt b/tests/2d_examples/test_2d_owsc/CMakeLists.txt index 3280c23780..ac809a778f 100644 --- a/tests/2d_examples/test_2d_owsc/CMakeLists.txt +++ b/tests/2d_examples/test_2d_owsc/CMakeLists.txt @@ -17,7 +17,7 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "FSI, Simbody") diff --git a/tests/2d_examples/test_2d_owsc/owsc.cpp b/tests/2d_examples/test_2d_owsc/owsc.cpp index f36d42ed8f..14c2e20c67 100644 --- a/tests/2d_examples/test_2d_owsc/owsc.cpp +++ b/tests/2d_examples/test_2d_owsc/owsc.cpp @@ -12,25 +12,25 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); - SolidBody flap(system, makeShared("Flap")); + SolidBody flap(sph_system, makeShared("Flap")); flap.defineParticlesAndMaterial(rho0_s); flap.generateParticles(); - ObserverBody observer(system, "FlapObserver"); + ObserverBody observer(sph_system, "FlapObserver"); observer.generateParticles(); //---------------------------------------------------------------------- // Define body relation map. @@ -157,7 +157,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping< ReducedQuantityRecording>> write_total_force_on_flap(io_environment, fluid_force_on_flap, "TotalForceOnSolid"); @@ -187,8 +187,8 @@ int main(int ac, char *av[]) // and case specified initial condition if necessary. //---------------------------------------------------------------------- flap_offset_position.exec(); - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); flap_normal_direction.exec(); flap_corrected_configuration.exec(); @@ -297,7 +297,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_total_force_on_flap.generateDataBase(1.0e-3); } @@ -306,5 +306,6 @@ int main(int ac, char *av[]) write_total_force_on_flap.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_particle_generator_single_resolution/CMakeLists.txt b/tests/2d_examples/test_2d_particle_generator_single_resolution/CMakeLists.txt index a00c11dc08..18ef50f456 100644 --- a/tests/2d_examples/test_2d_particle_generator_single_resolution/CMakeLists.txt +++ b/tests/2d_examples/test_2d_particle_generator_single_resolution/CMakeLists.txt @@ -6,7 +6,6 @@ set(CMAKE_VERBOSE_MAKEFILE on) STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") @@ -14,14 +13,14 @@ SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/SPHinXsys-2d.dat - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "particle relaxation") - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_particle_generator_single_resolution/particle_generator_single_resolution.cpp b/tests/2d_examples/test_2d_particle_generator_single_resolution/particle_generator_single_resolution.cpp index ad35bd70d7..8c19d6d9d7 100644 --- a/tests/2d_examples/test_2d_particle_generator_single_resolution/particle_generator_single_resolution.cpp +++ b/tests/2d_examples/test_2d_particle_generator_single_resolution/particle_generator_single_resolution.cpp @@ -40,17 +40,18 @@ class InputBody : public ComplexShape //---------------------------------------------------------------------- // The main program //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up -- a SPHSystem //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody input_body(system, makeShared("SPHInXsysLogo")); + RealBody input_body(sph_system, makeShared("SPHInXsysLogo")); input_body.defineBodyLevelSetShape()->writeLevelSet(io_environment); input_body.defineParticlesAndMaterial(); input_body.generateParticles(); @@ -98,5 +99,6 @@ int main() } std::cout << "The physics relaxation process finish !" << std::endl; + return 0; } diff --git a/tests/2d_examples/test_2d_plate/2d_plate.cpp b/tests/2d_examples/test_2d_plate/2d_plate.cpp index bd5d9ff6f0..4136854991 100644 --- a/tests/2d_examples/test_2d_plate/2d_plate.cpp +++ b/tests/2d_examples/test_2d_plate/2d_plate.cpp @@ -77,22 +77,22 @@ class BoundaryGeometry : public BodyPartByParticle //---------------------------------------------------------------------- // Main program starts here. //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up -- a SPHSystem //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); - system.generate_regression_data_ = false; + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody plate_body(system, makeShared("PlateBody")); + SolidBody plate_body(sph_system, makeShared("PlateBody")); plate_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); plate_body.generateParticles(); plate_body.addBodyStateForRecording("PriorAcceleration"); - ObserverBody plate_observer(system, "PlateObserver"); + ObserverBody plate_observer(sph_system, "PlateObserver"); plate_observer.generateParticles(observation_location); //---------------------------------------------------------------------- // Define body relation map. @@ -123,16 +123,16 @@ int main() //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_plate_max_displacement("Position", io_environment, plate_observer_contact); // TODO: using ensemble better //---------------------------------------------------------------------- // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); corrected_configuration.exec(); //---------------------------------------------------------------------- // First output before the main loop. @@ -188,7 +188,7 @@ int main() tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_plate_max_displacement.generateDataBase(0.005); } @@ -196,5 +196,7 @@ int main() { write_plate_max_displacement.testResult(); } + + return 0; } diff --git a/tests/2d_examples/test_2d_plate/CMakeLists.txt b/tests/2d_examples/test_2d_plate/CMakeLists.txt index 2a04792f6f..b4fd0c17fd 100644 --- a/tests/2d_examples/test_2d_plate/CMakeLists.txt +++ b/tests/2d_examples/test_2d_plate/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -17,10 +15,10 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_poiseuille_flow/src/CMakeLists.txt b/tests/2d_examples/test_2d_poiseuille_flow/src/CMakeLists.txt index f9c36851dd..1ee80263d9 100644 --- a/tests/2d_examples/test_2d_poiseuille_flow/src/CMakeLists.txt +++ b/tests/2d_examples/test_2d_poiseuille_flow/src/CMakeLists.txt @@ -2,16 +2,14 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) - - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_poiseuille_flow/src/poiseuille_flow.cpp b/tests/2d_examples/test_2d_poiseuille_flow/src/poiseuille_flow.cpp index 41c851e9a7..9baa0e0c46 100644 --- a/tests/2d_examples/test_2d_poiseuille_flow/src/poiseuille_flow.cpp +++ b/tests/2d_examples/test_2d_poiseuille_flow/src/poiseuille_flow.cpp @@ -77,24 +77,23 @@ class WallBoundary : public MultiPolygonShape /** * @brief Main program starts here. */ -int main() +int main(int ac, char *av[]) { /** * @brief Build up -- a SPHSystem -- */ - SPHSystem system(system_domain_bounds, resolution_ref); - /** Set the starting time. */ - GlobalStaticVariables::physical_time_ = 0.0; + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); /** * @brief Material property, particles and body creation of fluid. */ - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); /** * @brief Particle and body creation of wall boundary. */ - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); /** topology */ @@ -131,22 +130,22 @@ int main() /** * @brief Output. */ - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); /** Output the body states. */ - BodyStatesRecordingToVtp body_states_recording(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp body_states_recording(io_environment, sph_system.real_bodies_); /** * @brief Setup geometry and initial conditions. */ - system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemCellLinkedLists(); periodic_condition.update_cell_linked_list_.exec(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); /** Output the start states of bodies. */ body_states_recording.writeToFile(0); /** * @brief Basic parameters. */ - size_t number_of_iterations = system.RestartStep(); + size_t number_of_iterations = sph_system.RestartStep(); int screen_output_interval = 100; Real end_time = 20.0; /**< End time. */ Real Output_Time = 0.1; /**< Time stamps for output of body states. */ @@ -223,5 +222,6 @@ int main() std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; + return 0; } diff --git a/tests/2d_examples/test_2d_self_contact/CMakeLists.txt b/tests/2d_examples/test_2d_self_contact/CMakeLists.txt index ba8305f512..db4397c65e 100644 --- a/tests/2d_examples/test_2d_self_contact/CMakeLists.txt +++ b/tests/2d_examples/test_2d_self_contact/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -19,7 +17,8 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "solid_dynamics; self_contact") set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") diff --git a/tests/2d_examples/test_2d_self_contact/self_contact.cpp b/tests/2d_examples/test_2d_self_contact/self_contact.cpp index 8a532d8beb..5225b43472 100644 --- a/tests/2d_examples/test_2d_self_contact/self_contact.cpp +++ b/tests/2d_examples/test_2d_self_contact/self_contact.cpp @@ -108,19 +108,19 @@ int main(int ac, char *av[]) // Build up -- a SPHSystem //---------------------------------------------------------------------- BoundingBox system_domain_bounds(Vec2d(-SL - BW, -PL / 2.0), Vec2d(PL + 3.0 * BW, PL / 2.0)); - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); // handle command line arguments #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(system, makeShared("BeamBody")); + SolidBody beam_body(sph_system, makeShared("BeamBody")); beam_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); beam_body.generateParticles(); - ObserverBody beam_observer(system, "BeamObserver"); + ObserverBody beam_observer(sph_system, "BeamObserver"); beam_observer.defineAdaptationRatios(1.15, 2.0); StdVec beam_observation_location = {Vecd(PL, 0.0)}; beam_observer.generateParticles(beam_observation_location); @@ -148,16 +148,16 @@ int main(int ac, char *av[]) //----------------------------------------------------------------------------- // outputs //----------------------------------------------------------------------------- - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); beam_body.addBodyStateForRecording("SelfContactDensity"); - BodyStatesRecordingToVtp write_beam_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_beam_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_beam_tip_displacement("Position", io_environment, beam_observer_contact); //----------------------------------------------------------------------------- // Setup particle configuration and initial conditions //----------------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); beam_initial_velocity.exec(); beam_corrected_configuration.exec(); //----------------------------------------------------------------------------- @@ -230,7 +230,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_beam_tip_displacement.generateDataBase(1.0e-2); } @@ -239,5 +239,6 @@ int main(int ac, char *av[]) write_beam_tip_displacement.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_shell/2d_shell.cpp b/tests/2d_examples/test_2d_shell/2d_shell.cpp index 2f2f63f21a..875fcf135a 100644 --- a/tests/2d_examples/test_2d_shell/2d_shell.cpp +++ b/tests/2d_examples/test_2d_shell/2d_shell.cpp @@ -91,19 +91,20 @@ class TimeDependentExternalForce : public Gravity /** * The main program */ -int main() +int main(int ac, char *av[]) { /** Setup the system. */ - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.generate_regression_data_ = false; + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); + /** Create a Cylinder body. */ - SolidBody cylinder_body(system, makeShared("CylinderBody")); + SolidBody cylinder_body(sph_system, makeShared("CylinderBody")); cylinder_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); cylinder_body.generateParticles(); cylinder_body.addBodyStateForRecording("PseudoNormal"); /** Define Observer. */ - ObserverBody cylinder_observer(system, "CylinderObserver"); + ObserverBody cylinder_observer(sph_system, "CylinderObserver"); cylinder_observer.generateParticles(observation_location); /** Set body contact map @@ -138,14 +139,14 @@ int main() DampingWithRandomChoice>> cylinder_rotation_damping(0.2, cylinder_body_inner, "AngularVelocity", physical_viscosity); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_cylinder_max_displacement("Position", io_environment, cylinder_observer_contact); /** Apply initial condition. */ - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); corrected_configuration.exec(); /** @@ -203,7 +204,7 @@ int main() tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_cylinder_max_displacement.generateDataBase(0.05); } @@ -212,5 +213,6 @@ int main() write_cylinder_max_displacement.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_shell/CMakeLists.txt b/tests/2d_examples/test_2d_shell/CMakeLists.txt index d02f3b7072..dd37c79d04 100644 --- a/tests/2d_examples/test_2d_shell/CMakeLists.txt +++ b/tests/2d_examples/test_2d_shell/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -19,8 +17,8 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_shell_beam_collision/src/CMakeLists.txt b/tests/2d_examples/test_2d_shell_beam_collision/src/CMakeLists.txt index 1ce100f914..206ae228bc 100644 --- a/tests/2d_examples/test_2d_shell_beam_collision/src/CMakeLists.txt +++ b/tests/2d_examples/test_2d_shell_beam_collision/src/CMakeLists.txt @@ -10,9 +10,9 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "contact, Simbody") diff --git a/tests/2d_examples/test_2d_shell_beam_collision/src/shell_beam_collision.cpp b/tests/2d_examples/test_2d_shell_beam_collision/src/shell_beam_collision.cpp index d54bdfb510..3caa46994a 100644 --- a/tests/2d_examples/test_2d_shell_beam_collision/src/shell_beam_collision.cpp +++ b/tests/2d_examples/test_2d_shell_beam_collision/src/shell_beam_collision.cpp @@ -302,5 +302,7 @@ int main(int ac, char *av[]) TimeInterval tt; tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + + return 0; } diff --git a/tests/2d_examples/test_2d_shell_particle_relaxation/CMakeLists.txt b/tests/2d_examples/test_2d_shell_particle_relaxation/CMakeLists.txt index 2784a21747..bb0d6ba49b 100644 --- a/tests/2d_examples/test_2d_shell_particle_relaxation/CMakeLists.txt +++ b/tests/2d_examples/test_2d_shell_particle_relaxation/CMakeLists.txt @@ -3,10 +3,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -16,11 +15,11 @@ file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) + +add_test(NAME ${PROJECT_NAME}_particle_relaxation + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME}_particle_relaxation - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_shell_particle_relaxation/test_2d_shell_particle_relaxation.cpp b/tests/2d_examples/test_2d_shell_particle_relaxation/test_2d_shell_particle_relaxation.cpp index 1343658e6b..1a2f1b5de1 100644 --- a/tests/2d_examples/test_2d_shell_particle_relaxation/test_2d_shell_particle_relaxation.cpp +++ b/tests/2d_examples/test_2d_shell_particle_relaxation/test_2d_shell_particle_relaxation.cpp @@ -33,14 +33,15 @@ class Pipe : public MultiPolygonShape //-------------------------------------------------------------------------- // Main program starts here. //-------------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { /** Build up a SPHSystem. */ - SPHSystem system(system_domain_bounds, resolution_ref); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); /** Creating body, materials and particles. */ - SolidBody pipe_body(system, makeShared("PipeBody")); + SolidBody pipe_body(sph_system, makeShared("PipeBody")); pipe_body.defineAdaptation(1.15, 1.0); pipe_body.defineBodyLevelSetShape(level_set_refinement_ratio)->writeLevelSet(io_environment); // here dummy linear elastic solid is use because no solid dynamics in particle relaxation @@ -91,5 +92,6 @@ int main() write_real_body_states.writeToFile(ite_p); std::cout << "The physics relaxation process of the cylinder finish !" << std::endl; + return 0; } \ No newline at end of file diff --git a/tests/2d_examples/test_2d_sliding/CMakeLists.txt b/tests/2d_examples/test_2d_sliding/CMakeLists.txt index b56cbf0cd3..dd37c79d04 100644 --- a/tests/2d_examples/test_2d_sliding/CMakeLists.txt +++ b/tests/2d_examples/test_2d_sliding/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -19,7 +17,8 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_sliding/sliding.cpp b/tests/2d_examples/test_2d_sliding/sliding.cpp index 9e5c050757..4a9eb5626e 100644 --- a/tests/2d_examples/test_2d_sliding/sliding.cpp +++ b/tests/2d_examples/test_2d_sliding/sliding.cpp @@ -195,7 +195,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { // The lift force at the cylinder is very small and not important in this case. write_free_cube_displacement.generateDataBase({1.0e-2, 1.0e-2}, {1.0e-2, 1.0e-2}); @@ -205,5 +205,6 @@ int main(int ac, char *av[]) write_free_cube_displacement.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_square_droplet/src/CMakeLists.txt b/tests/2d_examples/test_2d_square_droplet/src/CMakeLists.txt index f9c36851dd..1ee80263d9 100644 --- a/tests/2d_examples/test_2d_square_droplet/src/CMakeLists.txt +++ b/tests/2d_examples/test_2d_square_droplet/src/CMakeLists.txt @@ -2,16 +2,14 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) - - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_square_droplet/src/droplet.cpp b/tests/2d_examples/test_2d_square_droplet/src/droplet.cpp index 6e3d7bf78b..5c97724dc5 100644 --- a/tests/2d_examples/test_2d_square_droplet/src/droplet.cpp +++ b/tests/2d_examples/test_2d_square_droplet/src/droplet.cpp @@ -102,13 +102,14 @@ class WallBoundary : public MultiPolygonShape //---------------------------------------------------------------------- // Main program starts here. //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up an SPHSystem. //---------------------------------------------------------------------- BoundingBox system_domain_bounds(Vec2d(-BW, -BW), Vec2d(DL + BW, DH + BW)); SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. @@ -305,5 +306,6 @@ int main() std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; + return 0; } diff --git a/tests/2d_examples/test_2d_standing_wave/CMakeLists.txt b/tests/2d_examples/test_2d_standing_wave/CMakeLists.txt index 1e1bc16be3..18fb6d3062 100644 --- a/tests/2d_examples/test_2d_standing_wave/CMakeLists.txt +++ b/tests/2d_examples/test_2d_standing_wave/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # main (to set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) @@ -15,11 +15,11 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -add_executable(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +add_executable(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} extra_sources_2d) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME}_restart COMMAND ${PROJECT_NAME} --restart_step=4000 - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME}_restart COMMAND ${PROJECT_NAME} --restart_step=4000 --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy.xml deleted file mode 100644 index 245c7c132d..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml index 522cd89567..7bd0aced5c 100644 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_0_result.xml @@ -1,9 +1,9 @@ - + - + diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_12_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_12_result.xml new file mode 100644 index 0000000000..2a6d051a3b --- /dev/null +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_12_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_1_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_1_result.xml deleted file mode 100644 index 95909cad10..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_1_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_2_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_2_result.xml deleted file mode 100644 index ce4266216e..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_2_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_3_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_3_result.xml deleted file mode 100644 index 99fc091b82..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_3_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_4_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_4_result.xml deleted file mode 100644 index fee5e7e55e..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_4_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml deleted file mode 100644 index 18c92666d3..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_5_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml index d1085b8e88..cbf5007edf 100644 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_Run_6_result.xml @@ -1,9 +1,9 @@ - + - + diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml index 0cf06461b4..0067554d1a 100644 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_dtwdistance.xml @@ -1,4 +1,4 @@ - + diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat index 34de7daedb..19c6fe5aad 100644 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaterBody_TotalMechanicalEnergy_runtimes.dat @@ -1,3 +1,3 @@ true -7 +13 4 \ No newline at end of file diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight.xml deleted file mode 100644 index aca65ef3bc..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_0_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_0_result.xml index b5f8c03b0c..32f8320757 100644 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_0_result.xml +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_0_result.xml @@ -1,9 +1,9 @@ - + - + diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_1_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_1_result.xml deleted file mode 100644 index 38c48399b4..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_1_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_2_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_2_result.xml deleted file mode 100644 index f0462213c0..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_2_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_3_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_3_result.xml deleted file mode 100644 index 118b098294..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_3_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_4_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_4_result.xml index 760497ebd0..a4fc4d6481 100644 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_4_result.xml +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_4_result.xml @@ -1,9 +1,9 @@ - + - + diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_5_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_5_result.xml deleted file mode 100644 index 2f3471c7c0..0000000000 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_5_result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_8_result.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_8_result.xml new file mode 100644 index 0000000000..fb49fbc29b --- /dev/null +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_Run_8_result.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_dtwdistance.xml b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_dtwdistance.xml index 3d267d10b3..5b459b5e2b 100644 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_dtwdistance.xml +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_dtwdistance.xml @@ -1,4 +1,4 @@ - + diff --git a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_runtimes.dat b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_runtimes.dat index de07de18db..0c87390426 100644 --- a/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_runtimes.dat +++ b/tests/2d_examples/test_2d_standing_wave/regression_test_tool/WaveProbe_FreeSurfaceHeight_runtimes.dat @@ -1,3 +1,3 @@ true -6 +9 4 \ No newline at end of file diff --git a/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp b/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp index a21c24331a..09935f6f35 100644 --- a/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp +++ b/tests/2d_examples/test_2d_standing_wave/standing_wave.cpp @@ -111,7 +111,6 @@ int main(int ac, char *av[]) sph_system.setRunParticleRelaxation(false); /** Tag for computation start with relaxed body fitted particles distribution. */ sph_system.setReloadParticles(false); - sph_system.generate_regression_data_ = true; sph_system.handleCommandlineOptions(ac, av); IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- @@ -328,7 +327,7 @@ int main(int ac, char *av[]) std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_water_mechanical_energy.generateDataBase(1.0e-3); wave_probe.generateDataBase(1.0e-3); @@ -339,5 +338,6 @@ int main(int ac, char *av[]) wave_probe.testResult(); } + return 0; }; diff --git a/tests/2d_examples/test_2d_static_confinement/CMakeLists.txt b/tests/2d_examples/test_2d_static_confinement/CMakeLists.txt index 3874771c1f..30e5a0c2e5 100644 --- a/tests/2d_examples/test_2d_static_confinement/CMakeLists.txt +++ b/tests/2d_examples/test_2d_static_confinement/CMakeLists.txt @@ -5,8 +5,6 @@ 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") @@ -16,11 +14,10 @@ file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) - aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") diff --git a/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp b/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp index 4ff77a2802..3d98eaf391 100644 --- a/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp +++ b/tests/2d_examples/test_2d_static_confinement/static_confinement.cpp @@ -264,7 +264,7 @@ int main(int ac, char *av[]) std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_water_mechanical_energy.generateDataBase(1.0e-3); write_recorded_water_pressure.generateDataBase(1.0e-3); @@ -275,5 +275,6 @@ int main(int ac, char *av[]) write_recorded_water_pressure.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_stfb/CMakeLists.txt b/tests/2d_examples/test_2d_stfb/CMakeLists.txt index 9e1975cf4f..5c22b6b9c1 100644 --- a/tests/2d_examples/test_2d_stfb/CMakeLists.txt +++ b/tests/2d_examples/test_2d_stfb/CMakeLists.txt @@ -18,7 +18,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "fluid dynamics, Simbody") diff --git a/tests/2d_examples/test_2d_stfb/stfb.cpp b/tests/2d_examples/test_2d_stfb/stfb.cpp index 5cee2fddfe..d91df6807c 100644 --- a/tests/2d_examples/test_2d_stfb/stfb.cpp +++ b/tests/2d_examples/test_2d_stfb/stfb.cpp @@ -13,27 +13,27 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); water_block.addBodyStateForRecording("VolumetricMeasure"); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); - SolidBody structure(system, makeShared>( - Transform(structure_translation), structure_halfsize, "Structure")); + SolidBody structure(sph_system, makeShared>( + Transform(structure_translation), structure_halfsize, "Structure")); structure.defineParticlesAndMaterial(rho_s); structure.generateParticles(); - ObserverBody observer(system, "Observer"); + ObserverBody observer(sph_system, "Observer"); observer.defineAdaptationRatios(1.15, 2.0); observer.generateParticles( StdVec{obs}); @@ -142,7 +142,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); BodyRegionByCell wave_probe_buffer(water_block, makeShared>( Transform(gauge_translation), gauge_halfsize, "FreeSurfaceGauge")); RegressionTestDynamicTimeWarping>> wave_gauge(io_environment, wave_probe_buffer); @@ -155,8 +155,8 @@ int main(int ac, char *av[]) // and case specified initial condition if necessary. //---------------------------------------------------------------------- structure_offset_position.exec(); - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); str_normal.exec(); str_corrected_conf.exec(); @@ -257,7 +257,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_str_displacement.generateDataBase(0.001); wave_gauge.generateDataBase(0.001); @@ -268,5 +268,6 @@ int main(int ac, char *av[]) wave_gauge.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_stfb/stfb.h b/tests/2d_examples/test_2d_stfb/stfb.h index 7c3fd5b541..2bc603cfec 100644 --- a/tests/2d_examples/test_2d_stfb/stfb.h +++ b/tests/2d_examples/test_2d_stfb/stfb.h @@ -45,7 +45,7 @@ Real FlStA = L * L; /**< Density of the solid structure*/ Real rho_s = StructureMass / FlStA; /* Equilibrium position of the solid structure*/ -Real H = -(rho_s / rho0_f * L - L / 2); /**< Strart placemnt of Flt Body*/ +Real H = -(rho_s / rho0_f * L - L / 2); /**< Strart placement of Flt Body*/ Real bcmx = 0; Real bcmy = H + 0; @@ -98,7 +98,7 @@ class WaterBlock : public ComplexShape } }; //---------------------------------------------------------------------- -// create mesuring probes +// create measuring probes //---------------------------------------------------------------------- Real h = 1.3 * particle_spacing_ref; Vec2d gauge_halfsize = Vec2d(0.5 * h, 0.5 * DH); diff --git a/tests/2d_examples/test_2d_stlw/CMakeLists.txt b/tests/2d_examples/test_2d_stlw/CMakeLists.txt index 0845141eff..898524456b 100644 --- a/tests/2d_examples/test_2d_stlw/CMakeLists.txt +++ b/tests/2d_examples/test_2d_stlw/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -18,10 +16,10 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_stlw/stlw.cpp b/tests/2d_examples/test_2d_stlw/stlw.cpp index e9ce981708..fd147296b1 100644 --- a/tests/2d_examples/test_2d_stlw/stlw.cpp +++ b/tests/2d_examples/test_2d_stlw/stlw.cpp @@ -12,19 +12,19 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared>( - Transform(water_block_translation), water_block_halfsize, "Structure")); + FluidBody water_block(sph_system, makeShared>( + Transform(water_block_translation), water_block_halfsize, "Structure")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); water_block.addBodyStateForRecording("VolumetricMeasure"); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); //---------------------------------------------------------------------- @@ -54,7 +54,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); BodyRegionByCell wave_probe_buffer(water_block, makeShared>( Transform(gauge_translation), gauge_halfsize, "FreeSurfaceGauge")); RegressionTestDynamicTimeWarping>> wave_gauge(io_environment, wave_probe_buffer); @@ -62,8 +62,8 @@ int main(int ac, char *av[]) // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); //---------------------------------------------------------------------- // First output before the main loop. @@ -144,7 +144,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { wave_gauge.generateDataBase(0.1); } @@ -153,5 +153,6 @@ int main(int ac, char *av[]) wave_gauge.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_stlw/stlw.h b/tests/2d_examples/test_2d_stlw/stlw.h index a53c4c7600..a76c30b61e 100644 --- a/tests/2d_examples/test_2d_stlw/stlw.h +++ b/tests/2d_examples/test_2d_stlw/stlw.h @@ -46,7 +46,7 @@ class WallBoundary : public ComplexShape } }; //---------------------------------------------------------------------- -// create mesuring probes +// create measuring probes //---------------------------------------------------------------------- Real h = 1.3 * particle_spacing_ref; Vec2d gauge_halfsize = Vec2d(0.5 * h, 0.5 * DH); diff --git a/tests/2d_examples/test_2d_taylor_green/CMakeLists.txt b/tests/2d_examples/test_2d_taylor_green/CMakeLists.txt index 144e7af607..ba6ff7df69 100644 --- a/tests/2d_examples/test_2d_taylor_green/CMakeLists.txt +++ b/tests/2d_examples/test_2d_taylor_green/CMakeLists.txt @@ -5,8 +5,6 @@ set(CMAKE_VERBOSE_MAKEFILE on) STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") - - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") @@ -14,14 +12,16 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ - DESTINATION ${BUILD_INPUT_PATH}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ + DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME}_lattice COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --i=true WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME}_lattice COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_taylor_green/taylor_green.cpp b/tests/2d_examples/test_2d_taylor_green/taylor_green.cpp index 8595555f97..943e13cba5 100644 --- a/tests/2d_examples/test_2d_taylor_green/taylor_green.cpp +++ b/tests/2d_examples/test_2d_taylor_green/taylor_green.cpp @@ -198,7 +198,7 @@ int main(int ac, char *av[]) write_particle_reload_files.writeToFile(); - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_total_mechanical_energy.generateDataBase(1.0e-3); write_maximum_speed.generateDataBase(1.0e-3); @@ -209,5 +209,6 @@ int main(int ac, char *av[]) write_maximum_speed.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_throat/CMakeLists.txt b/tests/2d_examples/test_2d_throat/CMakeLists.txt index d69138d833..ba4bd8538d 100644 --- a/tests/2d_examples/test_2d_throat/CMakeLists.txt +++ b/tests/2d_examples/test_2d_throat/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # main (to set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -14,14 +12,14 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) \ No newline at end of file diff --git a/tests/2d_examples/test_2d_throat/throat.cpp b/tests/2d_examples/test_2d_throat/throat.cpp index bcbe226713..b2a26a47ee 100644 --- a/tests/2d_examples/test_2d_throat/throat.cpp +++ b/tests/2d_examples/test_2d_throat/throat.cpp @@ -125,21 +125,21 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- BoundingBox system_domain_bounds(Vec2d(-0.5 * DL - BW, -0.5 * DH - BW), Vec2d(0.5 * DL + BW, 0.5 * DH + BW)); - SPHSystem system(system_domain_bounds, resolution_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody fluid_block(system, makeShared("FluidBody")); + FluidBody fluid_block(sph_system, makeShared("FluidBody")); fluid_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f, lambda_f, mu_p_f); fluid_block.generateParticles(); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); - ObserverBody fluid_observer(system, "FluidObserver"); + ObserverBody fluid_observer(sph_system, "FluidObserver"); StdVec observation_location = {Vecd::Zero()}; fluid_observer.generateParticles(observation_location); //---------------------------------------------------------------------- @@ -181,7 +181,7 @@ int main(int ac, char *av[]) // Define the methods for I/O operations, observations // and regression tests of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping>> write_fluid_mechanical_energy(io_environment, fluid_block); RegressionTestDynamicTimeWarping> @@ -190,10 +190,10 @@ int main(int ac, char *av[]) // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemCellLinkedLists(); // initial periodic boundary condition periodic_condition.ghost_creation_.exec(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemConfigurations(); // prepare quantities will be used once only wall_boundary_normal_direction.exec(); //---------------------------------------------------------------------- @@ -246,7 +246,7 @@ int main(int ac, char *av[]) std::cout << std::fixed << std::setprecision(9) << "N=" << number_of_iterations << " Time = " << GlobalStaticVariables::physical_time_ << " Dt = " << Dt << " dt = " << dt << "\n"; - if (number_of_iterations % observation_sample_interval == 0 && number_of_iterations != system.RestartStep()) + if (number_of_iterations % observation_sample_interval == 0 && number_of_iterations != sph_system.RestartStep()) { write_fluid_mechanical_energy.writeToFile(number_of_iterations); write_recorded_fluid_pressure.writeToFile(number_of_iterations); @@ -273,7 +273,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_fluid_mechanical_energy.generateDataBase(1.0e-2); write_recorded_fluid_pressure.generateDataBase(1.0e-2); @@ -284,5 +284,6 @@ int main(int ac, char *av[]) write_recorded_fluid_pressure.testResult(); } + return 0; } diff --git a/tests/2d_examples/test_2d_two_phase_dambreak/CMakeLists.txt b/tests/2d_examples/test_2d_two_phase_dambreak/CMakeLists.txt index b56cbf0cd3..dd37c79d04 100644 --- a/tests/2d_examples/test_2d_two_phase_dambreak/CMakeLists.txt +++ b/tests/2d_examples/test_2d_two_phase_dambreak/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -19,7 +17,8 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_ aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp index e6402e3402..c9af5d17a6 100644 --- a/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp +++ b/tests/2d_examples/test_2d_two_phase_dambreak/two_phase_dambreak.cpp @@ -9,14 +9,13 @@ #include "sphinxsys.h" using namespace SPH; -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up the environment of a SPHSystem. //---------------------------------------------------------------------- SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); - /** Set the starting time. */ - GlobalStaticVariables::physical_time_ = 0.0; + sph_system.handleCommandlineOptions(ac, av); IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. @@ -218,5 +217,6 @@ int main() write_water_mechanical_energy.testResult(); write_recorded_pressure.testResult(); + return 0; } diff --git a/tests/2d_examples/test_2d_wetting_effects/src/CMakeLists.txt b/tests/2d_examples/test_2d_wetting_effects/src/CMakeLists.txt index f9c36851dd..e166b44b87 100644 --- a/tests/2d_examples/test_2d_wetting_effects/src/CMakeLists.txt +++ b/tests/2d_examples/test_2d_wetting_effects/src/CMakeLists.txt @@ -2,16 +2,14 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) - - SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} sphinxsys_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/2d_examples/test_2d_wetting_effects/src/wetting.cpp b/tests/2d_examples/test_2d_wetting_effects/src/wetting.cpp index 0b6ac2244d..72c52e30b3 100644 --- a/tests/2d_examples/test_2d_wetting_effects/src/wetting.cpp +++ b/tests/2d_examples/test_2d_wetting_effects/src/wetting.cpp @@ -8,14 +8,13 @@ #include "sphinxsys.h" using namespace SPH; -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up the environment of a SPHSystem. //---------------------------------------------------------------------- SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); - /** Set the starting time. */ - GlobalStaticVariables::physical_time_ = 0.0; + sph_system.handleCommandlineOptions(ac, av); IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. @@ -211,5 +210,6 @@ int main() std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; + return 0; } diff --git a/tests/3d_examples/test_3d_arch/3d_arch.cpp b/tests/3d_examples/test_3d_arch/3d_arch.cpp index 6a7ce2288a..b8077f6041 100644 --- a/tests/3d_examples/test_3d_arch/3d_arch.cpp +++ b/tests/3d_examples/test_3d_arch/3d_arch.cpp @@ -137,19 +137,18 @@ class BoundaryGeometry : public BodyPartByParticle int main(int ac, char *av[]) { /** Setup the system. */ - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.generate_regression_data_ = false; + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); /** create a cylinder body with shell particles and linear elasticity. */ - SolidBody cylinder_body(system, makeShared("CylinderBody")); + SolidBody cylinder_body(sph_system, makeShared("CylinderBody")); cylinder_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); cylinder_body.generateParticles(); /** Define Observer. */ - ObserverBody cylinder_observer(system, "CylinderObserver"); + ObserverBody cylinder_observer(sph_system, "CylinderObserver"); cylinder_observer.generateParticles(observation_location); /** Set body contact map @@ -181,13 +180,13 @@ int main(int ac, char *av[]) DampingWithRandomChoice>> cylinder_rotation_damping(0.2, cylinder_body_inner, "AngularVelocity", physical_viscosity); /** Output */ - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_cylinder_max_displacement("Position", io_environment, cylinder_observer_contact); /** Apply initial condition. */ - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); corrected_configuration.exec(); /** @@ -246,7 +245,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_cylinder_max_displacement.generateDataBase(0.05); } @@ -255,5 +254,6 @@ int main(int ac, char *av[]) write_cylinder_max_displacement.testResult(); } + return 0; } diff --git a/tests/3d_examples/test_3d_arch/CMakeLists.txt b/tests/3d_examples/test_3d_arch/CMakeLists.txt index b384300033..066da02fda 100644 --- a/tests/3d_examples/test_3d_arch/CMakeLists.txt +++ b/tests/3d_examples/test_3d_arch/CMakeLists.txt @@ -1,4 +1,4 @@ -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) @@ -10,14 +10,12 @@ file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) - add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/3d_examples/test_3d_beam_pulling_pressure_load/CMakeLists.txt b/tests/3d_examples/test_3d_beam_pulling_pressure_load/CMakeLists.txt index ae2aee5cdf..1372d28d97 100644 --- a/tests/3d_examples/test_3d_beam_pulling_pressure_load/CMakeLists.txt +++ b/tests/3d_examples/test_3d_beam_pulling_pressure_load/CMakeLists.txt @@ -18,7 +18,6 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp b/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp index 240695fc27..b9168ab09e 100644 --- a/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp +++ b/tests/3d_examples/test_3d_beam_pulling_pressure_load/beam_pulling_pressure_load.cpp @@ -111,20 +111,20 @@ class LoadForce : public BaseLocalDynamics, public solid_dyn int main(int ac, char *av[]) { /** Setup the system. Please the make sure the global domain bounds are correctly defined. */ - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); #ifdef BOOST_AVAILABLE // handle command line arguments - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); /** Import a beam body, with corresponding material and particles. */ - SolidBody beam_body(system, makeShared("beam")); + SolidBody beam_body(sph_system, makeShared("beam")); beam_body.defineParticlesAndMaterial(rho, Youngs_modulus, poisson_ratio); beam_body.generateParticles(); // Define Observer - ObserverBody beam_observer(system, "BeamObserver"); + ObserverBody beam_observer(sph_system, "BeamObserver"); beam_observer.generateParticles(observation_location); /** topology */ InnerRelation beam_body_inner(beam_body); @@ -169,13 +169,13 @@ int main(int ac, char *av[]) beam_damping(0.1, beam_body_inner, "Velocity", physical_viscosity); /** Output */ - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestTimeAverage> write_beam_stress("VonMisesStress", io_environment, beam_observer_contact); /* time step begins */ GlobalStaticVariables::physical_time_ = 0.0; - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); /** apply initial condition */ corrected_configuration.exec(); @@ -215,7 +215,7 @@ int main(int ac, char *av[]) stress_relaxation_second_half.exec(dt); ite++; - dt = system.getSmallestTimeStepAmongSolidBodies(); + dt = sph_system.getSmallestTimeStepAmongSolidBodies(); integration_time += dt; GlobalStaticVariables::physical_time_ += dt; } @@ -232,7 +232,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_beam_stress.generateDataBase(0.01, 0.01); } diff --git a/tests/3d_examples/test_3d_bending_circular_plate_parametric_cvt/test_3d_bending_circular_plate_parametric_cvt.cpp b/tests/3d_examples/test_3d_bending_circular_plate_parametric_cvt/test_3d_bending_circular_plate_parametric_cvt.cpp index f1d4e81d42..7f9d0b93b7 100644 --- a/tests/3d_examples/test_3d_bending_circular_plate_parametric_cvt/test_3d_bending_circular_plate_parametric_cvt.cpp +++ b/tests/3d_examples/test_3d_bending_circular_plate_parametric_cvt/test_3d_bending_circular_plate_parametric_cvt.cpp @@ -3,7 +3,8 @@ * @brief Shell verification incl. refinement study * @details Circular plastic shell verification case with relaxed shell particles * @author Bence Rochlitz - * @ref ANSYS Workbench Verification Manual, Release 15.0, November 2013, VMMECH051: Bending of a Circular Plate Using Axisymmetric Elements + * @ref ANSYS Workbench Verification Manual, Release 15.0, November 2013, + * VMMECH051: Bending of a Circular Plate Using Axis symmetric Elements */ #include "sphinxsys.h" @@ -61,8 +62,8 @@ StdVec read_obj_vertices(const std::string &file_name) { std::cout << "read_obj_vertices started" << std::endl; - std::ifstream myfile(file_name, std::ios_base::in); - if (!myfile.is_open()) + std::ifstream my_file(file_name, std::ios_base::in); + if (!my_file.is_open()) throw std::runtime_error("read_obj_vertices: file doesn't exist: " + file_name); StdVec pos_0; @@ -70,7 +71,7 @@ StdVec read_obj_vertices(const std::string &file_name) unsigned int count = 0; Real value = 0; - while (myfile >> value) + while (my_file >> value) { particle[count] = value; ++count; @@ -163,11 +164,11 @@ struct return_data void write_data_to_txt(const std::string &file_name) const { - std::ofstream myfile; - myfile.open(file_name); - myfile << "deflection; stress_max\n"; - myfile << deflection << "; " << stress_max << "\n"; - myfile.close(); + std::ofstream my_file; + my_file.open(file_name); + my_file << "deflection; stress_max\n"; + my_file << deflection << "; " << stress_max << "\n"; + my_file.close(); } }; diff --git a/tests/3d_examples/test_3d_dambreak/CMakeLists.txt b/tests/3d_examples/test_3d_dambreak/CMakeLists.txt index 4d3dca07ba..066da02fda 100644 --- a/tests/3d_examples/test_3d_dambreak/CMakeLists.txt +++ b/tests/3d_examples/test_3d_dambreak/CMakeLists.txt @@ -16,7 +16,6 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/3d_examples/test_3d_dambreak/dambreak.cpp b/tests/3d_examples/test_3d_dambreak/dambreak.cpp index a597b273fc..d8c5611497 100644 --- a/tests/3d_examples/test_3d_dambreak/dambreak.cpp +++ b/tests/3d_examples/test_3d_dambreak/dambreak.cpp @@ -71,22 +71,22 @@ int main(int ac, char *av[]) // Build up an SPHSystem. //---------------------------------------------------------------------- BoundingBox system_domain_bounds(Vecd(-BW, -BW, -BW), Vecd(DL + BW, DH + BW, DW + BW)); - SPHSystem system(system_domain_bounds, resolution_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f); water_block.generateParticles(); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); wall_boundary.addBodyStateForRecording("NormalDirection"); - ObserverBody fluid_observer(system, "FluidObserver"); + ObserverBody fluid_observer(sph_system, "FluidObserver"); fluid_observer.generateParticles(); //---------------------------------------------------------------------- // Define body relation map. @@ -111,7 +111,7 @@ int main(int ac, char *av[]) // Define the methods for I/O operations, observations // and regression tests of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_water_block_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_water_block_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping>> write_water_mechanical_energy(io_environment, water_block, gravity_ptr); RegressionTestDynamicTimeWarping> @@ -120,13 +120,13 @@ int main(int ac, char *av[]) // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); //---------------------------------------------------------------------- // Setup for time-stepping control //---------------------------------------------------------------------- - size_t number_of_iterations = system.RestartStep(); + size_t number_of_iterations = sph_system.RestartStep(); int screen_output_interval = 100; Real end_time = 20.0; Real output_interval = end_time / 20.0; @@ -192,7 +192,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_water_mechanical_energy.generateDataBase(1.0e-3); write_recorded_water_pressure.generateDataBase(1.0e-3); @@ -203,5 +203,6 @@ int main(int ac, char *av[]) write_recorded_water_pressure.testResult(); } + return 0; } diff --git a/tests/3d_examples/test_3d_dynamic_plate/CMakeLists.txt b/tests/3d_examples/test_3d_dynamic_plate/CMakeLists.txt index 4e26998d6e..349eff1c3a 100644 --- a/tests/3d_examples/test_3d_dynamic_plate/CMakeLists.txt +++ b/tests/3d_examples/test_3d_dynamic_plate/CMakeLists.txt @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/3d_examples/test_3d_dynamic_plate/test_3d_dynamic_plate.cpp b/tests/3d_examples/test_3d_dynamic_plate/test_3d_dynamic_plate.cpp index 62743cee59..656a00201e 100644 --- a/tests/3d_examples/test_3d_dynamic_plate/test_3d_dynamic_plate.cpp +++ b/tests/3d_examples/test_3d_dynamic_plate/test_3d_dynamic_plate.cpp @@ -135,19 +135,19 @@ class TimeDependentExternalForce : public Gravity /** * The main program */ -int main() +int main(int ac, char *av[]) { /** Setup the system. */ - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.generate_regression_data_ = false; + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); /** create a plate body. */ - SolidBody plate_body(system, makeShared("PlateBody")); + SolidBody plate_body(sph_system, makeShared("PlateBody")); plate_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); plate_body.generateParticles(); plate_body.addBodyStateForRecording("PriorAcceleration"); /** Define Observer. */ - ObserverBody plate_observer(system, "PlateObserver"); + ObserverBody plate_observer(sph_system, "PlateObserver"); plate_observer.defineParticlesAndMaterial(); plate_observer.generateParticles(observation_location); @@ -159,8 +159,8 @@ int main() ContactRelation plate_observer_contact(plate_observer, {&plate_body}); /** Common particle dynamics. */ - SimpleDynamics initialize_external_force(plate_body, - makeShared(Vec3d(0.0, 0.0, q / (PT * rho0_s) - gravitational_acceleration))); + SimpleDynamics initialize_external_force( + plate_body, makeShared(Vec3d(0.0, 0.0, q / (PT * rho0_s) - gravitational_acceleration))); /** * This section define all numerical methods will be used in this case. @@ -179,18 +179,18 @@ int main() BoundaryGeometry boundary_geometry(plate_body, "BoundaryGeometry"); SimpleDynamics constrain_holder(boundary_geometry); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_plate_max_displacement("Position", io_environment, plate_observer_contact); /** Apply initial condition. */ - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); corrected_configuration.exec(); /** - * From here the time stepping begines. + * From here the time stepping begins. * Set the starting time. */ GlobalStaticVariables::physical_time_ = 0.0; @@ -211,8 +211,8 @@ int main() */ while (GlobalStaticVariables::physical_time_ < end_time) { - Real integeral_time = 0.0; - while (integeral_time < output_period) + Real integral_time = 0.0; + while (integral_time < output_period) { if (ite % 100 == 0) { @@ -227,7 +227,7 @@ int main() ite++; dt = computing_time_step_size.exec(); - integeral_time += dt; + integral_time += dt; GlobalStaticVariables::physical_time_ += dt; } write_plate_max_displacement.writeToFile(ite); @@ -242,7 +242,7 @@ int main() tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_plate_max_displacement.generateDataBase(0.005); } @@ -251,5 +251,6 @@ int main() write_plate_max_displacement.testResult(); } + return 0; } diff --git a/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp b/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp index 133e713078..e2df6e9d34 100644 --- a/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp +++ b/tests/3d_examples/test_3d_elasticSolid_shell_collision/3d_elasticSolid_shell_collision.cpp @@ -62,7 +62,7 @@ int main(int ac, char *av[]) // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- SPHSystem sph_system(system_domain_bounds, resolution_ref); - // sph_system.generate_regression_data_ = true; + // sph_system.GenerateRegressionData() = true; /** Tag for running particle relaxation for the initially body-fitted distribution */ sph_system.setRunParticleRelaxation(false); /** Tag for starting with relaxed body-fitted particles distribution */ @@ -232,7 +232,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_ball_center_displacement.generateDataBase(0.005); } @@ -240,5 +240,7 @@ int main(int ac, char *av[]) { write_ball_center_displacement.testResult(); } + + return 0; } diff --git a/tests/3d_examples/test_3d_elasticSolid_shell_collision/CMakeLists.txt b/tests/3d_examples/test_3d_elasticSolid_shell_collision/CMakeLists.txt index 2521c99a1c..f559e6cebc 100644 --- a/tests/3d_examples/test_3d_elasticSolid_shell_collision/CMakeLists.txt +++ b/tests/3d_examples/test_3d_elasticSolid_shell_collision/CMakeLists.txt @@ -16,18 +16,10 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -if(CMAKE_SYSTEM_NAME MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash "${EXECUTABLE_OUTPUT_PATH}/run_test.sh" - WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -endif() +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "particle_relaxation, thick_surface, solid_dynamics, contact") - \ No newline at end of file diff --git a/tests/3d_examples/test_3d_elasticSolid_shell_collision/regression_test_tool/regression_test_tool.py b/tests/3d_examples/test_3d_elasticSolid_shell_collision/regression_test_tool/regression_test_tool.py index bc678e8c49..363828a4b4 100644 --- a/tests/3d_examples/test_3d_elasticSolid_shell_collision/regression_test_tool/regression_test_tool.py +++ b/tests/3d_examples/test_3d_elasticSolid_shell_collision/regression_test_tool/regression_test_tool.py @@ -22,7 +22,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() print("Please note: This is the", number_of_run_times, "run!") diff --git a/tests/3d_examples/test_3d_elasticSolid_shell_collision/run_test.sh b/tests/3d_examples/test_3d_elasticSolid_shell_collision/run_test.sh deleted file mode 100755 index 00ee77b9c0..0000000000 --- a/tests/3d_examples/test_3d_elasticSolid_shell_collision/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_3d_elasticSolid_shell_collision --r=true -./test_3d_elasticSolid_shell_collision --r=false --i=true diff --git a/tests/3d_examples/test_3d_heart_electromechanics/CMakeLists.txt b/tests/3d_examples/test_3d_heart_electromechanics/CMakeLists.txt index 6a0f99ef6e..03f607fc7d 100644 --- a/tests/3d_examples/test_3d_heart_electromechanics/CMakeLists.txt +++ b/tests/3d_examples/test_3d_heart_electromechanics/CMakeLists.txt @@ -17,17 +17,10 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") diff --git a/tests/3d_examples/test_3d_heart_electromechanics/excitation-contraction.cpp b/tests/3d_examples/test_3d_heart_electromechanics/excitation-contraction.cpp index d9a7b1ace9..c21d10f035 100644 --- a/tests/3d_examples/test_3d_heart_electromechanics/excitation-contraction.cpp +++ b/tests/3d_examples/test_3d_heart_electromechanics/excitation-contraction.cpp @@ -272,20 +272,20 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // SPHSystem section //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, dp_0); - system.setRunParticleRelaxation(true); // Tag for run particle relaxation for body-fitted distribution - system.setReloadParticles(true); // Tag for computation with save particles distribution + SPHSystem sph_system(system_domain_bounds, dp_0); + sph_system.setRunParticleRelaxation(true); // Tag for run particle relaxation for body-fitted distribution + sph_system.setReloadParticles(true); // Tag for computation with save particles distribution #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); // handle command line arguments + sph_system.handleCommandlineOptions(ac, av); // handle command line arguments #endif - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // SPH Particle relaxation section //---------------------------------------------------------------------- /** check whether run particle relaxation for body fitted particle distribution. */ - if (system.RunParticleRelaxation()) + if (sph_system.RunParticleRelaxation()) { - SolidBody herat_model(system, makeShared("HeartModel")); + SolidBody herat_model(sph_system, makeShared("HeartModel")); herat_model.defineBodyLevelSetShape()->correctLevelSetSign()->writeLevelSet(io_environment); herat_model.defineParticlesAndMaterial(); herat_model.generateParticles(); @@ -359,29 +359,29 @@ int main(int ac, char *av[]) // SPH simulation section //---------------------------------------------------------------------- /** create a SPH body, material and particles */ - SolidBody physiology_heart(system, makeShared("PhysiologyHeart")); + SolidBody physiology_heart(sph_system, makeShared("PhysiologyHeart")); SharedPtr muscle_reaction_model_ptr = makeShared(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); physiology_heart.defineParticlesAndMaterial< ElectroPhysiologyParticles, MonoFieldElectroPhysiology>( muscle_reaction_model_ptr, TypeIdentity(), diffusion_coeff, bias_coeff, fiber_direction); - (!system.RunParticleRelaxation() && system.ReloadParticles()) + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? physiology_heart.generateParticles(io_environment, "HeartModel") : physiology_heart.generateParticles(); /** create a SPH body, material and particles */ - SolidBody mechanics_heart(system, makeShared("MechanicalHeart")); + SolidBody mechanics_heart(sph_system, makeShared("MechanicalHeart")); mechanics_heart.defineParticlesAndMaterial< ElasticSolidParticles, ActiveMuscle>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); - (!system.RunParticleRelaxation() && system.ReloadParticles()) + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? mechanics_heart.generateParticles(io_environment, "HeartModel") : mechanics_heart.generateParticles(); //---------------------------------------------------------------------- // SPH Observation section //---------------------------------------------------------------------- - ObserverBody voltage_observer(system, "VoltageObserver"); + ObserverBody voltage_observer(sph_system, "VoltageObserver"); voltage_observer.generateParticles(); - ObserverBody myocardium_observer(system, "MyocardiumObserver"); + ObserverBody myocardium_observer(sph_system, "MyocardiumObserver"); myocardium_observer.generateParticles(); //---------------------------------------------------------------------- // SPHBody relation (topology) section @@ -429,7 +429,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // SPH Output section //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_voltage("Voltage", io_environment, voltage_observer_contact); RegressionTestDynamicTimeWarping> @@ -437,8 +437,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Pre-simulation. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); correct_configuration_excitation.exec(); correct_configuration_contraction.exec(); correct_kernel_weights_for_interpolation.exec(); @@ -544,5 +544,6 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_heart_electromechanics/regression_test_tool/regression_test_tool.py b/tests/3d_examples/test_3d_heart_electromechanics/regression_test_tool/regression_test_tool.py index 424f4110cd..61fbb30411 100644 --- a/tests/3d_examples/test_3d_heart_electromechanics/regression_test_tool/regression_test_tool.py +++ b/tests/3d_examples/test_3d_heart_electromechanics/regression_test_tool/regression_test_tool.py @@ -26,7 +26,8 @@ while True: print("Now start a new run......") - sphinxsys.run_case() + sphinxsys.run_particle_relaxation() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() converged_1 = sphinxsys_1.read_dat_file() diff --git a/tests/3d_examples/test_3d_heart_electromechanics/run_test.sh b/tests/3d_examples/test_3d_heart_electromechanics/run_test.sh deleted file mode 100644 index 6da86b8d5e..0000000000 --- a/tests/3d_examples/test_3d_heart_electromechanics/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_3d_heart_electromechanics --r=true -./test_3d_heart_electromechanics --r=false --i=true diff --git a/tests/3d_examples/test_3d_heart_volume_change/CMakeLists.txt b/tests/3d_examples/test_3d_heart_volume_change/CMakeLists.txt index dff21eb8c9..03f607fc7d 100644 --- a/tests/3d_examples/test_3d_heart_volume_change/CMakeLists.txt +++ b/tests/3d_examples/test_3d_heart_volume_change/CMakeLists.txt @@ -11,24 +11,16 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) - add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") diff --git a/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.cpp b/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.cpp index e43d1db99e..346d86316d 100644 --- a/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.cpp +++ b/tests/3d_examples/test_3d_heart_volume_change/excitation_contraction.cpp @@ -21,22 +21,22 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // SPHSystem section //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, dp_0); + SPHSystem sph_system(system_domain_bounds, dp_0); GlobalStaticVariables::physical_time_ = 0.0; Real mechanical_time_ = 0.0; - system.setRunParticleRelaxation(true); // Tag for run particle relaxation for body-fitted distribution - system.setReloadParticles(true); // Tag for computation with save particles distribution + sph_system.setRunParticleRelaxation(true); // Tag for run particle relaxation for body-fitted distribution + sph_system.setReloadParticles(true); // Tag for computation with save particles distribution #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); // handle command line arguments + sph_system.handleCommandlineOptions(ac, av); // handle command line arguments #endif - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // SPH Particle relaxation section //---------------------------------------------------------------------- /** check whether run particle relaxation for body fitted particle distribution. */ - if (system.RunParticleRelaxation()) + if (sph_system.RunParticleRelaxation()) { - SolidBody herat_model(system, makeShared("HeartModel")); + SolidBody herat_model(sph_system, makeShared("HeartModel")); herat_model.defineBodyLevelSetShape()->correctLevelSetSign()->writeLevelSet(io_environment); herat_model.defineParticlesAndMaterial(); herat_model.generateParticles(); @@ -110,20 +110,20 @@ int main(int ac, char *av[]) // SPH simulation section //---------------------------------------------------------------------- /** create a SPH body, material and particles */ - SolidBody physiology_heart(system, makeShared("PhysiologyHeart")); + SolidBody physiology_heart(sph_system, makeShared("PhysiologyHeart")); SharedPtr muscle_reaction_model_ptr = makeShared(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); physiology_heart.defineParticlesAndMaterial< ElectroPhysiologyParticles, MonoFieldElectroPhysiology>( muscle_reaction_model_ptr, TypeIdentity(), diffusion_coeff, bias_coeff, fiber_direction); - (!system.RunParticleRelaxation() && system.ReloadParticles()) + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? physiology_heart.generateParticles(io_environment, "HeartModel") : physiology_heart.generateParticles(); /** create a SPH body, material and particles */ - SolidBody mechanics_heart(system, makeShared("MechanicalHeart")); + SolidBody mechanics_heart(sph_system, makeShared("MechanicalHeart")); mechanics_heart.defineParticlesAndMaterial< ElasticSolidParticles, ActiveMuscle>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); - (!system.RunParticleRelaxation() && system.ReloadParticles()) + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? mechanics_heart.generateParticles(io_environment, "HeartModel") : mechanics_heart.generateParticles(); auto myocardium_particles = dynamic_cast(&mechanics_heart.getBaseParticles()); @@ -131,9 +131,9 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // SPH Observation section //---------------------------------------------------------------------- - ObserverBody voltage_observer(system, "VoltageObserver"); + ObserverBody voltage_observer(sph_system, "VoltageObserver"); voltage_observer.generateParticles(); - ObserverBody myocardium_observer(system, "MyocardiumObserver"); + ObserverBody myocardium_observer(sph_system, "MyocardiumObserver"); myocardium_observer.generateParticles(); //---------------------------------------------------------------------- // SPHBody relation (topology) section @@ -184,7 +184,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // SPH Output section //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_voltage("Voltage", io_environment, voltage_observer_contact); RegressionTestDynamicTimeWarping> @@ -192,8 +192,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Pre-simulation. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); correct_configuration_excitation.exec(); correct_configuration_contraction.exec(); correct_kernel_weights_for_interpolation.exec(); @@ -357,5 +357,6 @@ int main(int ac, char *av[]) std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_heart_volume_change/regression_test_tool/regression_test_tool.py b/tests/3d_examples/test_3d_heart_volume_change/regression_test_tool/regression_test_tool.py index 8834f21aff..ff28138ad9 100644 --- a/tests/3d_examples/test_3d_heart_volume_change/regression_test_tool/regression_test_tool.py +++ b/tests/3d_examples/test_3d_heart_volume_change/regression_test_tool/regression_test_tool.py @@ -26,7 +26,8 @@ while True: print("Now start a new run......") - sphinxsys.run_case() + sphinxsys.run_particle_relaxation() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() converged_1 = sphinxsys_1.read_dat_file() diff --git a/tests/3d_examples/test_3d_heart_volume_change/run_test.sh b/tests/3d_examples/test_3d_heart_volume_change/run_test.sh deleted file mode 100644 index 7da081cc7c..0000000000 --- a/tests/3d_examples/test_3d_heart_volume_change/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_3d_heart_volume_change --r=true -./test_3d_heart_volume_change --r=false --i=true diff --git a/tests/3d_examples/test_3d_load_image/CMakeLists.txt b/tests/3d_examples/test_3d_load_image/CMakeLists.txt index ca7c7986b9..83ba6d2062 100644 --- a/tests/3d_examples/test_3d_load_image/CMakeLists.txt +++ b/tests/3d_examples/test_3d_load_image/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/3d_examples/test_3d_load_image/load_image.cpp b/tests/3d_examples/test_3d_load_image/load_image.cpp index 0a3d10eb69..be743faeef 100644 --- a/tests/3d_examples/test_3d_load_image/load_image.cpp +++ b/tests/3d_examples/test_3d_load_image/load_image.cpp @@ -34,17 +34,18 @@ class SolidBodyFromMesh : public ComplexShape //---------------------------------------------------------------------- // Main program begins here //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up -- a SPHSystem //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, dp_0); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, dp_0); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody imported_model(system, makeShared("SolidBodyFromMesh")); + RealBody imported_model(sph_system, makeShared("SolidBodyFromMesh")); imported_model.defineAdaptation(1.15, 1.0, 2); imported_model.defineBodyLevelSetShape()->writeLevelSet(io_environment); imported_model.defineParticlesAndMaterial(); @@ -96,5 +97,6 @@ int main() } std::cout << "The physics relaxation process of imported model finish !" << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_muscle_activation/src/CMakeLists.txt b/tests/3d_examples/test_3d_muscle_activation/src/CMakeLists.txt index 1297d9880b..4e03633bc1 100644 --- a/tests/3d_examples/test_3d_muscle_activation/src/CMakeLists.txt +++ b/tests/3d_examples/test_3d_muscle_activation/src/CMakeLists.txt @@ -9,8 +9,8 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "muscle") diff --git a/tests/3d_examples/test_3d_muscle_activation/src/muscle_activation.cpp b/tests/3d_examples/test_3d_muscle_activation/src/muscle_activation.cpp index f6611cbe60..c80acfd10c 100644 --- a/tests/3d_examples/test_3d_muscle_activation/src/muscle_activation.cpp +++ b/tests/3d_examples/test_3d_muscle_activation/src/muscle_activation.cpp @@ -50,18 +50,19 @@ class MyocardiumActivation //---------------------------------------------------------------------- // Main program starts here. //---------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up an SPHSystem. //---------------------------------------------------------------------- BoundingBox system_domain_bounds(Vecd(-SL, -SL, -SL), Vecd(PL + SL, PH + SL, PW + SL)); - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- - SolidBody myocardium_muscle_body(system, makeShared>( - Transform(translation_myocardium), halfsize_myocardium, "MyocardiumMuscleBody")); + SolidBody myocardium_muscle_body(sph_system, makeShared>( + Transform(translation_myocardium), halfsize_myocardium, "MyocardiumMuscleBody")); myocardium_muscle_body.defineParticlesAndMaterial< ElasticSolidParticles, ActiveMuscle>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); myocardium_muscle_body.generateParticles(); @@ -86,15 +87,15 @@ int main() // Define the methods for I/O operations, observations // and regression tests of the simulation. //---------------------------------------------------------------------- - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); //---------------------------------------------------------------------- // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- GlobalStaticVariables::physical_time_ = 0.0; - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); corrected_configuration.exec(); //---------------------------------------------------------------------- // Setup for time-stepping control @@ -148,5 +149,6 @@ int main() tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_muscle_soft_body_contact/src/CMakeLists.txt b/tests/3d_examples/test_3d_muscle_soft_body_contact/src/CMakeLists.txt index 4b833f94a3..a061618f56 100644 --- a/tests/3d_examples/test_3d_muscle_soft_body_contact/src/CMakeLists.txt +++ b/tests/3d_examples/test_3d_muscle_soft_body_contact/src/CMakeLists.txt @@ -9,7 +9,7 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "muscle") diff --git a/tests/3d_examples/test_3d_muscle_soft_body_contact/src/muscle_soft_body_contact.cpp b/tests/3d_examples/test_3d_muscle_soft_body_contact/src/muscle_soft_body_contact.cpp index 22a13e6626..9c79e0c126 100644 --- a/tests/3d_examples/test_3d_muscle_soft_body_contact/src/muscle_soft_body_contact.cpp +++ b/tests/3d_examples/test_3d_muscle_soft_body_contact/src/muscle_soft_body_contact.cpp @@ -51,16 +51,17 @@ class MovingPlate : public ComplexShape /** * The main program */ -int main() +int main(int ac, char *av[]) { /** Setup the system. Please the make sure the global domain bounds are correctly defined. */ - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); /** Creat a Myocardium body, corresponding material, particles and reaction model. */ - SolidBody myocardium_body(system, makeShared("MyocardiumBody")); + SolidBody myocardium_body(sph_system, makeShared("MyocardiumBody")); myocardium_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); myocardium_body.generateParticles(); /** Plate. */ - SolidBody moving_plate(system, makeShared("MovingPlate")); + SolidBody moving_plate(sph_system, makeShared("MovingPlate")); moving_plate.defineAdaptationRatios(1.15, 1.5); moving_plate.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); moving_plate.generateParticles(); @@ -103,16 +104,16 @@ int main() DampingWithRandomChoice>> plate_damping(0.2, moving_plate_inner, "Velocity", physical_viscosity); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); /** * From here the time stepping begins. * Set the starting time. */ GlobalStaticVariables::physical_time_ = 0.0; - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); /** apply initial condition */ corrected_configuration.exec(); corrected_configuration_2.exec(); @@ -164,7 +165,7 @@ int main() stress_relaxation_second_half_2.exec(dt); ite++; - dt = system.getSmallestTimeStepAmongSolidBodies(); + dt = sph_system.getSmallestTimeStepAmongSolidBodies(); integration_time += dt; GlobalStaticVariables::physical_time_ += dt; @@ -185,5 +186,6 @@ int main() tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_muscle_solid_contact/src/CMakeLists.txt b/tests/3d_examples/test_3d_muscle_solid_contact/src/CMakeLists.txt index 02c222b86e..a69ef31479 100644 --- a/tests/3d_examples/test_3d_muscle_solid_contact/src/CMakeLists.txt +++ b/tests/3d_examples/test_3d_muscle_solid_contact/src/CMakeLists.txt @@ -10,7 +10,7 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "muscle, Simbody") diff --git a/tests/3d_examples/test_3d_muscle_solid_contact/src/muscle_solid_contact.cpp b/tests/3d_examples/test_3d_muscle_solid_contact/src/muscle_solid_contact.cpp index 430780cb3f..aa4b89cf04 100644 --- a/tests/3d_examples/test_3d_muscle_solid_contact/src/muscle_solid_contact.cpp +++ b/tests/3d_examples/test_3d_muscle_solid_contact/src/muscle_solid_contact.cpp @@ -53,16 +53,17 @@ class MovingPlate : public ComplexShape /** * The main program */ -int main() +int main(int ac, char *av[]) { /** Setup the system. Please the make sure the global domain bounds are correctly defined. */ - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); /** Creat a Myocardium body, corresponding material, particles and reaction model. */ - SolidBody myocardium_body(system, makeShared("MyocardiumBody")); + SolidBody myocardium_body(sph_system, makeShared("MyocardiumBody")); myocardium_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); myocardium_body.generateParticles(); /** Plate. */ - SolidBody moving_plate(system, makeShared("MovingPlate")); + SolidBody moving_plate(sph_system, makeShared("MovingPlate")); moving_plate.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); moving_plate.generateParticles(); /** topology */ @@ -95,8 +96,8 @@ int main() DampingWithRandomChoice>> muscle_damping(0.1, myocardium_body_inner, "Velocity", physical_viscosity); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); /** Simbody interface. */ /** * The multi body system from simbody. @@ -138,8 +139,8 @@ int main() * Set the starting time. */ GlobalStaticVariables::physical_time_ = 0.0; - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); /** apply initial condition */ corrected_configuration.exec(); write_states.writeToFile(0); @@ -210,5 +211,6 @@ int main() tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_network/CMakeLists.txt b/tests/3d_examples/test_3d_network/CMakeLists.txt index d390d1436a..25643e5a3b 100644 --- a/tests/3d_examples/test_3d_network/CMakeLists.txt +++ b/tests/3d_examples/test_3d_network/CMakeLists.txt @@ -12,6 +12,6 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/3d_examples/test_3d_network/network.cpp b/tests/3d_examples/test_3d_network/network.cpp index c799df8a37..3f2c2735e3 100644 --- a/tests/3d_examples/test_3d_network/network.cpp +++ b/tests/3d_examples/test_3d_network/network.cpp @@ -42,19 +42,21 @@ int iteration_levels = 15; /** Network defecting angle. */ Real grad_factor = 5.0; -int main() +int main(int ac, char *av[]) { /** Setup the system. */ - SPHSystem system(system_domain_bounds, dp_0); - /** Output */ - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, dp_0); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); /** Creat a body, corresponding material and particles. */ - TreeBody tree_on_sphere(system, makeShared(Vec3d::Zero(), 1.0, "Sphere")); + TreeBody tree_on_sphere(sph_system, makeShared(Vec3d::Zero(), 1.0, "Sphere")); tree_on_sphere.defineBodyLevelSetShape()->writeLevelSet(io_environment); tree_on_sphere.defineParticlesAndMaterial(); tree_on_sphere.generateParticles(starting_point, second_point, iteration_levels, grad_factor); /** Write particle data. */ - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); write_states.writeToFile(0); + + return 0; } \ No newline at end of file diff --git a/tests/3d_examples/test_3d_nonlinear_wave_fsi/CMakeLists.txt b/tests/3d_examples/test_3d_nonlinear_wave_fsi/CMakeLists.txt index 80c21f20e9..d3b60d11ca 100644 --- a/tests/3d_examples/test_3d_nonlinear_wave_fsi/CMakeLists.txt +++ b/tests/3d_examples/test_3d_nonlinear_wave_fsi/CMakeLists.txt @@ -19,8 +19,8 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} extra_sources_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "fluid dynamics, Simbody") \ No newline at end of file diff --git a/tests/3d_examples/test_3d_nonlinear_wave_fsi/io_simbody_free.h b/tests/3d_examples/test_3d_nonlinear_wave_fsi/io_simbody_free.h index b68ad4947d..8dfa4131c9 100644 --- a/tests/3d_examples/test_3d_nonlinear_wave_fsi/io_simbody_free.h +++ b/tests/3d_examples/test_3d_nonlinear_wave_fsi/io_simbody_free.h @@ -10,133 +10,133 @@ namespace SPH { - /** - * @class WriteSimBodyFreeRotationMatrix - * @brief Write displacement and rotation of planar solid body. - */ - class WriteSimBodyFreeRotationMatrix : public WriteSimBodyStates - { - protected: - std::string filefullpath_; +/** + * @class WriteSimBodyFreeRotationMatrix + * @brief Write displacement and rotation of planar solid body. + */ +class WriteSimBodyFreeRotationMatrix : public WriteSimBodyStates +{ + protected: + std::string filefullpath_; - public: - WriteSimBodyFreeRotationMatrix(IOEnvironment &io_environment, SimTK::RungeKuttaMersonIntegrator &integ, SimTK::MobilizedBody::Free &freebody); - virtual ~WriteSimBodyFreeRotationMatrix(){}; - virtual void writeToFile(size_t iteration_step = 0) override; - }; - //=============================================================================================// - WriteSimBodyFreeRotationMatrix:: - WriteSimBodyFreeRotationMatrix(IOEnvironment &io_environment, SimTK::RungeKuttaMersonIntegrator &integ, SimTK::MobilizedBody::Free &freebody) - : WriteSimBodyStates(io_environment, integ, freebody), - filefullpath_(io_environment_.output_folder_ + "/RotationMatrix.dat") - { - std::ofstream out_file(filefullpath_.c_str(), std::ios::app); + public: + WriteSimBodyFreeRotationMatrix(IOEnvironment &io_environment, SimTK::RungeKuttaMersonIntegrator &integ, SimTK::MobilizedBody::Free &free_body); + virtual ~WriteSimBodyFreeRotationMatrix(){}; + virtual void writeToFile(size_t iteration_step = 0) override; +}; +//=============================================================================================// +WriteSimBodyFreeRotationMatrix:: + WriteSimBodyFreeRotationMatrix(IOEnvironment &io_environment, SimTK::RungeKuttaMersonIntegrator &integ, SimTK::MobilizedBody::Free &free_body) + : WriteSimBodyStates(io_environment, integ, free_body), + filefullpath_(io_environment_.output_folder_ + "/RotationMatrix.dat") +{ + std::ofstream out_file(filefullpath_.c_str(), std::ios::app); - out_file << "\"time\"" - << " "; - out_file << " " - << "rotation [1,1]" - << " "; - out_file << " " - << "rotation [1,2]" - << " "; - out_file << " " - << "rotation [1,3]" - << " "; - out_file << " " - << "rotation [2,1]" - << " "; - out_file << " " - << "rotation [2,2]" - << " "; - out_file << " " - << "rotation [2,3]" - << " "; - out_file << " " - << "rotation [3,1]" - << " "; - out_file << " " - << "rotation [3,2]" - << " "; - out_file << " " - << "rotation [3,3]" - << " "; - out_file << "\n"; + out_file << "\"time\"" + << " "; + out_file << " " + << "rotation [1,1]" + << " "; + out_file << " " + << "rotation [1,2]" + << " "; + out_file << " " + << "rotation [1,3]" + << " "; + out_file << " " + << "rotation [2,1]" + << " "; + out_file << " " + << "rotation [2,2]" + << " "; + out_file << " " + << "rotation [2,3]" + << " "; + out_file << " " + << "rotation [3,1]" + << " "; + out_file << " " + << "rotation [3,2]" + << " "; + out_file << " " + << "rotation [3,3]" + << " "; + out_file << "\n"; - out_file.close(); - }; - //=============================================================================================// - void WriteSimBodyFreeRotationMatrix::writeToFile(size_t iteration_step) - { - std::ofstream out_file(filefullpath_.c_str(), std::ios::app); - out_file << GlobalStaticVariables::physical_time_ << " "; - const SimTK::State &state = integ_.getState(); + out_file.close(); +}; +//=============================================================================================// +void WriteSimBodyFreeRotationMatrix::writeToFile(size_t iteration_step) +{ + std::ofstream out_file(filefullpath_.c_str(), std::ios::app); + out_file << GlobalStaticVariables::physical_time_ << " "; + const SimTK::State &state = integ_.getState(); - out_file << " " << mobody_.getBodyRotation(state)[0][0] << " "; - out_file << " " << mobody_.getBodyRotation(state)[0][1] << " "; - out_file << " " << mobody_.getBodyRotation(state)[0][2] << " "; - out_file << " " << mobody_.getBodyRotation(state)[1][0] << " "; - out_file << " " << mobody_.getBodyRotation(state)[1][1] << " "; - out_file << " " << mobody_.getBodyRotation(state)[1][2] << " "; - out_file << " " << mobody_.getBodyRotation(state)[2][0] << " "; - out_file << " " << mobody_.getBodyRotation(state)[2][1] << " "; - out_file << " " << mobody_.getBodyRotation(state)[2][2] << " "; + out_file << " " << mobody_.getBodyRotation(state)[0][0] << " "; + out_file << " " << mobody_.getBodyRotation(state)[0][1] << " "; + out_file << " " << mobody_.getBodyRotation(state)[0][2] << " "; + out_file << " " << mobody_.getBodyRotation(state)[1][0] << " "; + out_file << " " << mobody_.getBodyRotation(state)[1][1] << " "; + out_file << " " << mobody_.getBodyRotation(state)[1][2] << " "; + out_file << " " << mobody_.getBodyRotation(state)[2][0] << " "; + out_file << " " << mobody_.getBodyRotation(state)[2][1] << " "; + out_file << " " << mobody_.getBodyRotation(state)[2][2] << " "; - out_file << "\n"; - out_file.close(); - }; - //=================================================================================================// + out_file << "\n"; + out_file.close(); +}; +//=================================================================================================// /** - * @class WriteSimBodyVelocity - * @brief Write displacement and rotation of planar solid body. - */ - class WriteSimBodyVelocity : public WriteSimBodyStates - { - protected: - std::string filefullpath_; + * @class WriteSimBodyVelocity + * @brief Write displacement and rotation of planar solid body. + */ +class WriteSimBodyVelocity : public WriteSimBodyStates +{ + protected: + std::string filefullpath_; - public: - WriteSimBodyVelocity(IOEnvironment &io_environment, SimTK::RungeKuttaMersonIntegrator &integ, SimTK::MobilizedBody::Free &freebody); - virtual ~WriteSimBodyVelocity(){}; - virtual void writeToFile(size_t iteration_step = 0) override; - }; - //=============================================================================================// - WriteSimBodyVelocity:: - WriteSimBodyVelocity(IOEnvironment &io_environment, SimTK::RungeKuttaMersonIntegrator &integ, SimTK::MobilizedBody::Free &freebody) - : WriteSimBodyStates(io_environment, integ, freebody), - filefullpath_(io_environment_.output_folder_ + "/BodyVelocity.dat") - { - std::ofstream out_file(filefullpath_.c_str(), std::ios::app); + public: + WriteSimBodyVelocity(IOEnvironment &io_environment, SimTK::RungeKuttaMersonIntegrator &integ, SimTK::MobilizedBody::Free &free_body); + virtual ~WriteSimBodyVelocity(){}; + virtual void writeToFile(size_t iteration_step = 0) override; +}; +//=============================================================================================// +WriteSimBodyVelocity:: + WriteSimBodyVelocity(IOEnvironment &io_environment, SimTK::RungeKuttaMersonIntegrator &integ, SimTK::MobilizedBody::Free &free_body) + : WriteSimBodyStates(io_environment, integ, free_body), + filefullpath_(io_environment_.output_folder_ + "/BodyVelocity.dat") +{ + std::ofstream out_file(filefullpath_.c_str(), std::ios::app); - out_file << "\"time\"" - << " "; - out_file << " " - << "velocity [0]" - << " "; - out_file << " " - << "velocity [1]" - << " "; - out_file << " " - << "velocity [2]" - << " "; - out_file << " "; - out_file << "\n"; + out_file << "\"time\"" + << " "; + out_file << " " + << "velocity [0]" + << " "; + out_file << " " + << "velocity [1]" + << " "; + out_file << " " + << "velocity [2]" + << " "; + out_file << " "; + out_file << "\n"; - out_file.close(); - }; - //=============================================================================================// - void WriteSimBodyVelocity::writeToFile(size_t iteration_step) - { - std::ofstream out_file(filefullpath_.c_str(), std::ios::app); - out_file << GlobalStaticVariables::physical_time_ << " "; - const SimTK::State &state = integ_.getState(); + out_file.close(); +}; +//=============================================================================================// +void WriteSimBodyVelocity::writeToFile(size_t iteration_step) +{ + std::ofstream out_file(filefullpath_.c_str(), std::ios::app); + out_file << GlobalStaticVariables::physical_time_ << " "; + const SimTK::State &state = integ_.getState(); - out_file << " " << mobody_.getBodyOriginVelocity(state)[0] << " "; - out_file << " " << mobody_.getBodyOriginVelocity(state)[1] << " "; - out_file << " " << mobody_.getBodyOriginVelocity(state)[2] << " "; + out_file << " " << mobody_.getBodyOriginVelocity(state)[0] << " "; + out_file << " " << mobody_.getBodyOriginVelocity(state)[1] << " "; + out_file << " " << mobody_.getBodyOriginVelocity(state)[2] << " "; - out_file << "\n"; - out_file.close(); - }; - //=================================================================================================// -} + out_file << "\n"; + out_file.close(); +}; +//=================================================================================================// +} // namespace SPH diff --git a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp index 2184dc37fe..8a645dabd7 100644 --- a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp +++ b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.cpp @@ -70,33 +70,33 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the Main environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); water_block.addBodyStateForRecording("Position"); water_block.addBodyStateForRecording("Pressure"); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); - SolidBody structure(system, makeShared("Structure")); + SolidBody structure(sph_system, makeShared("Structure")); structure.defineParticlesAndMaterial(StructureDensity); structure.generateParticles(io_environment, "Structure_Fit"); - ObserverBody observer(system, "Observer"); + ObserverBody observer(sph_system, "Observer"); observer.defineAdaptationRatios(h, 2.0); observer.generateParticles( StdVec{obs}); - ObserverBody WMobserver(system, "WMObserver"); + ObserverBody WMobserver(sph_system, "WMObserver"); WMobserver.defineAdaptationRatios(h, 2.0); Vecd WMpos0 = Vecd(0.0, -Maker_width / 2, HWM / 2); WMobserver.generateParticles( @@ -105,15 +105,15 @@ int main(int ac, char *av[]) //--------------------------------------------------------- // PRESSURE PROBES //--------------------------------------------------------- - - ObserverBody fp1(system, "FP1"); + + ObserverBody fp1(sph_system, "FP1"); Real fp1x = Strx - 0.12; Real fp1y = Stry; Real fp1z = 1.013; StdVec fp1l = {Vecd(fp1x, fp1y, fp1z)}; fp1.generateParticles(fp1l); - - ObserverBody bp1(system, "BP1"); + + ObserverBody bp1(sph_system, "BP1"); Real bp1x = Strx - 0.295; Real bp1y = Stry + .035; Real bp1z = 0.933; @@ -134,7 +134,6 @@ int main(int ac, char *av[]) ContactRelation WMobserver_contact_with_water(WMobserver, {&water_block}); ContactRelation WMobserver_contact_with_wall(WMobserver, {&wall_boundary}); - ContactRelation fp1_contact_s(fp1, {&structure}); ContactRelation bp1_contact_s(bp1, {&structure}); @@ -165,7 +164,7 @@ int main(int ac, char *av[]) /** Computing viscous acceleration. */ InteractionDynamics viscous_acceleration(water_block_complex); /** Damp waves */ - Vecd translation_damping(0.5 * DW, 9.5 , 0.5 * HWM); + Vecd translation_damping(0.5 * DW, 9.5, 0.5 * HWM); Vecd damping(0.5 * DW, 0.5, 0.5 * HWM); BodyRegionByCell damping_buffer(water_block, makeShared>(Transform(translation_damping), damping)); SimpleDynamics damping_wave(damping_buffer); @@ -211,7 +210,7 @@ int main(int ac, char *av[]) SimTK::MobilizedBody::Weld fixed_spotBL(matter.Ground(), SimTK::Transform(SimTK::Vec3(ground_tethering_BL[0], ground_tethering_BL[1], ground_tethering_BL[2])), fixed_spot_info, SimTK::Transform(SimTK::Vec3(0.0, 0.0, 0.0))); /*---------------------------------------------------------------------------*/ - // A SEASIDE PILLARS; B PORTSIDE PILLARS + // A SEASIDE PILLARS; B PORT_SIDE PILLARS /*-----------------------------------------------------------------------------*/ Vecd disp_cable_endAR = structure_tethering_AR - structure_multibody.initial_mass_center_; SimTK::CablePath tethering_lineAR(cables, fixed_spotAR, SimTK::Vec3(0.0, 0.0, 0.0), tethered_struct, SimTK::Vec3(disp_cable_endAR[0], disp_cable_endAR[1], disp_cable_endAR[2])); @@ -265,7 +264,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); /** WaveProbes. */ BodyRegionByCell wave_probe_buffer(water_block, makeShared>(Transform(translation_WGauge), WGaugeDim)); ReducedQuantityRecording> wave_gauge(io_environment, wave_probe_buffer); @@ -281,18 +280,17 @@ int main(int ac, char *av[]) ObservedQuantityRecording write_WM_displacement("Position", io_environment, WMobserver_contact_with_wall); - InteractionDynamics> interpolation_fp1_position(fp1_contact_s, "Position", "Position"); InteractionDynamics> interpolation_bp1_position(bp1_contact_s, "Position", "Position"); - + RegressionTestDynamicTimeWarping> write_recorded_pressure_fp1("Pressure", io_environment, fp1_contact_w); ObservedQuantityRecording write_recorded_pressure_bp1("Pressure", io_environment, bp1_contact_w); - - RestartIO restart_io(io_environment, system.real_bodies_); + + RestartIO restart_io(io_environment, sph_system.real_bodies_); //---------------------------------------------------------------------- // Basic control parameters for time stepping. @@ -315,8 +313,8 @@ int main(int ac, char *av[]) // and case specified initial condition if necessary. //---------------------------------------------------------------------- structure_offset_position.exec(); - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); structure_normal_direction.exec(); structure_corrected_configuration.exec(); @@ -324,9 +322,9 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Load restart file if necessary. //---------------------------------------------------------------------- - if (system.RestartStep() != 0) + if (sph_system.RestartStep() != 0) { - GlobalStaticVariables::physical_time_ = restart_io.readRestartFiles(system.RestartStep()); + GlobalStaticVariables::physical_time_ = restart_io.readRestartFiles(sph_system.RestartStep()); water_block.updateCellLinkedListWithParticleSort(100); wall_boundary.updateCellLinkedList(); structure.updateCellLinkedList(); @@ -457,16 +455,17 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_str_displacement.generateDataBase(1.0e-3); write_recorded_pressure_fp1.generateDataBase(1.0e-3); } - else if (system.RestartStep() == 0) + else if (sph_system.RestartStep() == 0) { write_str_displacement.testResult(); write_recorded_pressure_fp1.testResult(); } + return 0; } diff --git a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.h b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.h index d43f2fa6f3..4d3c9e036c 100644 --- a/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.h +++ b/tests/3d_examples/test_3d_nonlinear_wave_fsi/nonlinear_wave_fsi.h @@ -10,20 +10,20 @@ using namespace SPH; // Basic geometry parameters and numerical setup. //---------------------------------------------------------------------- Real total_physical_time = 6.0; /**< TOTAL SIMULATION TIME*/ -Real DL = 10.0; /**< Tank length. */ -Real DH = 1.0; /**< Tank height. */ -Real DW = 1.6; /**< Tank width. */ -Real WH = 0.8; /**< Water block height. */ -Real BEH = 2.0; /**< Flume height. */ -Real Wmk_p = 0.0; /**< Wavemaker initial position. */ -Real EXS = 2.0; /**< Extra space behind the wavemaker*/ -Real HWM = 1.0; /**< Wameker height*/ -Real d = 0.8; /**< Still water level*/ +Real DL = 10.0; /**< Tank length. */ +Real DH = 1.0; /**< Tank height. */ +Real DW = 1.6; /**< Tank width. */ +Real WH = 0.8; /**< Water block height. */ +Real BEH = 2.0; /**< Flume height. */ +Real Wmk_p = 0.0; /**< Wave_maker initial position. */ +Real EXS = 2.0; /**< Extra space behind the wave_maker*/ +Real HWM = 1.0; /**< Wave_maker height*/ +Real d = 0.8; /**< Still water level*/ Real dDx = 10; Real particle_spacing_ref = d / dDx; /**< Main water particle spacing. */ Real particle_spacing_structure = 0.1; /**< Structure particle spacing. */ Real BW = particle_spacing_ref * 4.0; /**< Extending width for BCs. */ -Real Maker_width = particle_spacing_ref * 4.0; /**< Width of the wavemaker. */ +Real Maker_width = particle_spacing_ref * 4.0; /**< Width of the wave_maker. */ BoundingBox system_domain_bounds(Vecd(-BW, -EXS - BW, -BW), Vecd(EXS + BW, DL + BW, DH + BW)); @@ -79,7 +79,7 @@ Real Tad = Tw * Th; Real Taw = Td * Th; Real TVol = Tw * Td * Th; -// STIFFNER +// STIFFENER Real Sw = 0.43; Real Sd = 0.08; Real Sh = 0.04; @@ -112,7 +112,7 @@ Real PIz = (StructureDensity * PVol) / 12 * (Pd * Pd + Pw * Pw); Real TIx = (StructureDensity * TVol) / 12 * (Td * Td + Th * Th); Real TIy = (StructureDensity * TVol) / 12 * (Tw * Tw + Th * Th); Real TIz = (StructureDensity * TVol) / 12 * (Td * Td + Tw * Tw); -// STIFFNER +// STIFFENER Real SIx = (StructureDensity * SVol) / 12 * (Sd * Sd + Sh * Sh); Real SIy = (StructureDensity * SVol) / 12 * (Sw * Sw + Sh * Sh); Real SIz = (StructureDensity * SVol) / 12 * (Sd * Sd + Sw * Sw); @@ -129,17 +129,17 @@ Vec3d LLcm(Strx - dx - Lw / 2, Stry + Ld / 2, Strz + Lh / 2); /* Left Leg */ /* Pillars */ Real yPsP = 0.25; Real ySsP = 0.85; -Vec3d RPsPcm(Strx + dx + Pw / 2, Stry + yPsP + Pd / 2, Strz + Lh + Ph / 2); /* Right Portside Pillar */ -Vec3d LPsPcm(Strx - dx - Pw / 2, Stry + yPsP + Pd / 2, Strz + Lh + Ph / 2); /* Left Portside Pillar */ +Vec3d RPsPcm(Strx + dx + Pw / 2, Stry + yPsP + Pd / 2, Strz + Lh + Ph / 2); /* Right Port side Pillar */ +Vec3d LPsPcm(Strx - dx - Pw / 2, Stry + yPsP + Pd / 2, Strz + Lh + Ph / 2); /* Left Port side Pillar */ Vec3d RSsPcm(Strx + dx + Pw / 2, Stry + ySsP + Pd / 2, Strz + Lh + Ph / 2); /* Right Seaside Pillar */ Vec3d LSsPcm(Strx - dx - Pw / 2, Stry + ySsP + Pd / 2, Strz + Lh + Ph / 2); /* Left Seaside Pillar */ -/* Stiffners */ +/* StiffEners */ Real zS = 0.14; Real ySsS = 0.31; Real yPsS = 0.91; -Vec3d PsScm(Strx, Stry + yPsS + Sd / 2, Strz + zS + Sh / 2); /* Portside Stiffner */ -Vec3d SsScm(Strx, Stry + ySsS + Sd / 2, Strz + zS + Sh / 2); /* Seaside Stiffner */ +Vec3d PsScm(Strx, Stry + yPsS + Sd / 2, Strz + zS + Sh / 2); /* Port side StiffEner */ +Vec3d SsScm(Strx, Stry + ySsS + Sd / 2, Strz + zS + Sh / 2); /* Seaside StiffEner */ /* Top Plate */ Real yT = 0.18; @@ -240,14 +240,14 @@ Vecd structure_tethering_AR(G[0] + 0.31, G[1] - 0.3, Strz); // Left seaside cable topology Vecd ground_tethering_AL(G[0] - 0.31, G[1] - 0.3, 0.0); Vecd structure_tethering_AL(G[0] - 0.31, G[1] - 0.3, Strz); -// Right portside cable topology +// Right port side cable topology Vecd ground_tethering_BR(G[0] + 0.31, G[1] + 0.3, 0.0); Vecd structure_tethering_BR(G[0] + 0.31, G[1] + 0.3, Strz); -// Left portside cable topology +// Left port side cable topology Vecd ground_tethering_BL(G[0] - 0.31, G[1] + 0.3, 0.0); Vecd structure_tethering_BL(G[0] - 0.31, G[1] + 0.3, Strz); -Real cablength = Strz; +Real cable_length = Strz; /** * Structure observer position @@ -304,7 +304,7 @@ class WaterBlock : public ComplexShape }; //---------------------------------------------------------------------- -// create a wavemaker shape +// create a wave_maker shape //---------------------------------------------------------------------- Vecd wave_maker_shape(0.5 * DW, 0.5 * Maker_width, 0.5 * DH); Vecd wmk_pos(0.5 * DW, -0.5 * Maker_width, 0.5 * HWM); @@ -333,7 +333,7 @@ class WallBoundary : public ComplexShape }; //---------------------------------------------------------------------- -// Boundary condition for wavemaker +// Boundary condition for wave_maker //---------------------------------------------------------------------- class WaveMaking : public solid_dynamics::BaseMotionConstraint { @@ -470,7 +470,7 @@ class WaveMaking : public solid_dynamics::BaseMotionConstraint("SolidBodyFromMesh")); + RealBody imported_model(sph_system, makeShared("SolidBodyFromMesh")); imported_model.defineAdaptation(1.15, 1.0, 3); imported_model.defineBodyLevelSetShape()->correctLevelSetSign()->writeLevelSet(io_environment); imported_model.defineParticlesAndMaterial(); @@ -96,5 +97,6 @@ int main() } std::cout << "The physics relaxation process of imported model finish !" << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_particle_relaxation_single_resolution/CMakeLists.txt b/tests/3d_examples/test_3d_particle_relaxation_single_resolution/CMakeLists.txt index 45cf192433..ab31e741f3 100644 --- a/tests/3d_examples/test_3d_particle_relaxation_single_resolution/CMakeLists.txt +++ b/tests/3d_examples/test_3d_particle_relaxation_single_resolution/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) @@ -17,6 +17,6 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "particle relaxation") + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "particle relaxation") diff --git a/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp b/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp index 4fb217f7c6..e26e2029a3 100644 --- a/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp +++ b/tests/3d_examples/test_3d_particle_relaxation_single_resolution/particle_relaxation_single_resolution_3D.cpp @@ -55,17 +55,18 @@ class SolidBodyFromMesh : public ComplexShape //----------------------------------------------------------------------------------------------------------- // Main program starts here. //----------------------------------------------------------------------------------------------------------- -int main() +int main(int ac, char *av[]) { //---------------------------------------------------------------------- // Build up -- a SPHSystem //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, dp_0); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, dp_0); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody imported_model(system, makeShared("SolidBodyFromMesh")); + RealBody imported_model(sph_system, makeShared("SolidBodyFromMesh")); // level set shape is used for particle relaxation imported_model.defineBodyLevelSetShape()->correctLevelSetSign()->writeLevelSet(io_environment); imported_model.defineParticlesAndMaterial(); @@ -111,5 +112,6 @@ int main() } std::cout << "The physics relaxation process of imported model finish !" << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_passive_cantilever/CMakeLists.txt b/tests/3d_examples/test_3d_passive_cantilever/CMakeLists.txt index 4e26998d6e..349eff1c3a 100644 --- a/tests/3d_examples/test_3d_passive_cantilever/CMakeLists.txt +++ b/tests/3d_examples/test_3d_passive_cantilever/CMakeLists.txt @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/3d_examples/test_3d_passive_cantilever/passive_cantilever.cpp b/tests/3d_examples/test_3d_passive_cantilever/passive_cantilever.cpp index 14d9f5f258..94ac716e12 100644 --- a/tests/3d_examples/test_3d_passive_cantilever/passive_cantilever.cpp +++ b/tests/3d_examples/test_3d_passive_cantilever/passive_cantilever.cpp @@ -67,17 +67,18 @@ class CantileverInitialCondition /** * The main program */ -int main() +int main(int ac, char *av[]) { /** Setup the system. Please the make sure the global domain bounds are correctly defined. */ - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); /** create a Cantilever body, corresponding material, particles and reaction model. */ - SolidBody cantilever_body(system, makeShared("CantileverBody")); + SolidBody cantilever_body(sph_system, makeShared("CantileverBody")); cantilever_body.defineParticlesAndMaterial< ElasticSolidParticles, Muscle>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); cantilever_body.generateParticles(); /** Define Observer. */ - ObserverBody cantilever_observer(system, "CantileverObserver"); + ObserverBody cantilever_observer(sph_system, "CantileverObserver"); cantilever_observer.generateParticles(observation_location); /** topology */ @@ -102,8 +103,8 @@ int main() makeShared>(Transform(translation_holder), halfsize_holder, "Holder")); SimpleDynamics constraint_holder(holder); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_displacement("Position", io_environment, cantilever_observer_contact); /** @@ -111,8 +112,8 @@ int main() * Set the starting time. */ GlobalStaticVariables::physical_time_ = 0.0; - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); /** apply initial condition */ initialization.exec(); corrected_configuration.exec(); @@ -163,5 +164,6 @@ int main() write_displacement.testResult(); + return 0; } diff --git a/tests/3d_examples/test_3d_passive_cantilever_neohookean/CMakeLists.txt b/tests/3d_examples/test_3d_passive_cantilever_neohookean/CMakeLists.txt index 4e26998d6e..349eff1c3a 100644 --- a/tests/3d_examples/test_3d_passive_cantilever_neohookean/CMakeLists.txt +++ b/tests/3d_examples/test_3d_passive_cantilever_neohookean/CMakeLists.txt @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/3d_examples/test_3d_passive_cantilever_neohookean/passive_cantilever_neohookean.cpp b/tests/3d_examples/test_3d_passive_cantilever_neohookean/passive_cantilever_neohookean.cpp index a9a6be8293..d7703fbbbe 100644 --- a/tests/3d_examples/test_3d_passive_cantilever_neohookean/passive_cantilever_neohookean.cpp +++ b/tests/3d_examples/test_3d_passive_cantilever_neohookean/passive_cantilever_neohookean.cpp @@ -60,18 +60,18 @@ class TimeDependentGravity : public Gravity int main(int ac, char *av[]) { /** Setup the system. */ - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); // handle command line arguments #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif /** output environment. */ /** create a Cantilever body, corresponding material, particles and reaction model. */ - SolidBody cantilever_body(system, makeShared("CantileverBody")); + SolidBody cantilever_body(sph_system, makeShared("CantileverBody")); cantilever_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); cantilever_body.generateParticles(); /** Define Observer. */ - ObserverBody cantilever_observer(system, "CantileverObserver"); + ObserverBody cantilever_observer(sph_system, "CantileverObserver"); cantilever_observer.generateParticles(observation_location); /** topology */ @@ -105,8 +105,8 @@ int main(int ac, char *av[]) DampingWithRandomChoice>> muscle_damping(0.1, cantilever_body_inner, "Velocity", physical_viscosity); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_displacement("Position", io_environment, cantilever_observer_contact); /** @@ -114,8 +114,8 @@ int main(int ac, char *av[]) * Set the starting time. */ GlobalStaticVariables::physical_time_ = 0.0; - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); corrected_configuration.exec(); write_states.writeToFile(0); write_displacement.writeToFile(0); @@ -166,7 +166,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_displacement.generateDataBase(1.0e-2); } @@ -175,5 +175,6 @@ int main(int ac, char *av[]) write_displacement.testResult(); } + return 0; } diff --git a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/CMakeLists.txt b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/CMakeLists.txt index f941e4f7e2..9a442369ce 100644 --- a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/CMakeLists.txt +++ b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/CMakeLists.txt @@ -16,17 +16,10 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") diff --git a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.cpp b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.cpp index f2f7a07798..c9f149a3d9 100644 --- a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.cpp +++ b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/pkj_lv_electrocontraction.cpp @@ -27,18 +27,18 @@ int main(int ac, char *av[]) /** * Build up context -- a SPHSystem. */ - SPHSystem system(system_domain_bounds, dp_0); + SPHSystem sph_system(system_domain_bounds, dp_0); /** Set the starting time. */ GlobalStaticVariables::physical_time_ = 0.0; /** Tag for run particle relaxation for the initial body fitted distribution. */ - system.setRunParticleRelaxation(false); + sph_system.setRunParticleRelaxation(false); /** Tag for reload initially relaxed particles. */ - system.setReloadParticles(true); + sph_system.setReloadParticles(true); // handle command line arguments #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Define the same level geometric shape for all bodies //---------------------------------------------------------------------- @@ -50,9 +50,9 @@ int main(int ac, char *av[]) // SPH Particle relaxation section //---------------------------------------------------------------------- /** check whether run particle relaxation for body fitted particle distribution. */ - if (system.RunParticleRelaxation()) + if (sph_system.RunParticleRelaxation()) { - SolidBody herat_model(system, level_set_heart_model); + SolidBody herat_model(sph_system, level_set_heart_model); herat_model.defineParticlesAndMaterial(); herat_model.generateParticles(); /** topology */ @@ -125,25 +125,25 @@ int main(int ac, char *av[]) // SPH simulation section //---------------------------------------------------------------------- /** create a SPH body, material and particles */ - SolidBody physiology_heart(system, level_set_heart_model, "PhysiologyHeart"); + SolidBody physiology_heart(sph_system, level_set_heart_model, "PhysiologyHeart"); SharedPtr muscle_reaction_model_ptr = makeShared(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); physiology_heart.defineParticlesAndMaterial< ElectroPhysiologyParticles, MonoFieldElectroPhysiology>( muscle_reaction_model_ptr, TypeIdentity(), diffusion_coeff, bias_coeff, fiber_direction); - (!system.RunParticleRelaxation() && system.ReloadParticles()) + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? physiology_heart.generateParticles(io_environment, "HeartModel") : physiology_heart.generateParticles(); /** create a SPH body, material and particles */ - SolidBody mechanics_heart(system, level_set_heart_model, "MechanicalHeart"); + SolidBody mechanics_heart(sph_system, level_set_heart_model, "MechanicalHeart"); mechanics_heart.defineParticlesAndMaterial< ElasticSolidParticles, ActiveMuscle>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); - (!system.RunParticleRelaxation() && system.ReloadParticles()) + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? mechanics_heart.generateParticles(io_environment, "HeartModel") : mechanics_heart.generateParticles(); /** Creat a Purkinje network for fast diffusion, material and particles */ - TreeBody pkj_body(system, level_set_heart_model, "Purkinje"); + TreeBody pkj_body(sph_system, level_set_heart_model, "Purkinje"); SharedPtr pkj_reaction_model_ptr = makeShared(k_a, c_m, k, a, b, mu_1, mu_2, epsilon); pkj_body.defineParticlesAndMaterial< ElectroPhysiologyReducedParticles, MonoFieldElectroPhysiology>( @@ -153,9 +153,9 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // SPH Observation section //---------------------------------------------------------------------- - ObserverBody voltage_observer(system, "VoltageObserver"); + ObserverBody voltage_observer(sph_system, "VoltageObserver"); voltage_observer.generateParticles(); - ObserverBody myocardium_observer(system, "MyocardiumObserver"); + ObserverBody myocardium_observer(sph_system, "MyocardiumObserver"); myocardium_observer.generateParticles(); /** topology */ @@ -186,7 +186,7 @@ int main(int ac, char *av[]) electro_physiology::ElectroPhysiologyReactionRelaxationForward pkj_reaction_relaxation_forward(pkj_body); electro_physiology::ElectroPhysiologyReactionRelaxationBackward pkj_reaction_relaxation_backward(pkj_body); /**IO for observer.*/ - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); ObservedQuantityRecording write_voltage("Voltage", io_environment, voltage_observer_contact); ObservedQuantityRecording write_displacement("Position", io_environment, myocardium_observer_contact); /**Apply the Iron stimulus.*/ @@ -215,8 +215,8 @@ int main(int ac, char *av[]) /** * Pre-simulation. */ - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); correct_configuration_excitation.exec(); correct_configuration_contraction.exec(); correct_kernel_weights_for_interpolation.exec(); @@ -354,5 +354,6 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } \ No newline at end of file diff --git a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/run_test.sh b/tests/3d_examples/test_3d_pkj_lv_electrocontraction/run_test.sh deleted file mode 100644 index bb0556b233..0000000000 --- a/tests/3d_examples/test_3d_pkj_lv_electrocontraction/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_3d_pkj_lv_electrocontraction --r=true -./test_3d_pkj_lv_electrocontraction --r=false --i=true diff --git a/tests/3d_examples/test_3d_roof/3d_roof.cpp b/tests/3d_examples/test_3d_roof/3d_roof.cpp index a852084342..42ed4e7689 100644 --- a/tests/3d_examples/test_3d_roof/3d_roof.cpp +++ b/tests/3d_examples/test_3d_roof/3d_roof.cpp @@ -114,14 +114,14 @@ class TimeDependentExternalForce : public Gravity int main(int ac, char *av[]) { /** Setup the system. */ - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.generate_regression_data_ = false; + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); // handle command line arguments /** Create a Cylinder body. */ - SolidBody cylinder_body(system, makeShared("CylinderBody")); + SolidBody cylinder_body(sph_system, makeShared("CylinderBody")); cylinder_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); cylinder_body.generateParticles(); /** Define Observer. */ - ObserverBody cylinder_observer(system, "CylinderObserver"); + ObserverBody cylinder_observer(sph_system, "CylinderObserver"); cylinder_observer.generateParticles(observation_location); /** Set body contact map @@ -155,14 +155,14 @@ int main(int ac, char *av[]) DampingWithRandomChoice>> cylinder_rotation_damping(0.2, cylinder_body_inner, "AngularVelocity", physical_viscosity); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_cylinder_max_displacement("Position", io_environment, cylinder_observer_contact); /** Apply initial condition. */ - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); corrected_configuration.exec(); /** @@ -223,7 +223,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_cylinder_max_displacement.generateDataBase(0.005); } @@ -234,6 +234,7 @@ int main(int ac, char *av[]) observed_quantity_n = (*write_cylinder_max_displacement.getObservedQuantity())[0][2]; + testing::InitGoogleTest(&ac, av); return RUN_ALL_TESTS(); } diff --git a/tests/3d_examples/test_3d_roof/CMakeLists.txt b/tests/3d_examples/test_3d_roof/CMakeLists.txt index 4e26998d6e..349eff1c3a 100644 --- a/tests/3d_examples/test_3d_roof/CMakeLists.txt +++ b/tests/3d_examples/test_3d_roof/CMakeLists.txt @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/3d_examples/test_3d_roof_parametric_cvt/test_3d_roof_parametric_cvt.cpp b/tests/3d_examples/test_3d_roof_parametric_cvt/test_3d_roof_parametric_cvt.cpp index 9f4d502d18..ffb6a9b7f3 100644 --- a/tests/3d_examples/test_3d_roof_parametric_cvt/test_3d_roof_parametric_cvt.cpp +++ b/tests/3d_examples/test_3d_roof_parametric_cvt/test_3d_roof_parametric_cvt.cpp @@ -94,8 +94,8 @@ StdVec read_obj_vertices(const std::string &file_name) { std::cout << "read_obj_vertices started" << std::endl; - std::ifstream myfile(file_name, std::ios_base::in); - if (!myfile.is_open()) + std::ifstream my_file(file_name, std::ios_base::in); + if (!my_file.is_open()) throw std::runtime_error("read_obj_vertices: file doesn't exist"); StdVec pos_0; @@ -103,7 +103,7 @@ StdVec read_obj_vertices(const std::string &file_name) unsigned int count = 0; Real value = 0; - while (myfile >> value) + while (my_file >> value) { particle[count] = value; ++count; @@ -242,11 +242,11 @@ struct return_data void write_data_to_txt(const std::string &file_name) const { - std::ofstream myfile; - myfile.open(file_name); - myfile << "displ_y_A; displ_x_A; total_area; total_mass; dp\n"; - myfile << displ_y_A << "; " << displ_x_A << "; " << total_area << "; " << total_mass << "; " << dp << "\n"; - myfile.close(); + std::ofstream my_file; + my_file.open(file_name); + my_file << "displ_y_A; displ_x_A; total_area; total_mass; dp\n"; + my_file << displ_y_A << "; " << displ_x_A << "; " << total_area << "; " << total_mass << "; " << dp << "\n"; + my_file.close(); } }; diff --git a/tests/3d_examples/test_3d_self_contact/3d_self_contact.cpp b/tests/3d_examples/test_3d_self_contact/3d_self_contact.cpp index 4490b39602..14411a8d35 100644 --- a/tests/3d_examples/test_3d_self_contact/3d_self_contact.cpp +++ b/tests/3d_examples/test_3d_self_contact/3d_self_contact.cpp @@ -56,33 +56,33 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up -- a SPHSystem //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); // Tag for run particle relaxation for the initial body fitted distribution. - system.setRunParticleRelaxation(false); + sph_system.setRunParticleRelaxation(false); // Tag for reload initially relaxed particles. - system.setReloadParticles(true); + sph_system.setReloadParticles(true); #ifdef BOOST_AVAILABLE // handle command line arguments - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody coil(system, makeShared("Coil")); + SolidBody coil(sph_system, makeShared("Coil")); coil.defineBodyLevelSetShape()->writeLevelSet(io_environment); coil.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); - (!system.RunParticleRelaxation() && system.ReloadParticles()) + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? coil.generateParticles(io_environment, coil.getName()) : coil.generateParticles(); - SolidBody stationary_plate(system, makeShared("StationaryPlate")); + SolidBody stationary_plate(sph_system, makeShared("StationaryPlate")); stationary_plate.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); stationary_plate.generateParticles(); //---------------------------------------------------------------------- // Define simple file input and outputs functions. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); //---------------------------------------------------------------------- // Define body relation map. // The contact map gives the topological connections between the bodies. @@ -94,7 +94,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // check whether run particle relaxation for body fitted particle distribution. //---------------------------------------------------------------------- - if (system.RunParticleRelaxation()) + if (sph_system.RunParticleRelaxation()) { //---------------------------------------------------------------------- // Methods used for particle relaxation. @@ -153,8 +153,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // From here the time stepping begins. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); // apply initial condition corrected_configuration.exec(); write_states.writeToFile(0); @@ -212,5 +212,6 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_self_contact/CMakeLists.txt b/tests/3d_examples/test_3d_self_contact/CMakeLists.txt index bc8f1dc397..7af5a718d6 100644 --- a/tests/3d_examples/test_3d_self_contact/CMakeLists.txt +++ b/tests/3d_examples/test_3d_self_contact/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) @@ -16,17 +16,10 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") diff --git a/tests/3d_examples/test_3d_self_contact/run_test.sh b/tests/3d_examples/test_3d_self_contact/run_test.sh deleted file mode 100644 index d0b2ec947e..0000000000 --- a/tests/3d_examples/test_3d_self_contact/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_3d_self_contact --r=true -./test_3d_self_contact --r=false --i=true diff --git a/tests/3d_examples/test_3d_shell_particle_relaxation/CMakeLists.txt b/tests/3d_examples/test_3d_shell_particle_relaxation/CMakeLists.txt index 254e5288df..d81881e3c3 100644 --- a/tests/3d_examples/test_3d_shell_particle_relaxation/CMakeLists.txt +++ b/tests/3d_examples/test_3d_shell_particle_relaxation/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/3d_examples/test_3d_shell_particle_relaxation/test_3d_shell_particle_relaxation.cpp b/tests/3d_examples/test_3d_shell_particle_relaxation/test_3d_shell_particle_relaxation.cpp index cfb172e625..156cd001d4 100644 --- a/tests/3d_examples/test_3d_shell_particle_relaxation/test_3d_shell_particle_relaxation.cpp +++ b/tests/3d_examples/test_3d_shell_particle_relaxation/test_3d_shell_particle_relaxation.cpp @@ -43,12 +43,12 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up a SPHSystem. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, dp_0); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, dp_0); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - RealBody imported_model(system, makeShared("ImportedShellModel")); + RealBody imported_model(sph_system, makeShared("ImportedShellModel")); imported_model.defineBodyLevelSetShape(level_set_refinement_ratio)->correctLevelSetSign()->writeLevelSet(io_environment); // here dummy linear elastic solid is use because no solid dynamics in particle relaxation imported_model.defineParticlesAndMaterial(1.0, 1.0, 0.0); @@ -98,5 +98,6 @@ int main(int ac, char *av[]) write_imported_model_to_vtp.writeToFile(ite_p); std::cout << "The physics relaxation process of imported model finish !" << std::endl; + return 0; } diff --git a/tests/3d_examples/test_3d_shell_stability_half_sphere/test_3d_shell_stability_half_sphere.cpp b/tests/3d_examples/test_3d_shell_stability_half_sphere/test_3d_shell_stability_half_sphere.cpp index 4b61001065..50a1b1c2dd 100644 --- a/tests/3d_examples/test_3d_shell_stability_half_sphere/test_3d_shell_stability_half_sphere.cpp +++ b/tests/3d_examples/test_3d_shell_stability_half_sphere/test_3d_shell_stability_half_sphere.cpp @@ -3,7 +3,7 @@ * @brief Shell verification incl. refinement study * @details Circular plastic shell verification case with relaxed shell particles * @author Bence Rochlitz - * @ref ANSYS Workbench Verification Manual, Release 15.0, November 2013, VMMECH051: Bending of a Circular Plate Using Axisymmetric Elements + * @ref ANSYS Workbench Verification Manual, Release 15.0, November 2013, VMMECH051: Bending of a Circular Plate Using Axis symmetric Elements */ #include "sphinxsys.h" @@ -59,8 +59,8 @@ StdVec read_obj_vertices(const std::string &file_name) { std::cout << "read_obj_vertices started" << std::endl; - std::ifstream myfile(file_name, std::ios_base::in); - if (!myfile.is_open()) + std::ifstream my_file(file_name, std::ios_base::in); + if (!my_file.is_open()) throw std::runtime_error("read_obj_vertices: file doesn't exist"); StdVec pos_0; @@ -68,7 +68,7 @@ StdVec read_obj_vertices(const std::string &file_name) unsigned int count = 0; Real value = 0; - while (myfile >> value) + while (my_file >> value) { particle[count] = value; ++count; diff --git a/tests/3d_examples/test_3d_slender_beam/CMakeLists.txt b/tests/3d_examples/test_3d_slender_beam/CMakeLists.txt index 7ad4e1cf8a..77268ca2ac 100644 --- a/tests/3d_examples/test_3d_slender_beam/CMakeLists.txt +++ b/tests/3d_examples/test_3d_slender_beam/CMakeLists.txt @@ -13,5 +13,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/3d_examples/test_3d_slender_beam/test_3d_slender_beam.cpp b/tests/3d_examples/test_3d_slender_beam/test_3d_slender_beam.cpp index 221fc8bf57..bfd5b8dab0 100644 --- a/tests/3d_examples/test_3d_slender_beam/test_3d_slender_beam.cpp +++ b/tests/3d_examples/test_3d_slender_beam/test_3d_slender_beam.cpp @@ -133,15 +133,15 @@ class TimeDependentExternalForce : public Gravity int main(int ac, char *av[]) { /** Setup the system. */ - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); /** create a bar body. */ - SolidBody bar_body(system, makeShared("BarBody")); + SolidBody bar_body(sph_system, makeShared("BarBody")); bar_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); bar_body.generateParticles(); /** Define Observer. */ - ObserverBody bar_observer(system, "BarObserver"); + ObserverBody bar_observer(sph_system, "BarObserver"); bar_observer.defineParticlesAndMaterial(); bar_observer.generateParticles(observation_location); @@ -153,8 +153,8 @@ int main(int ac, char *av[]) ContactRelation bar_observer_contact(bar_observer, {&bar_body}); /** Common particle dynamics. */ - SimpleDynamics initialize_external_force(bar_body, - makeShared(Vec3d(0.0, 0.0, q / (PT * rho0_s) - gravitational_acceleration))); + SimpleDynamics initialize_external_force( + bar_body, makeShared(Vec3d(0.0, 0.0, q / (PT * rho0_s) - gravitational_acceleration))); /** * This section define all numerical methods will be used in this case. @@ -183,13 +183,13 @@ int main(int ac, char *av[]) DampingWithRandomChoice>> bar_rotation_b_damping(0.5, bar_body_inner, "AngularVelocity_b", physical_viscosity); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); ObservedQuantityRecording write_beam_max_displacement("Position", io_environment, bar_observer_contact); /** Apply initial condition. */ - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); corrected_configuration.exec(); /** @@ -253,6 +253,7 @@ int main(int ac, char *av[]) observed_quantity_n = (*write_beam_max_displacement.getObservedQuantity())[0][2]; + testing::InitGoogleTest(&ac, av); return RUN_ALL_TESTS(); } diff --git a/tests/3d_examples/test_3d_stfb/CMakeLists.txt b/tests/3d_examples/test_3d_stfb/CMakeLists.txt index 2384662ebe..1df97abcfa 100644 --- a/tests/3d_examples/test_3d_stfb/CMakeLists.txt +++ b/tests/3d_examples/test_3d_stfb/CMakeLists.txt @@ -18,7 +18,7 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "fluid dynamics, Simbody") diff --git a/tests/3d_examples/test_3d_stfb/stfb.cpp b/tests/3d_examples/test_3d_stfb/stfb.cpp index 5d7cf854d6..6d0fb2fce8 100644 --- a/tests/3d_examples/test_3d_stfb/stfb.cpp +++ b/tests/3d_examples/test_3d_stfb/stfb.cpp @@ -13,25 +13,25 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); - SolidBody structure(system, makeShared("Structure")); + SolidBody structure(sph_system, makeShared("Structure")); structure.defineParticlesAndMaterial(rho_s); structure.generateParticles(); - ObserverBody observer(system, "Observer"); + ObserverBody observer(sph_system, "Observer"); observer.defineAdaptationRatios(1.15, 2.0); observer.generateParticles( StdVec{obs}); @@ -148,7 +148,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); /** WaveProbes. */ BodyRegionByCell wave_probe_buffer(water_block, makeShared>(Transform(translation_FS_gauge), FS_gauge)); RegressionTestDynamicTimeWarping>> wave_gauge(io_environment, wave_probe_buffer); @@ -175,8 +175,8 @@ int main(int ac, char *av[]) // and case specified initial condition if necessary. //---------------------------------------------------------------------- structure_offset_position.exec(); - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); str_normal.exec(); str_corrected_conf.exec(); @@ -263,7 +263,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_str_displacement.generateDataBase(1e-3); wave_gauge.generateDataBase(1e-3); @@ -274,5 +274,6 @@ int main(int ac, char *av[]) wave_gauge.testResult(); } + return 0; } diff --git a/tests/3d_examples/test_3d_stfb/stfb.h b/tests/3d_examples/test_3d_stfb/stfb.h index 2af1fa4fb6..390aac8beb 100644 --- a/tests/3d_examples/test_3d_stfb/stfb.h +++ b/tests/3d_examples/test_3d_stfb/stfb.h @@ -1,6 +1,6 @@ /** * @file stfb.h - * @brief This is the case file for 3D still floaing body. + * @brief This is the case file for 3D still floating body. * @author Nicolò Salis */ #include "sphinxsys.h" @@ -17,7 +17,7 @@ Real WH = 2.0; /**< Water block height. */ Real L = 1.0; /**< Base of the floating body. */ Real particle_spacing_ref = L / 10; Real BW = particle_spacing_ref * 4.0; /**< Extending width for BCs. */ -Real Maker_width = particle_spacing_ref * 4.0; /**< Width of the wavemaker. */ +Real Maker_width = particle_spacing_ref * 4.0; /**< Width of the wave_maker. */ BoundingBox system_domain_bounds(Vecd(-BW, -BW, -BW), Vecd(DW + BW, DL + BW, DH + BW)); Vecd offset = Vecd::Zero(); //---------------------------------------------------------------------- @@ -38,7 +38,7 @@ Real FlStA = L * L * L; /**< Density of the solid structure*/ Real rho_s = StructureMass / FlStA; /* Equilibrium position of the solid structure*/ -Real H = WH - (rho_s / rho0_f * L - L / 2); /**< Strart placemnt of Flt Body*/ +Real H = WH - (rho_s / rho0_f * L - L / 2); /**< Strart placement of Flt Body*/ Real bcmx = DL / 2; Real bcmy = DL / 2; @@ -117,7 +117,7 @@ class WallBoundary : public ComplexShape } }; //---------------------------------------------------------------------- -// create mesuring probes +// create measuring probes //---------------------------------------------------------------------- Real h = 1.3 * particle_spacing_ref; Vecd FS_gaugeDim(0.5 * h, 0.5 * h, 0.5 * DH); @@ -144,4 +144,4 @@ class FreeSurfaceHeightZ : public BaseLocalDynamicsReduce("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); water_block.addBodyStateForRecording("VolumetricMeasure"); - SolidBody wall_boundary(system, makeShared("Wall")); + SolidBody wall_boundary(sph_system, makeShared("Wall")); wall_boundary.defineParticlesAndMaterial(); wall_boundary.generateParticles(); //---------------------------------------------------------------------- @@ -62,7 +62,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); /** WaveProbes. */ BodyRegionByCell wave_probe_buffer(water_block, makeShared>(Transform(translation_FS_gauge), FS_gauge)); RegressionTestDynamicTimeWarping>> wave_gauge(io_environment, wave_probe_buffer); @@ -84,8 +84,8 @@ int main(int ac, char *av[]) // Prepare the simulation with cell linked list, configuration // and case specified initial condition if necessary. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_boundary_normal_direction.exec(); //---------------------------------------------------------------------- // First output before the main loop. @@ -153,7 +153,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { wave_gauge.generateDataBase(1e-3); } @@ -162,5 +162,6 @@ int main(int ac, char *av[]) wave_gauge.testResult(); } + return 0; } diff --git a/tests/3d_examples/test_3d_stlw/stlw.h b/tests/3d_examples/test_3d_stlw/stlw.h index 1e0064231f..6f570015cd 100644 --- a/tests/3d_examples/test_3d_stlw/stlw.h +++ b/tests/3d_examples/test_3d_stlw/stlw.h @@ -16,7 +16,7 @@ Real DH = 2.5; /**< Tank height. */ Real WH = 2.0; /**< Water block height. */ Real particle_spacing_ref = 0.1; Real BW = particle_spacing_ref * 4.0; /**< Extending width for BCs. */ -Real Maker_width = particle_spacing_ref * 4.0; /**< Width of the wavemaker. */ +Real Maker_width = particle_spacing_ref * 4.0; /**< Width of the wave_maker. */ BoundingBox system_domain_bounds(Vecd(-BW, -BW, -BW), Vecd(DW + BW, DL + BW, DH + BW)); @@ -63,7 +63,7 @@ class WallBoundary : public ComplexShape } }; //---------------------------------------------------------------------- -// create mesuring probes +// create measuring probes //---------------------------------------------------------------------- Real h = 1.3 * particle_spacing_ref; Vecd FS_gaugeDim(0.5 * h, 0.5 * h, 0.5 * DH); diff --git a/tests/3d_examples/test_3d_taylor_bar/CMakeLists.txt b/tests/3d_examples/test_3d_taylor_bar/CMakeLists.txt index af3bba82fc..de70716a8f 100644 --- a/tests/3d_examples/test_3d_taylor_bar/CMakeLists.txt +++ b/tests/3d_examples/test_3d_taylor_bar/CMakeLists.txt @@ -16,17 +16,10 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") diff --git a/tests/3d_examples/test_3d_taylor_bar/regression_test_tool/regression_test_tool.py b/tests/3d_examples/test_3d_taylor_bar/regression_test_tool/regression_test_tool.py index 7577007f7d..0b9f708236 100644 --- a/tests/3d_examples/test_3d_taylor_bar/regression_test_tool/regression_test_tool.py +++ b/tests/3d_examples/test_3d_taylor_bar/regression_test_tool/regression_test_tool.py @@ -25,7 +25,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() converged_1 = sphinxsys_1.read_dat_file() diff --git a/tests/3d_examples/test_3d_taylor_bar/run_test.sh b/tests/3d_examples/test_3d_taylor_bar/run_test.sh deleted file mode 100644 index 4c99d18bcf..0000000000 --- a/tests/3d_examples/test_3d_taylor_bar/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_3d_taylor_bar --r=true -./test_3d_taylor_bar --r=false --i=true \ No newline at end of file diff --git a/tests/3d_examples/test_3d_taylor_bar/taylor_bar.cpp b/tests/3d_examples/test_3d_taylor_bar/taylor_bar.cpp index b2f0f0cc50..0d8bde482a 100644 --- a/tests/3d_examples/test_3d_taylor_bar/taylor_bar.cpp +++ b/tests/3d_examples/test_3d_taylor_bar/taylor_bar.cpp @@ -13,31 +13,31 @@ using namespace SPH; int main(int ac, char *av[]) { /** Setup the system. Please the make sure the global domain bounds are correctly defined. */ - SPHSystem system(system_domain_bounds, particle_spacing_ref); - system.setRunParticleRelaxation(false); - system.setReloadParticles(true); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.setRunParticleRelaxation(false); + sph_system.setReloadParticles(true); #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); /** create a body with corresponding material, particles and reaction model. */ - SolidBody column(system, makeShared("Column")); + SolidBody column(sph_system, makeShared("Column")); column.defineAdaptationRatios(1.3, 1.0); column.defineBodyLevelSetShape()->writeLevelSet(io_environment); column.defineParticlesAndMaterial( rho0_s, Youngs_modulus, poisson, yield_stress, hardening_modulus); - (!system.RunParticleRelaxation() && system.ReloadParticles()) + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? column.generateParticles(io_environment, column.getName()) : column.generateParticles(); column.addBodyStateForRecording("NormalDirection"); - SolidBody wall(system, makeShared("Wall")); + SolidBody wall(sph_system, makeShared("Wall")); wall.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); wall.generateParticles(); /** Define Observer. */ - ObserverBody my_observer(system, "MyObserver"); + ObserverBody my_observer(sph_system, "MyObserver"); my_observer.generateParticles(); /**body relation topology */ @@ -45,9 +45,9 @@ int main(int ac, char *av[]) ContactRelation my_observer_contact(my_observer, {&column}); SurfaceContactRelation column_wall_contact(column, {&wall}); /**define simple data file input and outputs functions. */ - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); - if (system.RunParticleRelaxation()) + if (sph_system.RunParticleRelaxation()) { /** * @brief Methods used for particle relaxation. @@ -107,8 +107,8 @@ int main(int ac, char *av[]) // From here the time stepping begins. //---------------------------------------------------------------------- GlobalStaticVariables::physical_time_ = 0.0; - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); wall_normal_direction.exec(); corrected_configuration.exec(); initial_condition.exec(); @@ -176,5 +176,6 @@ int main(int ac, char *av[]) write_displacement.testResult(); write_velocity.testResult(); + return 0; } diff --git a/tests/3d_examples/test_3d_thin_plate/CMakeLists.txt b/tests/3d_examples/test_3d_thin_plate/CMakeLists.txt index 7ad4e1cf8a..77268ca2ac 100644 --- a/tests/3d_examples/test_3d_thin_plate/CMakeLists.txt +++ b/tests/3d_examples/test_3d_thin_plate/CMakeLists.txt @@ -13,5 +13,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/3d_examples/test_3d_thin_plate/test_3d_thin_plate.cpp b/tests/3d_examples/test_3d_thin_plate/test_3d_thin_plate.cpp index 505c90bc1d..88ad80b665 100644 --- a/tests/3d_examples/test_3d_thin_plate/test_3d_thin_plate.cpp +++ b/tests/3d_examples/test_3d_thin_plate/test_3d_thin_plate.cpp @@ -131,15 +131,15 @@ class TimeDependentExternalForce : public Gravity int main(int ac, char *av[]) { /** Setup the system. */ - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); /** create a plate body. */ - SolidBody plate_body(system, makeShared("PlateBody")); + SolidBody plate_body(sph_system, makeShared("PlateBody")); plate_body.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); plate_body.generateParticles(); /** Define Observer. */ - ObserverBody plate_observer(system, "PlateObserver"); + ObserverBody plate_observer(sph_system, "PlateObserver"); plate_observer.defineParticlesAndMaterial(); plate_observer.generateParticles(observation_location); @@ -151,8 +151,8 @@ int main(int ac, char *av[]) ContactRelation plate_observer_contact(plate_observer, {&plate_body}); /** Common particle dynamics. */ - SimpleDynamics initialize_external_force(plate_body, - makeShared(Vec3d(0.0, 0.0, q / (PT * rho0_s) - gravitational_acceleration))); + SimpleDynamics initialize_external_force( + plate_body, makeShared(Vec3d(0.0, 0.0, q / (PT * rho0_s) - gravitational_acceleration))); /** * This section define all numerical methods will be used in this case. @@ -179,13 +179,13 @@ int main(int ac, char *av[]) DampingWithRandomChoice>> plate_rotation_damping(0.5, plate_body_inner, "AngularVelocity", physical_viscosity); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); ObservedQuantityRecording write_plate_max_displacement("Position", io_environment, plate_observer_contact); /** Apply initial condition. */ - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); corrected_configuration.exec(); /** @@ -248,6 +248,7 @@ int main(int ac, char *av[]) observed_quantity_n = (*write_plate_max_displacement.getObservedQuantity())[0][2]; + testing::InitGoogleTest(&ac, av); return RUN_ALL_TESTS(); } diff --git a/tests/3d_examples/test_3d_twisting_column/CMakeLists.txt b/tests/3d_examples/test_3d_twisting_column/CMakeLists.txt index 4a0ea7e96e..af1def3d7e 100644 --- a/tests/3d_examples/test_3d_twisting_column/CMakeLists.txt +++ b/tests/3d_examples/test_3d_twisting_column/CMakeLists.txt @@ -16,4 +16,5 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/3d_examples/test_3d_twisting_column/twisting_column.cpp b/tests/3d_examples/test_3d_twisting_column/twisting_column.cpp index b3c7ce14ef..cc0e9cd696 100644 --- a/tests/3d_examples/test_3d_twisting_column/twisting_column.cpp +++ b/tests/3d_examples/test_3d_twisting_column/twisting_column.cpp @@ -14,20 +14,20 @@ using namespace SPH; int main(int ac, char *av[]) { /** Setup the system. Please the make sure the global domain bounds are correctly defined. */ - SPHSystem system(system_domain_bounds, particle_spacing_ref); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif - IOEnvironment io_environment(system); + IOEnvironment io_environment(sph_system); //---------------------------------------------------------------------- // Creating bodies with corresponding materials and particles. //---------------------------------------------------------------------- /** create a body with corresponding material, particles and reaction model. */ - SolidBody column(system, makeShared("Column")); + SolidBody column(sph_system, makeShared("Column")); column.defineParticlesAndMaterial(rho0_s, Youngs_modulus, poisson); column.generateParticles(); /** Define Observer. */ - ObserverBody my_observer(system, "MyObserver"); + ObserverBody my_observer(sph_system, "MyObserver"); my_observer.generateParticles(observation_location); /**body relation topology */ InnerRelation column_inner(column); @@ -49,7 +49,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Output //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_velocity("Velocity", io_environment, my_observer_contact); RegressionTestDynamicTimeWarping> @@ -57,8 +57,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // From here the time stepping begins. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); initial_condition.exec(); corrected_configuration.exec(); write_states.writeToFile(0); @@ -110,7 +110,7 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - if (system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_displacement.generateDataBase(0.005); write_velocity.generateDataBase(0.005); @@ -121,5 +121,6 @@ int main(int ac, char *av[]) write_velocity.testResult(); } + return 0; } diff --git a/tests/user_examples/extra_src/for_2D_build/common_shared_FVM_classes.cpp b/tests/user_examples/extra_src/for_2D_build/common_shared_FVM_classes.cpp index 2571d64f3b..3898169986 100644 --- a/tests/user_examples/extra_src/for_2D_build/common_shared_FVM_classes.cpp +++ b/tests/user_examples/extra_src/for_2D_build/common_shared_FVM_classes.cpp @@ -515,7 +515,7 @@ InnerRelationInFVM::InnerRelationInFVM(RealBody &real_body, vector void InnerRelationInFVM::searchNeighborsByParticles(size_t total_particles, BaseParticles &source_particles, - ParticleConfiguration &particle_configuration, GetParticleIndex &get_particle_index, GetNeighborRelation &get_neighbor_relation) + ParticleConfiguration &particle_configuration, GetParticleIndex &get_particle_index, GetNeighborRelation &get_neighbor_relation) { parallel_for( IndexRange(0, base_particles_.total_real_particles_ + base_particles_.total_ghost_particles_), @@ -580,7 +580,7 @@ void BodyStatesRecordingInMeshToVtp::writeWithFileName(const std::string &sequen { for (SPHBody *body : bodies_) { - if (body->checkNewlyUpdated()) + if (body->checkNewlyUpdated() && state_recording_) { // TODO: we can short the file name by without using SPHBody std::string filefullpath = io_environment_.output_folder_ + "/SPHBody_" + body->getName() + "_" + sequence + ".vtp"; diff --git a/tests/user_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.cpp b/tests/user_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.cpp index 6f79e36c4c..adab1ac654 100644 --- a/tests/user_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.cpp +++ b/tests/user_examples/test_2d_FVM_double_mach_reflection/2d_FVM_double_mach_reflection.cpp @@ -51,7 +51,7 @@ int main(int ac, char *av[]) the value is larger, the numerical dissipation larger*/ InteractionWithUpdate pressure_relaxation(water_block_inner); InteractionWithUpdate density_relaxation(water_block_inner); - //Visuallization in FVM with date in cell. + // Visuallization in FVM with date in cell. BodyStatesRecordingInMeshToVtp write_real_body_states(io_environment, sph_system.real_bodies_, read_mesh_data.elements_nodes_connection_, read_mesh_data.point_coordinates_2D_); //---------------------------------------------------------------------- // Prepare the simulation with case specified initial condition if necessary. @@ -108,5 +108,6 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; cout << "Total wall time for computation: " << tt.seconds() << " seconds." << endl; + return 0; } diff --git a/tests/user_examples/test_2d_FVM_double_mach_reflection/CMakeLists.txt b/tests/user_examples/test_2d_FVM_double_mach_reflection/CMakeLists.txt index 8145387293..910a98f24c 100644 --- a/tests/user_examples/test_2d_FVM_double_mach_reflection/CMakeLists.txt +++ b/tests/user_examples/test_2d_FVM_double_mach_reflection/CMakeLists.txt @@ -10,19 +10,17 @@ file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/double_mach_reflection_0.05.msh DESTINATION ${BUILD_INPUT_PATH}) - add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} extra_sources_2d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - -add_test(NAME ${PROJECT_NAME}_particle_relaxation - COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME}_particle_relaxation + COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, Eulerian") diff --git a/tests/user_examples/test_2d_FVM_flow_around_cylinder/2d_FVM_flow_around_cylinder.cpp b/tests/user_examples/test_2d_FVM_flow_around_cylinder/2d_FVM_flow_around_cylinder.cpp index 428db9f12a..d7fbd65a8e 100644 --- a/tests/user_examples/test_2d_FVM_flow_around_cylinder/2d_FVM_flow_around_cylinder.cpp +++ b/tests/user_examples/test_2d_FVM_flow_around_cylinder/2d_FVM_flow_around_cylinder.cpp @@ -129,5 +129,6 @@ int main(int ac, char *av[]) cout << "Total wall time for computation: " << tt.seconds() << " seconds." << endl; write_total_viscous_force_on_inserted_body.testResult(); + return 0; } diff --git a/tests/user_examples/test_2d_FVM_flow_around_cylinder/CMakeLists.txt b/tests/user_examples/test_2d_FVM_flow_around_cylinder/CMakeLists.txt index 2b7aa98864..831d16d20b 100644 --- a/tests/user_examples/test_2d_FVM_flow_around_cylinder/CMakeLists.txt +++ b/tests/user_examples/test_2d_FVM_flow_around_cylinder/CMakeLists.txt @@ -8,23 +8,21 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/fluent_0.3.msh DESTINATION ${BUILD_INPUT_PATH}) - add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} extra_sources_2d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - -add_test(NAME ${PROJECT_NAME}_particle_relaxation - COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME}_particle_relaxation + COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, Eulerian") diff --git a/tests/user_examples/test_2d_FVM_flow_around_cylinder/regression_test_tool/regression_test_tool.py b/tests/user_examples/test_2d_FVM_flow_around_cylinder/regression_test_tool/regression_test_tool.py index 7d7695a3a3..888abde0e8 100644 --- a/tests/user_examples/test_2d_FVM_flow_around_cylinder/regression_test_tool/regression_test_tool.py +++ b/tests/user_examples/test_2d_FVM_flow_around_cylinder/regression_test_tool/regression_test_tool.py @@ -21,7 +21,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() print("Please note: This is the", number_of_run_times, "run!") diff --git a/tests/user_examples/test_2d_column_collapse/CMakeLists.txt b/tests/user_examples/test_2d_column_collapse/CMakeLists.txt index 3af25fce68..53b296dac0 100644 --- a/tests/user_examples/test_2d_column_collapse/CMakeLists.txt +++ b/tests/user_examples/test_2d_column_collapse/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} extra_sources_2d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/user_examples/test_2d_column_collapse/column_collapse.cpp b/tests/user_examples/test_2d_column_collapse/column_collapse.cpp index b6284133fc..2d4f436d6f 100644 --- a/tests/user_examples/test_2d_column_collapse/column_collapse.cpp +++ b/tests/user_examples/test_2d_column_collapse/column_collapse.cpp @@ -237,8 +237,8 @@ int main(int ac, char *av[]) std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; - //sph_system.generate_regression_data_ = true; - if (sph_system.generate_regression_data_) + //sph_system.GenerateRegressionData() = true; + if (sph_system.GenerateRegressionData()) { write_mechanical_energy.generateDataBase(1.0e-3); } @@ -247,5 +247,6 @@ int main(int ac, char *av[]) write_mechanical_energy.testResult(); } + return 0; }; \ No newline at end of file diff --git a/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp b/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp index 9a85e581bf..36f85b02d8 100644 --- a/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp +++ b/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/2d_eulerian_flow_around_cylinder_LG.cpp @@ -194,5 +194,6 @@ int main(int ac, char *av[]) write_total_viscous_force_on_inserted_body.testResult(); + return 0; } diff --git a/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/CMakeLists.txt b/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/CMakeLists.txt index d7cab5d175..a0fba24567 100644 --- a/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/CMakeLists.txt +++ b/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/CMakeLists.txt @@ -10,20 +10,17 @@ file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) - add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} extra_sources_2d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - -add_test(NAME ${PROJECT_NAME}_particle_relaxation - COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME}_particle_relaxation + COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES DEPENDS "${PROJECT_NAME}_particle_relaxation") set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, Eulerian") - diff --git a/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/regression_test_tool/regression_test_tool.py b/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/regression_test_tool/regression_test_tool.py index d0b12d13e2..bc53b00069 100644 --- a/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/regression_test_tool/regression_test_tool.py +++ b/tests/user_examples/test_2d_eulerian_flow_around_cylinder_LG/regression_test_tool/regression_test_tool.py @@ -21,7 +21,7 @@ while True: print("Now start a new run......") sphinxsys.run_particle_relaxation() - sphinxsys.run_case() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() print("Please note: This is the", number_of_run_times, "run!") diff --git a/tests/user_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp b/tests/user_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp index 0822e675fc..276bd934bb 100644 --- a/tests/user_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp +++ b/tests/user_examples/test_2d_eulerian_taylor_green_LG/2d_eulerian_taylor_green_LG.cpp @@ -137,5 +137,6 @@ int main(int ac, char *av[]) write_total_mechanical_energy.testResult(); write_maximum_speed.testResult(); + return 0; } diff --git a/tests/user_examples/test_2d_eulerian_taylor_green_LG/CMakeLists.txt b/tests/user_examples/test_2d_eulerian_taylor_green_LG/CMakeLists.txt index b8e620c1cd..1a64d78cc1 100644 --- a/tests/user_examples/test_2d_eulerian_taylor_green_LG/CMakeLists.txt +++ b/tests/user_examples/test_2d_eulerian_taylor_green_LG/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/") @@ -22,14 +22,14 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/WaterBody_TotalMechan DESTINATION ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/WaterBody_TotalMechanicalEnergy_ensemble_averaged_mean_variance.xml DESTINATION ${BUILD_INPUT_PATH}) - + aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "periodic boundary, Eulerian") - set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") - target_link_libraries(${PROJECT_NAME} extra_sources_2d) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") +target_link_libraries(${PROJECT_NAME} extra_sources_2d) diff --git a/tests/user_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp b/tests/user_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp index 942c8ace82..44d7ba3f48 100644 --- a/tests/user_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp +++ b/tests/user_examples/test_2d_flow_stream_around_fish/2d_flow_stream_around_fish.cpp @@ -12,32 +12,32 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, particle_spacing_ref); + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); /** Tag for run particle relaxation for the initial body fitted distribution. */ - system.setRunParticleRelaxation(true); + sph_system.setRunParticleRelaxation(true); /** Tag for computation start with relaxed body fitted particles distribution. */ - system.setReloadParticles(false); + sph_system.setReloadParticles(false); // handle command line arguments #ifdef BOOST_AVAILABLE - system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(system); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); #endif //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- //---------------------------------------------------------------------- - FluidBody water_block(system, makeShared("WaterBody")); + FluidBody water_block(sph_system, makeShared("WaterBody")); water_block.defineParticlesAndMaterial(rho0_f, c_f, mu_f); water_block.generateParticles(); /** * @brief Particles and body creation for fish. */ - SolidBody fish_body(system, makeShared("FishBody")); + SolidBody fish_body(sph_system, makeShared("FishBody")); fish_body.defineAdaptationRatios(1.15, 2.0); fish_body.defineBodyLevelSetShape()->writeLevelSet(io_environment); fish_body.defineParticlesAndMaterial(); // Using relaxed particle distribution if needed - (!system.RunParticleRelaxation() && system.ReloadParticles()) + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) ? fish_body.generateParticles(io_environment, fish_body.getName()) : fish_body.generateParticles(); //---------------------------------------------------------------------- @@ -52,7 +52,7 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Run particle relaxation for body-fitted distribution if chosen. //---------------------------------------------------------------------- - if (system.RunParticleRelaxation()) + if (sph_system.RunParticleRelaxation()) { /** * @brief Methods used for particle relaxation. @@ -160,8 +160,8 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Define the methods for I/O operations and observations of the simulation. //---------------------------------------------------------------------- - BodyStatesRecordingToVtp write_real_body_states(io_environment, system.real_bodies_); - RestartIO restart_io(io_environment, system.real_bodies_); + BodyStatesRecordingToVtp write_real_body_states(io_environment, sph_system.real_bodies_); + RestartIO restart_io(io_environment, sph_system.real_bodies_); RegressionTestTimeAverage>> write_total_viscous_force_on_insert_body(io_environment, viscous_force_on_solid, "TotalViscousForceOnSolid"); RegressionTestTimeAverage>> @@ -171,9 +171,9 @@ int main(int ac, char *av[]) // and case specified initial condition if necessary. //---------------------------------------------------------------------- /** initialize cell linked lists for all bodies. */ - system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemCellLinkedLists(); /** initialize configurations for all bodies. */ - system.initializeSystemConfigurations(); + sph_system.initializeSystemConfigurations(); /** computing surface normal direction for the fish. */ fish_body_normal_direction.exec(); /** computing linear reproducing configuration for the fish. */ @@ -287,5 +287,6 @@ int main(int ac, char *av[]) tt = t4 - t1 - interval; std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + return 0; } diff --git a/tests/user_examples/test_2d_flow_stream_around_fish/CMakeLists.txt b/tests/user_examples/test_2d_flow_stream_around_fish/CMakeLists.txt index 8fc0e129ec..67afd07e84 100644 --- a/tests/user_examples/test_2d_flow_stream_around_fish/CMakeLists.txt +++ b/tests/user_examples/test_2d_flow_stream_around_fish/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) PROJECT("${CURRENT_FOLDER}") SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) @@ -13,17 +13,10 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") aux_source_directory(. DIR_SRCS) ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS}) -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif() +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} sphinxsys_2d) diff --git a/tests/user_examples/test_2d_flow_stream_around_fish/run_test.sh b/tests/user_examples/test_2d_flow_stream_around_fish/run_test.sh deleted file mode 100644 index 5ad71f9c2e..0000000000 --- a/tests/user_examples/test_2d_flow_stream_around_fish/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_2d_flow_stream_around_fish --r=true -./test_2d_flow_stream_around_fish --r=false --i=true diff --git a/tests/user_examples/test_2d_membrane/2d_membrane.cpp b/tests/user_examples/test_2d_membrane/2d_membrane.cpp index 09c86a5cb7..87ddd2ec1e 100644 --- a/tests/user_examples/test_2d_membrane/2d_membrane.cpp +++ b/tests/user_examples/test_2d_membrane/2d_membrane.cpp @@ -41,7 +41,7 @@ Real fulid_initial_density_ = 1.0; Real water_pressure_constant_ = 3.0e6; Real saturation = 0.4; -Real refer_density_energy = 0.5 * water_pressure_constant_ ; +Real refer_density_energy = 0.5 * water_pressure_constant_; //---------------------------------------------------------------------- // Geometric shapes used in the system. @@ -106,15 +106,15 @@ MultiPolygon createSaturationConstrainShape() //---------------------------------------------------------------------- // application dependent initial condition //---------------------------------------------------------------------- -class SaturationInitialCondition : public multi_species_continuum::PorousMediaSaturationDynamicsInitialCondition +class SaturationInitialCondition : public multi_species_continuum::PorousMediaSaturationDynamicsInitialCondition { public: - SaturationInitialCondition(BodyPartByParticle &body_part) : multi_species_continuum::PorousMediaSaturationDynamicsInitialCondition(body_part){}; + SaturationInitialCondition(BodyPartByParticle &body_part) : multi_species_continuum::PorousMediaSaturationDynamicsInitialCondition(body_part){}; virtual ~SaturationInitialCondition(){}; protected: void update(size_t index_i, Real dt = 0.0) - { + { fluid_saturation_[index_i] = saturation; fluid_mass_[index_i] = saturation * fulid_initial_density_ * Vol_update_[index_i]; total_mass_[index_i] = rho_n_[index_i] * Vol_update_[index_i] + fluid_mass_[index_i]; @@ -129,19 +129,19 @@ int main(int ac, char *av[]) //---------------------------------------------------------------------- // Build up the environment of a SPHSystem with global controls. //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); #ifdef BOOST_AVAILABLE // handle command line arguments - system.handleCommandlineOptions(ac, av); + sph_system.handleCommandlineOptions(ac, av); #endif //---------------------------------------------------------------------- // Creating body, materials and particles. //---------------------------------------------------------------------- - SolidBody beam_body(system, makeShared("2dMembrane")); - beam_body.defineParticlesAndMaterial(rho_0, Youngs_modulus, poisson, - diffusivity_constant_, fulid_initial_density_, water_pressure_constant_); + SolidBody beam_body(sph_system, makeShared("2dMembrane")); + beam_body.defineParticlesAndMaterial( + rho_0, Youngs_modulus, poisson, diffusivity_constant_, fulid_initial_density_, water_pressure_constant_); beam_body.generateParticles(); - ObserverBody beam_observer(system, "MembraneObserver"); + ObserverBody beam_observer(sph_system, "MembraneObserver"); beam_observer.defineAdaptationRatios(1.15, 2.0); beam_observer.generateParticles(observation_location); //---------------------------------------------------------------------- @@ -155,12 +155,11 @@ int main(int ac, char *av[]) // this section define all numerical methods will be used in this case //----------------------------------------------------------------------------- - // corrected strong configuration InteractionWithUpdate beam_corrected_configuration(beam_body_inner); // time step size calculation ReduceDynamics computing_time_step_size(beam_body); - ReduceDynamics< multi_species_continuum::GetSaturationTimeStepSize> saturation_time_step_size(beam_body); + ReduceDynamics saturation_time_step_size(beam_body); // stress relaxation for the beam Dynamics1Level stress_relaxation_first_half(beam_body_inner); @@ -172,8 +171,8 @@ int main(int ac, char *av[]) SimpleDynamics clamp_constrain_beam_base(beam_base); BodyRegionByParticle beam_saturation(beam_body, makeShared(createSaturationConstrainShape())); - SimpleDynamics constrain_beam_saturation(beam_saturation); - + SimpleDynamics constrain_beam_saturation(beam_saturation); + // need to be done ReduceDynamics get_kinetic_energy(beam_body); @@ -183,36 +182,32 @@ int main(int ac, char *av[]) //----------------------------------------------------------------------------- // outputs //----------------------------------------------------------------------------- - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_beam_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_beam_states(io_environment, sph_system.real_bodies_); // note there is a line observation - + ObservedQuantityRecording write_beam_tip_position("Position", io_environment, beam_observer_contact); //---------------------------------------------------------------------- // Setup computing and initial conditions. //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); constrain_beam_saturation.exec(); beam_corrected_configuration.exec(); - - + int ite = 0; - int total_ite = 0; - - + int total_ite = 0; + GlobalStaticVariables::physical_time_ = 0.0; - + //---------------------------------------------------------------------- // Setup computing time-step controls. //---------------------------------------------------------------------- - Real End_Time = 100.0; Real setup_saturation_time_ = End_Time * 0.1; - // time step size for output file Real D_Time = End_Time / 100.0; @@ -226,9 +221,7 @@ int main(int ac, char *av[]) //----------------------------------------------------------------------------- write_beam_states.writeToFile(0); write_beam_tip_position.writeToFile(0); - - - + // computation loop starts while (GlobalStaticVariables::physical_time_ < End_Time) { @@ -242,15 +235,14 @@ int main(int ac, char *av[]) constrain_beam_saturation.exec(); } saturation_relaxation.exec(Dt); - + int stress_ite = 0; Real relaxation_time = 0.0; Real total_kinetic_energy = 1000.0; - while (relaxation_time < Dt) { - if (total_kinetic_energy > (5e-9* refer_density_energy )) // this is because we change the total mehanical energy calculation + if (total_kinetic_energy > (5e-9 * refer_density_energy)) // this is because we change the total mehanical energy calculation { stress_relaxation_first_half.exec(dt); clamp_constrain_beam_base.exec(); @@ -266,28 +258,26 @@ int main(int ac, char *av[]) if (ite % 1000 == 0) { std::cout << "N=" << ite << " Time: " - << GlobalStaticVariables::physical_time_ << " Dt:" << Dt << " dt: " - << dt << " Dt/ dt:" << Dt / dt << "\n"; + << GlobalStaticVariables::physical_time_ << " Dt:" << Dt << " dt: " + << dt << " Dt/ dt:" << Dt / dt << "\n"; } - } - total_ite++; relaxation_time += dt; integration_time += dt; GlobalStaticVariables::physical_time_ += dt; } - - std::cout << "One Diffusion finishes " - << "total_kinetic_energy = " << total_kinetic_energy - << " stress_ite = " << stress_ite << std::endl; + + std::cout << "One Diffusion finishes " + << "total_kinetic_energy = " << total_kinetic_energy + << " stress_ite = " << stress_ite << std::endl; } TickCount t2 = TickCount::now(); write_beam_states.writeToFile(ite); write_beam_tip_position.writeToFile(ite); - + TickCount t3 = TickCount::now(); interval += t3 - t2; } @@ -300,5 +290,6 @@ int main(int ac, char *av[]) std::cout << "Total iterations computation: " << GlobalStaticVariables::physical_time_ / dt << " Total iterations: " << total_ite << std::endl; + return 0; } diff --git a/tests/user_examples/test_2d_membrane/CMakeLists.txt b/tests/user_examples/test_2d_membrane/CMakeLists.txt index 3b2a61cb57..b4b2b11b8b 100644 --- a/tests/user_examples/test_2d_membrane/CMakeLists.txt +++ b/tests/user_examples/test_2d_membrane/CMakeLists.txt @@ -7,7 +7,7 @@ SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input") SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) - + add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) @@ -15,5 +15,5 @@ target_link_libraries(${PROJECT_NAME} extra_sources_2d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/user_examples/test_2d_oscillating_beam_UL/CMakeLists.txt b/tests/user_examples/test_2d_oscillating_beam_UL/CMakeLists.txt index 3af25fce68..53b296dac0 100644 --- a/tests/user_examples/test_2d_oscillating_beam_UL/CMakeLists.txt +++ b/tests/user_examples/test_2d_oscillating_beam_UL/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} extra_sources_2d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/user_examples/test_2d_oscillating_beam_UL/oscillating_beam_UL.cpp b/tests/user_examples/test_2d_oscillating_beam_UL/oscillating_beam_UL.cpp index 31bccffeac..bc8657ba9e 100644 --- a/tests/user_examples/test_2d_oscillating_beam_UL/oscillating_beam_UL.cpp +++ b/tests/user_examples/test_2d_oscillating_beam_UL/oscillating_beam_UL.cpp @@ -1,36 +1,36 @@ /* ---------------------------------------------------------------------------* -* SPHinXsys: 2D oscillation beam example-update Lagrange * -* ----------------------------------------------------------------------------* -* This is the one of the basic test cases for understanding SPH method for * -* solid simulation based on update Lagrange method * -* In this case, the constraint of the beam is implemented with * -* internal constrained subregion. * -* ----------------------------------------------------------------------------*/ -#include "sphinxsys.h" + * SPHinXsys: 2D oscillation beam example-update Lagrange * + * ----------------------------------------------------------------------------* + * This is the one of the basic test cases for understanding SPH method for * + * solid simulation based on update Lagrange method * + * In this case, the constraint of the beam is implemented with * + * internal constrained subregion. * + * ----------------------------------------------------------------------------*/ #include "all_continuum.h" +#include "sphinxsys.h" using namespace SPH; //------------------------------------------------------------------------------ -//global parameters for the case +// global parameters for the case //------------------------------------------------------------------------------ -Real PL = 0.2; //beam length -Real PH = 0.02; //for thick plate; =0.01 for thin plate -Real SL = 0.06; //depth of the insert +Real PL = 0.2; // beam length +Real PH = 0.02; // for thick plate; =0.01 for thin plate +Real SL = 0.06; // depth of the insert Real resolution_ref = PH / 10; -Real BW = resolution_ref * 4; //boundary width, at least three particles +Real BW = resolution_ref * 4; // boundary width, at least three particles /** Domain bounds of the system. */ BoundingBox system_domain_bounds(Vec2d(-SL - BW, -PL / 2.0), - Vec2d(PL + 3.0 * BW, PL / 2.0)); + Vec2d(PL + 3.0 * BW, PL / 2.0)); //---------------------------------------------------------------------- // Material properties of the fluid. //---------------------------------------------------------------------- -Real rho0_s = 1.0e3; //reference density -Real Youngs_modulus = 2.0e6; //reference Youngs modulus -Real poisson = 0.3975; //Poisson ratio -//Real poisson = 0.4; //Poisson ratio +Real rho0_s = 1.0e3; // reference density +Real Youngs_modulus = 2.0e6; // reference Youngs modulus +Real poisson = 0.3975; // Poisson ratio +// Real poisson = 0.4; //Poisson ratio Real c0 = sqrt(Youngs_modulus / (3 * (1 - 2 * poisson) * rho0_s)); Real gravity_g = 0.0; //---------------------------------------------------------------------- -// Parameters for initial condition on velocity +// Parameters for initial condition on velocity //---------------------------------------------------------------------- Real kl = 1.875; Real M = sin(kl) + sinh(kl); @@ -38,197 +38,198 @@ Real N = cos(kl) + cosh(kl); Real Q = 2.0 * (cos(kl) * sinh(kl) - sin(kl) * cosh(kl)); Real vf = 0.05; Real R = PL / (0.5 * Pi); -//for dual time-step +// for dual time-step Real U_ref = vf * c0 * (M * (cos(kl) - cosh(kl)) - N * (sin(kl) - sinh(kl))) / Q; //---------------------------------------------------------------------- // Geometric shapes used in the system. //---------------------------------------------------------------------- // a beam base shape std::vector beam_base_shape{ - Vecd(-SL - BW, -PH / 2 - BW), Vecd(-SL - BW, PH / 2 + BW), Vecd(0.0, PH / 2 + BW), - Vecd(0.0, -PH / 2 - BW), Vecd(-SL - BW, -PH / 2 - BW) }; + Vecd(-SL - BW, -PH / 2 - BW), Vecd(-SL - BW, PH / 2 + BW), Vecd(0.0, PH / 2 + BW), + Vecd(0.0, -PH / 2 - BW), Vecd(-SL - BW, -PH / 2 - BW)}; // a beam shape std::vector beam_shape{ - Vecd(-SL, -PH / 2), Vecd(-SL, PH / 2), Vecd(PL, PH / 2), Vecd(PL, -PH / 2), Vecd(-SL, -PH / 2) }; -//Beam observer location -StdVec observation_location = { Vecd(PL, 0.0) }; + Vecd(-SL, -PH / 2), Vecd(-SL, PH / 2), Vecd(PL, PH / 2), Vecd(PL, -PH / 2), Vecd(-SL, -PH / 2)}; +// Beam observer location +StdVec observation_location = {Vecd(PL, 0.0)}; //---------------------------------------------------------------------- // Define the beam body //---------------------------------------------------------------------- class Beam : public MultiPolygonShape { -public: - explicit Beam(const std::string& shape_name) : MultiPolygonShape(shape_name) - { - multi_polygon_.addAPolygon(beam_base_shape, ShapeBooleanOps::add); - multi_polygon_.addAPolygon(beam_shape, ShapeBooleanOps::add); - } + public: + explicit Beam(const std::string &shape_name) : MultiPolygonShape(shape_name) + { + multi_polygon_.addAPolygon(beam_base_shape, ShapeBooleanOps::add); + multi_polygon_.addAPolygon(beam_shape, ShapeBooleanOps::add); + } }; //---------------------------------------------------------------------- -// application dependent initial condition +// application dependent initial condition //---------------------------------------------------------------------- class BeamInitialCondition - : public fluid_dynamics::FluidInitialCondition + : public fluid_dynamics::FluidInitialCondition { -public: - explicit BeamInitialCondition(RealBody& beam_column) - : fluid_dynamics::FluidInitialCondition(beam_column) {}; -protected: - void update(size_t index_i, Real dt) - { - /** initial velocity profile */ - Real x = pos_[index_i][0] / PL; - if (x > 0.0) - { - vel_[index_i][1] = vf * c0 * - (M * (cos(kl * x) - cosh(kl * x)) - N * (sin(kl * x) - sinh(kl * x))) / Q; - } - }; + public: + explicit BeamInitialCondition(RealBody &beam_column) + : fluid_dynamics::FluidInitialCondition(beam_column){}; + + protected: + void update(size_t index_i, Real dt) + { + /** initial velocity profile */ + Real x = pos_[index_i][0] / PL; + if (x > 0.0) + { + vel_[index_i][1] = vf * c0 * + (M * (cos(kl * x) - cosh(kl * x)) - N * (sin(kl * x) - sinh(kl * x))) / Q; + } + }; }; //---------------------------------------------------------------------- // define the beam base which will be constrained. //---------------------------------------------------------------------- MultiPolygon createBeamConstrainShape() { - MultiPolygon multi_polygon; - multi_polygon.addAPolygon(beam_base_shape, ShapeBooleanOps::add); - multi_polygon.addAPolygon(beam_shape, ShapeBooleanOps::sub); - return multi_polygon; + MultiPolygon multi_polygon; + multi_polygon.addAPolygon(beam_base_shape, ShapeBooleanOps::add); + multi_polygon.addAPolygon(beam_shape, ShapeBooleanOps::sub); + return multi_polygon; }; //------------------------------------------------------------------------------ -//the main program +// the main program //------------------------------------------------------------------------------ -int main(int ac, char* av[]) +int main(int ac, char *av[]) { - //---------------------------------------------------------------------- - // Build up the environment of a SPHSystem with global controls. - //---------------------------------------------------------------------- - SPHSystem system(system_domain_bounds, resolution_ref); + //---------------------------------------------------------------------- + // Build up the environment of a SPHSystem with global controls. + //---------------------------------------------------------------------- + SPHSystem sph_system(system_domain_bounds, resolution_ref); #ifdef BOOST_AVAILABLE - // handle command line arguments - system.handleCommandlineOptions(ac, av); -#endif - //---------------------------------------------------------------------- - // Creating body, materials and particles. - //---------------------------------------------------------------------- - RealBody beam_body(system, makeShared("BeamBody")); - beam_body.sph_adaptation_->resetKernel(); - beam_body.defineParticlesAndMaterial(rho0_s, c0, Youngs_modulus, poisson); - beam_body.generateParticles(); - beam_body.addBodyStateForRecording("VonMisesStress"); - beam_body.addBodyStateForRecording("VonMisesStrain"); - beam_body.addBodyStateForRecording("Pressure"); - beam_body.addBodyStateForRecording("Density"); + // handle command line arguments + sph_system.handleCommandlineOptions(ac, av); +#endif + //---------------------------------------------------------------------- + // Creating body, materials and particles. + //---------------------------------------------------------------------- + RealBody beam_body(sph_system, makeShared("BeamBody")); + beam_body.sph_adaptation_->resetKernel(); + beam_body.defineParticlesAndMaterial(rho0_s, c0, Youngs_modulus, poisson); + beam_body.generateParticles(); + beam_body.addBodyStateForRecording("VonMisesStress"); + beam_body.addBodyStateForRecording("VonMisesStrain"); + beam_body.addBodyStateForRecording("Pressure"); + beam_body.addBodyStateForRecording("Density"); - ObserverBody beam_observer(system, "BeamObserver"); - beam_observer.sph_adaptation_->resetAdaptationRatios(1.15, 2.0); - beam_observer.generateParticles(observation_location); + ObserverBody beam_observer(sph_system, "BeamObserver"); + beam_observer.sph_adaptation_->resetAdaptationRatios(1.15, 2.0); + beam_observer.generateParticles(observation_location); - //---------------------------------------------------------------------- - // Define body relation map. - // The contact map gives the topological connections between the bodies. - // Basically the the range of bodies to build neighbor particle lists. - //---------------------------------------------------------------------- - ContactRelation beam_observer_contact(beam_observer, { &beam_body }); - InnerRelation beam_body_inner(beam_body); - //----------------------------------------------------------------------------- - //this section define all numerical methods will be used in this case - //----------------------------------------------------------------------------- + //---------------------------------------------------------------------- + // Define body relation map. + // The contact map gives the topological connections between the bodies. + // Basically the the range of bodies to build neighbor particle lists. + //---------------------------------------------------------------------- + ContactRelation beam_observer_contact(beam_observer, {&beam_body}); + InnerRelation beam_body_inner(beam_body); + //----------------------------------------------------------------------------- + // this section define all numerical methods will be used in this case + //----------------------------------------------------------------------------- - /** initial condition */ - SimpleDynamics beam_initial_velocity(beam_body); - SharedPtr gravity_ptr = makeShared(Vecd(0.0, -gravity_g)); - Dynamics1Level beam_pressure_relaxation(beam_body_inner); - Dynamics1Level beam_density_relaxation(beam_body_inner); - InteractionDynamics - beam_shear_acceleration_angular_conservative(beam_body_inner); - InteractionWithUpdate correcttion_matrix(beam_body_inner); - Dynamics1Level beam_shear_stress_relaxation(beam_body_inner); - //for dula timestep - ReduceDynamics fluid_advection_time_step(beam_body, U_ref, 0.2); - ReduceDynamics fluid_acoustic_time_step(beam_body, 0.4); - // clamping a solid body part. - BodyRegionByParticle beam_base(beam_body, makeShared(createBeamConstrainShape())); - SimpleDynamics> constraint_beam_base(beam_base); - //----------------------------------------------------------------------------- - //outputs - //----------------------------------------------------------------------------- - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_beam_states(io_environment, system.real_bodies_); - RegressionTestEnsembleAverage> - write_beam_tip_displacement("Position", io_environment, beam_observer_contact); - RegressionTestDynamicTimeWarping>> - write_water_mechanical_energy(io_environment, beam_body, gravity_ptr); - //---------------------------------------------------------------------- - // Setup computing and initial conditions. - //---------------------------------------------------------------------- - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); - beam_initial_velocity.exec(); - correcttion_matrix.exec(); - //---------------------------------------------------------------------- - // Setup computing time-step controls. - //---------------------------------------------------------------------- - int ite = 0; - Real T0 = 1.0; - Real End_Time = T0; - Real D_Time = End_Time / 100; /**< Time period for data observing */ - TickCount t1 = TickCount::now(); - TimeInterval interval; - //----------------------------------------------------------------------------- - //from here the time stepping begines - //----------------------------------------------------------------------------- - write_beam_states.writeToFile(0); - write_beam_tip_displacement.writeToFile(0); - write_water_mechanical_energy.writeToFile(0); - //computation loop starts - while (GlobalStaticVariables::physical_time_ < End_Time) - { - Real integration_time = 0.0; - while (integration_time < D_Time) - { - Real relaxation_time = 0.0; - Real advection_dt = fluid_advection_time_step.exec(); + /** initial condition */ + SimpleDynamics beam_initial_velocity(beam_body); + SharedPtr gravity_ptr = makeShared(Vecd(0.0, -gravity_g)); + Dynamics1Level beam_pressure_relaxation(beam_body_inner); + Dynamics1Level beam_density_relaxation(beam_body_inner); + InteractionDynamics + beam_shear_acceleration_angular_conservative(beam_body_inner); + InteractionWithUpdate correction_matrix(beam_body_inner); + Dynamics1Level beam_shear_stress_relaxation(beam_body_inner); + // for dual timestep + ReduceDynamics fluid_advection_time_step(beam_body, U_ref, 0.2); + ReduceDynamics fluid_acoustic_time_step(beam_body, 0.4); + // clamping a solid body part. + BodyRegionByParticle beam_base(beam_body, makeShared(createBeamConstrainShape())); + SimpleDynamics> constraint_beam_base(beam_base); + //----------------------------------------------------------------------------- + // outputs + //----------------------------------------------------------------------------- + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_beam_states(io_environment, sph_system.real_bodies_); + RegressionTestEnsembleAverage> + write_beam_tip_displacement("Position", io_environment, beam_observer_contact); + RegressionTestDynamicTimeWarping>> + write_water_mechanical_energy(io_environment, beam_body, gravity_ptr); + //---------------------------------------------------------------------- + // Setup computing and initial conditions. + //---------------------------------------------------------------------- + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); + beam_initial_velocity.exec(); + correction_matrix.exec(); + //---------------------------------------------------------------------- + // Setup computing time-step controls. + //---------------------------------------------------------------------- + int ite = 0; + Real T0 = 1.0; + Real End_Time = T0; + Real D_Time = End_Time / 100; /**< Time period for data observing */ + TickCount t1 = TickCount::now(); + TimeInterval interval; + //----------------------------------------------------------------------------- + // from here the time stepping begins + //----------------------------------------------------------------------------- + write_beam_states.writeToFile(0); + write_beam_tip_displacement.writeToFile(0); + write_water_mechanical_energy.writeToFile(0); + // computation loop starts + while (GlobalStaticVariables::physical_time_ < End_Time) + { + Real integration_time = 0.0; + while (integration_time < D_Time) + { + Real relaxation_time = 0.0; + Real advection_dt = fluid_advection_time_step.exec(); - while (relaxation_time < advection_dt) - { - Real acoustic_dt = fluid_acoustic_time_step.exec(); - beam_shear_stress_relaxation.exec(acoustic_dt); - beam_pressure_relaxation.exec(acoustic_dt); - constraint_beam_base.exec(); - beam_density_relaxation.exec(acoustic_dt); - //shear acceleration with angular conservative - beam_shear_acceleration_angular_conservative.exec(acoustic_dt); - ite++; - relaxation_time += acoustic_dt; - integration_time += acoustic_dt; - GlobalStaticVariables::physical_time_ += acoustic_dt; - if (ite % 500 == 0) - { - std::cout << "N=" << ite << " Time: " - << GlobalStaticVariables::physical_time_ << " advection_dt: " - << advection_dt << " acoustic_dt: " - << acoustic_dt << "\n"; - } - } - beam_body.updateCellLinkedList(); - beam_body_inner.updateConfiguration(); - correcttion_matrix.exec(); - } - write_beam_tip_displacement.writeToFile(ite); - write_water_mechanical_energy.writeToFile(ite); - TickCount t2 = TickCount::now(); - write_beam_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; + while (relaxation_time < advection_dt) + { + Real acoustic_dt = fluid_acoustic_time_step.exec(); + beam_shear_stress_relaxation.exec(acoustic_dt); + beam_pressure_relaxation.exec(acoustic_dt); + constraint_beam_base.exec(); + beam_density_relaxation.exec(acoustic_dt); + // shear acceleration with angular conservative + beam_shear_acceleration_angular_conservative.exec(acoustic_dt); + ite++; + relaxation_time += acoustic_dt; + integration_time += acoustic_dt; + GlobalStaticVariables::physical_time_ += acoustic_dt; + if (ite % 500 == 0) + { + std::cout << "N=" << ite << " Time: " + << GlobalStaticVariables::physical_time_ << " advection_dt: " + << advection_dt << " acoustic_dt: " + << acoustic_dt << "\n"; + } + } + beam_body.updateCellLinkedList(); + beam_body_inner.updateConfiguration(); + correction_matrix.exec(); + } + write_beam_tip_displacement.writeToFile(ite); + write_water_mechanical_energy.writeToFile(ite); + TickCount t2 = TickCount::now(); + write_beam_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; - //system.generate_regression_data_ = true; - if (system.generate_regression_data_) + // system.GenerateRegressionData() = true; + if (sph_system.GenerateRegressionData()) { write_beam_tip_displacement.generateDataBase(Vec2d(1.0e-2, 1.0e-2), Vec2d(1.0e-2, 1.0e-2)); } @@ -236,5 +237,7 @@ int main(int ac, char* av[]) { write_beam_tip_displacement.testResult(); } - return 0; + + + return 0; } \ No newline at end of file diff --git a/tests/user_examples/test_2d_water_entry_exit/CMakeLists.txt b/tests/user_examples/test_2d_water_entry_exit/CMakeLists.txt index 97eef33f2b..b00933fc10 100644 --- a/tests/user_examples/test_2d_water_entry_exit/CMakeLists.txt +++ b/tests/user_examples/test_2d_water_entry_exit/CMakeLists.txt @@ -2,11 +2,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # mai set(CMAKE_VERBOSE_MAKEFILE on) -STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ) +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") @@ -17,22 +15,14 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ DESTINATION ${BUILD_INPUT_PATH}) aux_source_directory(. DIR_SRCS) -ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} ) - -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif() +ADD_EXECUTABLE(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS}) + +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) set_tests_properties(${PROJECT_NAME} PROPERTIES LABELS "spatial_temporal_identification") set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") target_link_libraries(${PROJECT_NAME} extra_sources_2d) - diff --git a/tests/user_examples/test_2d_water_entry_exit/regression_test_tool/regression_test_tool.py b/tests/user_examples/test_2d_water_entry_exit/regression_test_tool/regression_test_tool.py index 8f3d795957..bedffb1c37 100644 --- a/tests/user_examples/test_2d_water_entry_exit/regression_test_tool/regression_test_tool.py +++ b/tests/user_examples/test_2d_water_entry_exit/regression_test_tool/regression_test_tool.py @@ -24,7 +24,8 @@ while True: print("Now start a new run......") - sphinxsys.run_case() + sphinxsys.run_particle_relaxation() + sphinxsys.run_case_with_reload() number_of_run_times += 1 converged = sphinxsys.read_dat_file() converged_1 = sphinxsys_1.read_dat_file() diff --git a/tests/user_examples/test_2d_water_entry_exit/run_test.sh b/tests/user_examples/test_2d_water_entry_exit/run_test.sh deleted file mode 100644 index bf83adea29..0000000000 --- a/tests/user_examples/test_2d_water_entry_exit/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_2d_water_entry_exit --r=true -./test_2d_water_entry_exit --r=false --i=true diff --git a/tests/user_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp b/tests/user_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp index aad9683e6e..9a89aa81c7 100644 --- a/tests/user_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp +++ b/tests/user_examples/test_2d_water_entry_exit/test_2d_water_entry_exit.cpp @@ -344,10 +344,10 @@ int main(int ac, char *av[]) SimTK::SimbodyMatterSubsystem matter(MBsystem); /** The forces of the MBsystem.*/ SimTK::GeneralForceSubsystem forces(MBsystem); - /** Mass proeprties of the fixed spot. */ + /** Mass properties of the fixed spot. */ SimTK::Body::Rigid fixed_spot_info(SimTK::MassProperties(1.0, SimTKVec3(0), SimTK::UnitInertia(1))); SolidBodyPartForSimbody cylinder_constraint_area(cylinder, makeShared(createSimbodyConstrainShape(cylinder), "cylinder")); - /** Mass properties of the consrained spot. */ + /** Mass properties of the constrained spot. */ SimTK::Body::Rigid tethered_spot_info(*cylinder_constraint_area.body_part_mass_properties_); /** Mobility of the fixed spot. */ SimTK::MobilizedBody::Weld fixed_spot(matter.Ground(), SimTK::Transform(SimTKVec3(tethering_point[0], tethering_point[1], 0.0)), @@ -365,7 +365,7 @@ int main(int ac, char *av[]) tethered_spot_info.addDecoration(SimTK::Transform(), SimTK::DecorativeSphere(0.4)); SimTK::State state = MBsystem.realizeTopology(); - /** Time steping method for multibody system.*/ + /** Time stepping method for multibody system.*/ SimTK::RungeKuttaMersonIntegrator integ(MBsystem); integ.setAccuracy(1e-3); integ.setAllowInterpolation(false); @@ -526,7 +526,7 @@ int main(int ac, char *av[]) std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " << interval_updating_configuration.seconds() << "\n"; - if (sph_system.generate_regression_data_) + if (sph_system.GenerateRegressionData()) { write_cylinder_displacement.generateDataBase(1.0e-3); } @@ -535,5 +535,6 @@ int main(int ac, char *av[]) write_cylinder_displacement.testResult(); } + return 0; }; diff --git a/tests/user_examples/test_3d_oscillating_plate_UL/CMakeLists.txt b/tests/user_examples/test_3d_oscillating_plate_UL/CMakeLists.txt index 0ee37144e2..6ff1e4e81e 100644 --- a/tests/user_examples/test_3d_oscillating_plate_UL/CMakeLists.txt +++ b/tests/user_examples/test_3d_oscillating_plate_UL/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} extra_sources_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/user_examples/test_3d_oscillating_plate_UL/oscillating_plate_UL.cpp b/tests/user_examples/test_3d_oscillating_plate_UL/oscillating_plate_UL.cpp index 96bf120ffd..45154cb99c 100644 --- a/tests/user_examples/test_3d_oscillating_plate_UL/oscillating_plate_UL.cpp +++ b/tests/user_examples/test_3d_oscillating_plate_UL/oscillating_plate_UL.cpp @@ -1,255 +1,253 @@ /** -* @file dw_3d_volum_oscillating_plate.cpp -* @brief This is the test case for the hourglass manuscript. -* @details We consider vibration deformation of a square plate under initial vertical velocity field. -* @author Dong Wu, Chi Zhang and Xiangyu Hu -* @version 0.1 + * @file oscillating_plate_UL.cpp + * @brief This is the test case for the hourglass manuscript. + * @details We consider vibration deformation of a square plate under initial vertical velocity field. + * @author Dong Wu, Chi Zhang and Xiangyu Hu + * @version 0.1 */ -#include "sphinxsys.h" #include "all_continuum.h" +#include "sphinxsys.h" using namespace SPH; /** * @brief Basic geometry parameters and numerical setup. */ -Real PL = 0.4; /** Length of the square plate. */ -Real PH = 0.4; /** Width of the square plate. */ -Real PT = 0.01; /** Thickness of the square plate. */ -int particle_number = 3; /** Particle number in the direction of the thickness. */ -Real particle_spacing_ref = PT / (Real)particle_number; /** Initial reference particle spacing. */ -int particle_nuber_PL = PL / particle_spacing_ref; -int particle_nuber_PH = PH / particle_spacing_ref; +Real PL = 0.4; /** Length of the square plate. */ +Real PH = 0.4; /** Width of the square plate. */ +Real PT = 0.01; /** Thickness of the square plate. */ +int particle_number = 3; /** Particle number in the direction of the thickness. */ +Real particle_spacing_ref = PT / (Real)particle_number; /** Initial reference particle spacing. */ +int particle_number_PL = PL / particle_spacing_ref; +int particle_number_PH = PH / particle_spacing_ref; int BWD = 1; -Real BW = particle_spacing_ref * (Real)BWD; /** Boundary width, determined by specific layer of boundary particles. */ +Real BW = particle_spacing_ref * (Real)BWD; /** Boundary width, determined by specific layer of boundary particles. */ /** Domain bounds of the system. */ BoundingBox system_domain_bounds(Vec3d(-BW, -BW, -PT / 2), Vec3d(PL + BW, PH + BW, PT / 2)); // Observer location -StdVec observation_location = { Vecd(0.5 * PL, 0.5 * PH, 0.0), Vecd(-BW, -BW, 0.0) }; +StdVec observation_location = {Vecd(0.5 * PL, 0.5 * PH, 0.0), Vecd(-BW, -BW, 0.0)}; /** For material properties of the solid. */ -Real rho0_s = 1000.0; /** Normalized density. */ -Real Youngs_modulus = 100.0e6; /** Normalized Youngs Modulus. */ -Real poisson = 0.3; /** Poisson ratio. */ +Real rho0_s = 1000.0; /** Normalized density. */ +Real Youngs_modulus = 100.0e6; /** Normalized Youngs Modulus. */ +Real poisson = 0.3; /** Poisson ratio. */ Real c0 = sqrt(Youngs_modulus / (3 * (1 - 2 * poisson) * rho0_s)); Real gravity_g = 0.0; Real governing_vibration_integer_x = 2.0; Real governing_vibration_integer_y = 2.0; -Real U_ref = 1.0; //Maximum velocity +Real U_ref = 1.0; // Maximum velocity /** Define application dependent particle generator for thin structure. */ class PlateParticleGenerator : public ParticleGenerator { -public: - explicit PlateParticleGenerator(SPHBody& sph_body) : ParticleGenerator(sph_body) {}; - virtual void initializeGeometricVariables() override - { - for (int k = 0; k < particle_number; k++) - { - for (int i = 0; i < particle_nuber_PL + 2 * BWD; i++) - { - for (int j = 0; j < particle_nuber_PH + 2 * BWD; j++) - { - Real x = particle_spacing_ref * i - BW + particle_spacing_ref * 0.5; - Real y = particle_spacing_ref * j - BW + particle_spacing_ref * 0.5; - Real z = particle_spacing_ref * (k - ((particle_number - 1.0) / 2.0)); - initializePositionAndVolumetricMeasure(Vecd(x, y, z), - particle_spacing_ref * particle_spacing_ref * particle_spacing_ref); - } - } - } - } + public: + explicit PlateParticleGenerator(SPHBody &sph_body) : ParticleGenerator(sph_body){}; + virtual void initializeGeometricVariables() override + { + for (int k = 0; k < particle_number; k++) + { + for (int i = 0; i < particle_number_PL + 2 * BWD; i++) + { + for (int j = 0; j < particle_number_PH + 2 * BWD; j++) + { + Real x = particle_spacing_ref * i - BW + particle_spacing_ref * 0.5; + Real y = particle_spacing_ref * j - BW + particle_spacing_ref * 0.5; + Real z = particle_spacing_ref * (k - ((particle_number - 1.0) / 2.0)); + initializePositionAndVolumetricMeasure(Vecd(x, y, z), + particle_spacing_ref * particle_spacing_ref * particle_spacing_ref); + } + } + } + } }; /** Define the boundary geometry. */ class BoundaryGeometry : public BodyPartByParticle { -public: - BoundaryGeometry(SPHBody& body, const std::string& body_part_name) - : BodyPartByParticle(body, body_part_name) - { - TaggingParticleMethod tagging_particle_method = std::bind(&BoundaryGeometry::tagManually, this, _1); - tagParticles(tagging_particle_method); - }; - virtual ~BoundaryGeometry() {}; - -private: - void tagManually(size_t index_i) - { - if ((base_particles_.pos_[index_i][2] < 0.5 * particle_spacing_ref) - & (base_particles_.pos_[index_i][2] > -0.5 * particle_spacing_ref) - & (base_particles_.pos_[index_i][0] < 0.0 || base_particles_.pos_[index_i][0] > PL - || base_particles_.pos_[index_i][1] < 0.0 || base_particles_.pos_[index_i][1] > PH)) - { - body_part_particles_.push_back(index_i); - } - }; + public: + BoundaryGeometry(SPHBody &body, const std::string &body_part_name) + : BodyPartByParticle(body, body_part_name) + { + TaggingParticleMethod tagging_particle_method = std::bind(&BoundaryGeometry::tagManually, this, _1); + tagParticles(tagging_particle_method); + }; + virtual ~BoundaryGeometry(){}; + + private: + void tagManually(size_t index_i) + { + if ((base_particles_.pos_[index_i][2] < 0.5 * particle_spacing_ref) && + (base_particles_.pos_[index_i][2] > -0.5 * particle_spacing_ref) && + (base_particles_.pos_[index_i][0] < 0.0 || base_particles_.pos_[index_i][0] > PL || base_particles_.pos_[index_i][1] < 0.0 || base_particles_.pos_[index_i][1] > PH)) + { + body_part_particles_.push_back(index_i); + } + }; }; /** Define the initial condition. */ class BeamInitialCondition - : public fluid_dynamics::FluidInitialCondition + : public fluid_dynamics::FluidInitialCondition { -public: - explicit BeamInitialCondition(SPHBody& sph_body) - : fluid_dynamics::FluidInitialCondition(sph_body) {}; - - void update(size_t index_i, Real dt) - { - /** initial velocity profile */ - vel_[index_i][2] = sin(governing_vibration_integer_x * Pi * pos_[index_i][0] / PL) - * sin(governing_vibration_integer_y * Pi * pos_[index_i][1] / PH); - }; + public: + explicit BeamInitialCondition(SPHBody &sph_body) + : fluid_dynamics::FluidInitialCondition(sph_body){}; + + void update(size_t index_i, Real dt) + { + /** initial velocity profile */ + vel_[index_i][2] = sin(governing_vibration_integer_x * Pi * pos_[index_i][0] / PL) * sin(governing_vibration_integer_y * Pi * pos_[index_i][1] / PH); + }; }; /** * The main program */ -int main() +int main(int ac, char *av[]) { - /** Setup the system. */ - SPHSystem system(system_domain_bounds, particle_spacing_ref); - /** Tag for computation from restart files. 0: start with initial condition. */ - system.setRestartStep(0); - - /** create a plate body. */ - SolidBody plate_body(system, makeShared("PlateBody")); - plate_body.defineParticlesAndMaterial(rho0_s, c0, Youngs_modulus, poisson); - plate_body.generateParticles(); - //plate_body.addBodyStateForRecording("VolumetricStress"); - plate_body.addBodyStateForRecording("VonMisesStress"); - plate_body.addBodyStateForRecording("VonMisesStrain"); - plate_body.addBodyStateForRecording("Pressure"); - plate_body.addBodyStateForRecording("Density"); - - /** Define Observer. */ - ObserverBody plate_observer(system, "PlateObserver"); - plate_observer.defineParticlesAndMaterial(); - plate_observer.generateParticles(observation_location); - - /** Set body contact map - * The contact map gives the data conntections between the bodies - * basically the the range of bodies to build neighbor particle lists - */ - InnerRelation plate_body_inner(plate_body); - ContactRelation plate_observer_contact(plate_observer, { &plate_body }); - /** - * This section define all numerical methods will be used in this case. - */ - SimpleDynamics initial_velocity(plate_body); - /** Time step size calculation. */ - ReduceDynamics fluid_advection_time_step(plate_body, U_ref, 0.2); - ReduceDynamics fluid_acoustic_time_step(plate_body, 0.4); - /** stress relaxation. */ - Dynamics1Level plate_pressure_relaxation(plate_body_inner); - Dynamics1Level plate_density_relaxation(plate_body_inner); - InteractionDynamics - plate_shear_acceleration_angular_conservative(plate_body_inner); - /** Corrected configuration. */ - InteractionWithUpdate corrected_configuration(plate_body_inner); - Dynamics1Level plate_shear_stress_relaxation(plate_body_inner); - /** Constrain the Boundary. */ - BoundaryGeometry boundary_geometry(plate_body, "BoundaryGeometry"); - SimpleDynamics constrain_holder(boundary_geometry, Vecd(1.0, 1.0, 0.0)); - SimpleDynamics - constrain_mass_center(plate_body, Vecd(1.0, 1.0, 0.0)); - /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); - RestartIO restart_io(io_environment, system.real_bodies_); - // ObservedQuantityRecording - // write_plate_displacement("Position", io_environment, plate_observer_contact); - RegressionTestEnsembleAverage> - write_plate_displacement("Position", io_environment, plate_observer_contact); - RegressionTestDynamicTimeWarping>> - write_kinetic_energy(io_environment, plate_body); - - - /** Apply initial condition. */ - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); - initial_velocity.exec(); - constrain_holder.exec(); - corrected_configuration.exec(); - - /** - * @brief The time stepping starts here. - */ - if (system.RestartStep() != 0) - { - GlobalStaticVariables::physical_time_ = restart_io.readRestartFiles(system.RestartStep()); - } - GlobalStaticVariables::physical_time_ = 0.0; - /** first output. */ - write_states.writeToFile(0); - write_plate_displacement.writeToFile(0); - write_kinetic_energy.writeToFile(0); - //write_elastic_strain_energy.writeToFile(0); - - /** Setup physical parameters. */ - size_t number_of_iterations = system.RestartStep(); - int screen_output_interval = 500; - int restart_output_interval = screen_output_interval * 10; - Real end_time = 0.02; - Real output_period = end_time / 50.0; - /** Statistics for computing time. */ - TickCount t1 = TickCount::now(); - TimeInterval interval; - /** - * Main loop - */ - while (GlobalStaticVariables::physical_time_ < end_time) - { - Real integration_time = 0.0; - while (integration_time < output_period) - { - Real relaxation_time = 0.0; - Real advection_dt = fluid_advection_time_step.exec(); - - while (relaxation_time < advection_dt) - { - Real acoustic_dt = fluid_acoustic_time_step.exec(); - plate_shear_stress_relaxation.exec(acoustic_dt); - plate_pressure_relaxation.exec(acoustic_dt); - constrain_holder.exec(acoustic_dt); - plate_density_relaxation.exec(acoustic_dt); - //shear acceleration with angular conservative - plate_shear_acceleration_angular_conservative.exec(acoustic_dt); - number_of_iterations++; - relaxation_time += acoustic_dt; - integration_time += acoustic_dt; - GlobalStaticVariables::physical_time_ += acoustic_dt; - if (number_of_iterations % screen_output_interval == 0) - { - std::cout << "N=" << number_of_iterations << " Time: " - << GlobalStaticVariables::physical_time_ << " advection_dt: " - << advection_dt << " acoustic_dt: " - << acoustic_dt << "\n"; - if (number_of_iterations % restart_output_interval == 0 && number_of_iterations != system.RestartStep()) - restart_io.writeToFile(Real(number_of_iterations)); - } - } - plate_body.updateCellLinkedList(); - plate_body_inner.updateConfiguration(); - corrected_configuration.exec(); //put correct matrix in the end - } - write_plate_displacement.writeToFile(number_of_iterations); - write_kinetic_energy.writeToFile(number_of_iterations); - TickCount t2 = TickCount::now(); - write_states.writeToFile(); - TickCount t3 = TickCount::now(); - interval += t3 - t2; - } - - TickCount t4 = TickCount::now(); - TickCount::interval_t tt; - tt = t4 - t1 - interval; - std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; - - system.generate_regression_data_ = false; - if (system.generate_regression_data_) - { - write_kinetic_energy.generateDataBase(1.0e-3); - } - else - { - write_kinetic_energy.testResult(); - } -} \ No newline at end of file + /** Setup the system. */ + SPHSystem sph_system(system_domain_bounds, particle_spacing_ref); + sph_system.handleCommandlineOptions(ac, av); + + /** create a plate body. */ + SolidBody plate_body(sph_system, makeShared("PlateBody")); + plate_body.defineParticlesAndMaterial(rho0_s, c0, Youngs_modulus, poisson); + plate_body.generateParticles(); + // plate_body.addBodyStateForRecording("VolumetricStress"); + plate_body.addBodyStateForRecording("VonMisesStress"); + plate_body.addBodyStateForRecording("VonMisesStrain"); + plate_body.addBodyStateForRecording("Pressure"); + plate_body.addBodyStateForRecording("Density"); + + /** Define Observer. */ + ObserverBody plate_observer(sph_system, "PlateObserver"); + plate_observer.defineParticlesAndMaterial(); + plate_observer.generateParticles(observation_location); + + /** 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(plate_body); + ContactRelation plate_observer_contact(plate_observer, {&plate_body}); + /** + * This section define all numerical methods will be used in this case. + */ + SimpleDynamics initial_velocity(plate_body); + /** Time step size calculation. */ + ReduceDynamics fluid_advection_time_step(plate_body, U_ref, 0.2); + ReduceDynamics fluid_acoustic_time_step(plate_body, 0.4); + /** stress relaxation. */ + Dynamics1Level plate_pressure_relaxation(plate_body_inner); + Dynamics1Level plate_density_relaxation(plate_body_inner); + InteractionDynamics + plate_shear_acceleration_angular_conservative(plate_body_inner); + /** Corrected configuration. */ + InteractionWithUpdate corrected_configuration(plate_body_inner); + Dynamics1Level plate_shear_stress_relaxation(plate_body_inner); + /** Constrain the Boundary. */ + BoundaryGeometry boundary_geometry(plate_body, "BoundaryGeometry"); + SimpleDynamics constrain_holder(boundary_geometry, Vecd(1.0, 1.0, 0.0)); + SimpleDynamics + constrain_mass_center(plate_body, Vecd(1.0, 1.0, 0.0)); + /** Output */ + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); + RestartIO restart_io(io_environment, sph_system.real_bodies_); + // ObservedQuantityRecording + // write_plate_displacement("Position", io_environment, plate_observer_contact); + RegressionTestEnsembleAverage> + write_plate_displacement("Position", io_environment, plate_observer_contact); + RegressionTestDynamicTimeWarping>> + write_kinetic_energy(io_environment, plate_body); + + /** Apply initial condition. */ + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); + initial_velocity.exec(); + constrain_holder.exec(); + corrected_configuration.exec(); + + /** + * @brief The time stepping starts here. + */ + if (sph_system.RestartStep() != 0) + { + GlobalStaticVariables::physical_time_ = restart_io.readRestartFiles(sph_system.RestartStep()); + } + GlobalStaticVariables::physical_time_ = 0.0; + /** first output. */ + write_states.writeToFile(0); + write_plate_displacement.writeToFile(0); + write_kinetic_energy.writeToFile(0); + // write_elastic_strain_energy.writeToFile(0); + + /** Setup physical parameters. */ + size_t number_of_iterations = sph_system.RestartStep(); + int screen_output_interval = 500; + int restart_output_interval = screen_output_interval * 10; + Real end_time = 0.02; + Real output_period = end_time / 50.0; + /** Statistics for computing time. */ + TickCount t1 = TickCount::now(); + TimeInterval interval; + /** + * Main loop + */ + while (GlobalStaticVariables::physical_time_ < end_time) + { + Real integration_time = 0.0; + while (integration_time < output_period) + { + Real relaxation_time = 0.0; + Real advection_dt = fluid_advection_time_step.exec(); + + while (relaxation_time < advection_dt) + { + Real acoustic_dt = fluid_acoustic_time_step.exec(); + plate_shear_stress_relaxation.exec(acoustic_dt); + plate_pressure_relaxation.exec(acoustic_dt); + constrain_holder.exec(acoustic_dt); + plate_density_relaxation.exec(acoustic_dt); + // shear acceleration with angular conservative + plate_shear_acceleration_angular_conservative.exec(acoustic_dt); + number_of_iterations++; + relaxation_time += acoustic_dt; + integration_time += acoustic_dt; + GlobalStaticVariables::physical_time_ += acoustic_dt; + if (number_of_iterations % screen_output_interval == 0) + { + std::cout << "N=" << number_of_iterations << " Time: " + << GlobalStaticVariables::physical_time_ << " advection_dt: " + << advection_dt << " acoustic_dt: " + << acoustic_dt << "\n"; + if (number_of_iterations % restart_output_interval == 0 && number_of_iterations != sph_system.RestartStep()) + restart_io.writeToFile(Real(number_of_iterations)); + } + } + plate_body.updateCellLinkedList(); + plate_body_inner.updateConfiguration(); + corrected_configuration.exec(); // put correct matrix in the end + } + write_plate_displacement.writeToFile(number_of_iterations); + write_kinetic_energy.writeToFile(number_of_iterations); + TickCount t2 = TickCount::now(); + write_states.writeToFile(); + TickCount t3 = TickCount::now(); + interval += t3 - t2; + } + + TickCount t4 = TickCount::now(); + TickCount::interval_t tt; + tt = t4 - t1 - interval; + std::cout << "Total wall time for computation: " << tt.seconds() << " seconds." << std::endl; + + if (sph_system.GenerateRegressionData()) + { + write_kinetic_energy.generateDataBase(1.0e-3); + } + else + { + write_kinetic_energy.testResult(); + } + + + return 0; +} diff --git a/tests/user_examples/test_3d_passive_cantilever_LG/CMakeLists.txt b/tests/user_examples/test_3d_passive_cantilever_LG/CMakeLists.txt index b3eef14df9..23ebe87350 100644 --- a/tests/user_examples/test_3d_passive_cantilever_LG/CMakeLists.txt +++ b/tests/user_examples/test_3d_passive_cantilever_LG/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) @@ -17,5 +17,5 @@ target_link_libraries(${PROJECT_NAME} sphinxsys_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file + COMMAND ${PROJECT_NAME} --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/tests/user_examples/test_3d_passive_cantilever_LG/passive_cantilever_LG.cpp b/tests/user_examples/test_3d_passive_cantilever_LG/passive_cantilever_LG.cpp index 9e99a3ac17..8859587568 100644 --- a/tests/user_examples/test_3d_passive_cantilever_LG/passive_cantilever_LG.cpp +++ b/tests/user_examples/test_3d_passive_cantilever_LG/passive_cantilever_LG.cpp @@ -67,19 +67,20 @@ class CantileverInitialCondition /** * The main program */ -int main() +int main(int ac, char *av[]) { /** Setup the system. Please the make sure the global domain bounds are correctly defined. */ - SPHSystem system(system_domain_bounds, resolution_ref); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.handleCommandlineOptions(ac, av); /** create a Cantilever body, corresponding material, particles and reaction model. */ - SolidBody cantilever_body(system, makeShared("CantileverBody")); + SolidBody cantilever_body(sph_system, makeShared("CantileverBody")); cantilever_body.defineAdaptationRatios(1.3, 1.0); cantilever_body.sph_adaptation_->resetKernel>(20); cantilever_body.defineParticlesAndMaterial< ElasticSolidParticles, Muscle>(rho0_s, bulk_modulus, fiber_direction, sheet_direction, a0, b0); cantilever_body.generateParticles(); /** Define Observer. */ - ObserverBody cantilever_observer(system, "CantileverObserver"); + ObserverBody cantilever_observer(sph_system, "CantileverObserver"); cantilever_observer.generateParticles(observation_location); /** topology */ @@ -104,8 +105,8 @@ int main() makeShared>(Transform(translation_holder), halfsize_holder, "Holder")); SimpleDynamics constraint_holder(holder); /** Output */ - IOEnvironment io_environment(system); - BodyStatesRecordingToVtp write_states(io_environment, system.real_bodies_); + IOEnvironment io_environment(sph_system); + BodyStatesRecordingToVtp write_states(io_environment, sph_system.real_bodies_); RegressionTestDynamicTimeWarping> write_displacement("Position", io_environment, cantilever_observer_contact); /** @@ -113,8 +114,8 @@ int main() * Set the starting time. */ GlobalStaticVariables::physical_time_ = 0.0; - system.initializeSystemCellLinkedLists(); - system.initializeSystemConfigurations(); + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); /** apply initial condition */ initialization.exec(); corrected_configuration.exec(); @@ -165,5 +166,6 @@ int main() write_displacement.testResult(); + return 0; } diff --git a/tests/user_examples/test_3d_repose_angle/CMakeLists.txt b/tests/user_examples/test_3d_repose_angle/CMakeLists.txt index fb50cb12cf..79ed1a178e 100644 --- a/tests/user_examples/test_3d_repose_angle/CMakeLists.txt +++ b/tests/user_examples/test_3d_repose_angle/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload") file(MAKE_DIRECTORY ${BUILD_INPUT_PATH}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/ - DESTINATION ${BUILD_INPUT_PATH}) + DESTINATION ${BUILD_INPUT_PATH}) add_executable(${PROJECT_NAME}) aux_source_directory(. DIR_SRCS) @@ -16,14 +16,7 @@ target_sources(${PROJECT_NAME} PRIVATE ${DIR_SRCS}) target_link_libraries(${PROJECT_NAME} extra_sources_3d) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -else() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - DESTINATION ${EXECUTABLE_OUTPUT_PATH}) - add_test(NAME ${PROJECT_NAME} COMMAND bash ${EXECUTABLE_OUTPUT_PATH}/run_test.sh - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -endif() \ No newline at end of file +add_test(NAME ${PROJECT_NAME}_particle_relaxation COMMAND ${PROJECT_NAME} --r=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --r=false --i=true --state_recording=${TEST_STATE_RECORDING} + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) diff --git a/tests/user_examples/test_3d_repose_angle/repose_angle.cpp b/tests/user_examples/test_3d_repose_angle/repose_angle.cpp index 21901e4d99..ef5b9703fb 100644 --- a/tests/user_examples/test_3d_repose_angle/repose_angle.cpp +++ b/tests/user_examples/test_3d_repose_angle/repose_angle.cpp @@ -1,19 +1,19 @@ -#include "sphinxsys.h" // SPHinXsys Library. #include "all_continuum.h" +#include "sphinxsys.h" // SPHinXsys Library. using namespace SPH; // general parameters for geometry -Real radius = 0.1; // liquid length -Real height = 0.1; // liquid height -Real resolution_ref = radius / 10; // particle spacing -Real BW = resolution_ref * 4; // boundary width -Real DL = 2 * radius*(1+1.24*height/radius) + 0.1; // tank length -Real DH = height + 0.02; // tank height -Real DW = DL; // tank width +Real radius = 0.1; // liquid length +Real height = 0.1; // liquid height +Real resolution_ref = radius / 10; // particle spacing +Real BW = resolution_ref * 4; // boundary width +Real DL = 2 * radius * (1 + 1.24 * height / radius) + 0.1; // tank length +Real DH = height + 0.02; // tank height +Real DW = DL; // tank width // for material properties -Real rho0_s = 2600; /**< Reference density of soil. */ -Real gravity_g = 9.8; /**< Gravity force of soil. */ -Real Youngs_modulus = 5.98e6; //reference Youngs modulus -Real poisson = 0.3; //Poisson ratio +Real rho0_s = 2600; /**< Reference density of soil. */ +Real gravity_g = 9.8; /**< Gravity force of soil. */ +Real Youngs_modulus = 5.98e6; // reference Youngs modulus +Real poisson = 0.3; // Poisson ratio Real c_s = sqrt(Youngs_modulus / (rho0_s * 3 * (1 - 2 * poisson))); Real friction_angle = 30 * Pi / 180; /** Define the soil body. */ @@ -21,266 +21,269 @@ Real inner_circle_radius = radius; int resolution(20); class SoilBlock : public ComplexShape { -public: - explicit SoilBlock(const std::string& shape_name) : ComplexShape(shape_name) - { - Vecd translation_column(DL / 2, 0.5 * height, DW / 2); - add(SimTK::UnitVec3(0, 1.0, 0), inner_circle_radius, - 0.5 * height, resolution, translation_column); - } + public: + explicit SoilBlock(const std::string &shape_name) : ComplexShape(shape_name) + { + Vecd translation_column(DL / 2, 0.5 * height, DW / 2); + add(SimTK::UnitVec3(0, 1.0, 0), inner_circle_radius, + 0.5 * height, resolution, translation_column); + } }; // define the static solid wall boundary shape class WallBoundary : public ComplexShape { -public: - explicit WallBoundary(const std::string &shape_name) : ComplexShape(shape_name) - { - Vecd outer_wall_halfsize = Vecd(0.5 * DL + BW, 0.5 * DH + BW, 0.5 * DW + BW); - Vecd outer_wall_translation = Vecd(-BW, -BW, -BW) + outer_wall_halfsize; - Vecd inner_wall_halfsize = Vecd(0.5 * DL, 0.5 * DH, 0.5 * DW); - Vecd inner_wall_translation = inner_wall_halfsize; - add>(Transform(outer_wall_translation), outer_wall_halfsize); - subtract>(Transform(inner_wall_translation), inner_wall_halfsize); - } + public: + explicit WallBoundary(const std::string &shape_name) : ComplexShape(shape_name) + { + Vecd outer_wall_halfsize = Vecd(0.5 * DL + BW, 0.5 * DH + BW, 0.5 * DW + BW); + Vecd outer_wall_translation = Vecd(-BW, -BW, -BW) + outer_wall_halfsize; + Vecd inner_wall_halfsize = Vecd(0.5 * DL, 0.5 * DH, 0.5 * DW); + Vecd inner_wall_translation = inner_wall_halfsize; + add>(Transform(outer_wall_translation), outer_wall_halfsize); + subtract>(Transform(inner_wall_translation), inner_wall_halfsize); + } }; //---------------------------------------------------------------------- -// application dependent initial condition +// application dependent initial condition //---------------------------------------------------------------------- class SoilInitialCondition : public continuum_dynamics::ContinuumInitialCondition { -public: - explicit SoilInitialCondition(RealBody& granular_column) - : continuum_dynamics::ContinuumInitialCondition(granular_column) {}; -protected: - void update(size_t index_i, Real dt) - { - /** initial stress */ - Real y = pos_[index_i][1]; - Real gama = 1 - sin(friction_angle); - Real stress_yy = -rho0_s * gravity_g * y; - stress_tensor_3D_[index_i](1, 1) = stress_yy; - stress_tensor_3D_[index_i](0, 0) = stress_yy * gama; - stress_tensor_3D_[index_i](2, 2) = stress_yy * gama; - }; + public: + explicit SoilInitialCondition(RealBody &granular_column) + : continuum_dynamics::ContinuumInitialCondition(granular_column){}; + + protected: + void update(size_t index_i, Real dt) + { + /** initial stress */ + Real y = pos_[index_i][1]; + Real gama = 1 - sin(friction_angle); + Real stress_yy = -rho0_s * gravity_g * y; + stress_tensor_3D_[index_i](1, 1) = stress_yy; + stress_tensor_3D_[index_i](0, 0) = stress_yy * gama; + stress_tensor_3D_[index_i](2, 2) = stress_yy * gama; + }; }; // the main program with commandline options int main(int ac, char *av[]) { - //---------------------------------------------------------------------- - // Build up an SPHSystem. - //---------------------------------------------------------------------- - BoundingBox system_domain_bounds(Vecd(-BW, -BW, -BW), Vecd(DL + BW, DH + BW, DW + BW)); - SPHSystem sph_system(system_domain_bounds, resolution_ref); - sph_system.setRunParticleRelaxation(false); - sph_system.setReloadParticles(true); - sph_system.handleCommandlineOptions(ac, av); - IOEnvironment io_environment(sph_system); - //---------------------------------------------------------------------- - // Creating bodies with corresponding materials and particles. - //---------------------------------------------------------------------- - RealBody soil_block(sph_system, makeShared("GranularBody")); - soil_block.defineBodyLevelSetShape()->writeLevelSet(io_environment); - soil_block.defineParticlesAndMaterial(rho0_s, c_s, Youngs_modulus, poisson, friction_angle); - (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) - ? soil_block.generateParticles(io_environment, soil_block.getName()) - : soil_block.generateParticles(); - soil_block.addBodyStateForRecording("Pressure"); - soil_block.addBodyStateForRecording("Density"); - soil_block.addBodyStateForRecording("VerticalStress"); - soil_block.addBodyStateForRecording("AccDeviatoricPlasticStrain"); + //---------------------------------------------------------------------- + // Build up an SPHSystem. + //---------------------------------------------------------------------- + BoundingBox system_domain_bounds(Vecd(-BW, -BW, -BW), Vecd(DL + BW, DH + BW, DW + BW)); + SPHSystem sph_system(system_domain_bounds, resolution_ref); + sph_system.setRunParticleRelaxation(false); + sph_system.setReloadParticles(true); + sph_system.handleCommandlineOptions(ac, av); + IOEnvironment io_environment(sph_system); + //---------------------------------------------------------------------- + // Creating bodies with corresponding materials and particles. + //---------------------------------------------------------------------- + RealBody soil_block(sph_system, makeShared("GranularBody")); + soil_block.defineBodyLevelSetShape()->writeLevelSet(io_environment); + soil_block.defineParticlesAndMaterial(rho0_s, c_s, Youngs_modulus, poisson, friction_angle); + (!sph_system.RunParticleRelaxation() && sph_system.ReloadParticles()) + ? soil_block.generateParticles(io_environment, soil_block.getName()) + : soil_block.generateParticles(); + soil_block.addBodyStateForRecording("Pressure"); + soil_block.addBodyStateForRecording("Density"); + soil_block.addBodyStateForRecording("VerticalStress"); + soil_block.addBodyStateForRecording("AccDeviatoricPlasticStrain"); + + SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); + wall_boundary.defineParticlesAndMaterial(); + wall_boundary.generateParticles(); + wall_boundary.addBodyStateForRecording("NormalDirection"); + //---------------------------------------------------------------------- + // Define body relation map. + // The contact map gives the topological connections between the bodies. + // Basically the the range of bodies to build neighbor particle lists. + //---------------------------------------------------------------------- + ComplexRelation soil_block_complex(soil_block, {&wall_boundary}); + BodyStatesRecordingToVtp body_states_recording(io_environment, sph_system.real_bodies_); + // run particle relaxation + if (sph_system.RunParticleRelaxation()) + { + /** + * @brief Methods used for particle relaxation. + */ + /** Random reset the insert body particle position. */ + SimpleDynamics random_column_particles(soil_block); + /** Write the body state to Vtp file. */ + BodyStatesRecordingToVtp write_column_to_vtp(io_environment, soil_block); + /** Write the particle reload files. */ + + ReloadParticleIO write_particle_reload_files(io_environment, soil_block); + /** A Physics relaxation step. */ + relax_dynamics::RelaxationStepInner relaxation_step_inner(soil_block_complex.getInnerRelation()); + /** + * @brief Particle relaxation starts here. + */ + random_column_particles.exec(0.25); + relaxation_step_inner.SurfaceBounding().exec(); + body_states_recording.writeToFile(0.0); - SolidBody wall_boundary(sph_system, makeShared("WallBoundary")); - wall_boundary.defineParticlesAndMaterial(); - wall_boundary.generateParticles(); - wall_boundary.addBodyStateForRecording("NormalDirection"); - //---------------------------------------------------------------------- - // Define body relation map. - // The contact map gives the topological connections between the bodies. - // Basically the the range of bodies to build neighbor particle lists. - //---------------------------------------------------------------------- - ComplexRelation soil_block_complex(soil_block, { &wall_boundary }); - BodyStatesRecordingToVtp body_states_recording(io_environment, sph_system.real_bodies_); - //run particle relaxation - if (sph_system.RunParticleRelaxation()) - { - /** - * @brief Methods used for particle relaxation. - */ - /** Random reset the insert body particle position. */ - SimpleDynamics random_column_particles(soil_block); - /** Write the body state to Vtp file. */ - BodyStatesRecordingToVtp write_column_to_vtp(io_environment, soil_block); - /** Write the particle reload files. */ + /** relax particles of the insert body. */ + int ite_p = 0; + while (ite_p < 1000) + { + relaxation_step_inner.exec(); + ite_p += 1; + if (ite_p % 200 == 0) + { + std::cout << std::fixed << std::setprecision(9) << "Relaxation steps for the column body N = " << ite_p << "\n"; + write_column_to_vtp.writeToFile(ite_p); + } + } + std::cout << "The physics relaxation process of cylinder body finish !" << std::endl; + /** Output results. */ + write_particle_reload_files.writeToFile(0.0); + return 0; + } + //---------------------------------------------------------------------- + // Define the numerical methods used in the simulation. + // Note that there may be data dependence on the sequence of constructions. + //---------------------------------------------------------------------- + SimpleDynamics soil_initial_condition(soil_block); + SharedPtr gravity_ptr = makeShared(Vec3d(0.0, -gravity_g, 0.0)); + SimpleDynamics wall_boundary_normal_direction(wall_boundary); + SimpleDynamics soil_step_initialization(soil_block, gravity_ptr); + ReduceDynamics soil_acoustic_time_step(soil_block, 0.1); + InteractionWithUpdate soil_density_by_summation(soil_block_complex); + InteractionDynamics stress_diffusion(soil_block_complex.getInnerRelation()); + Dynamics1Level granular_stress_relaxation_1st(soil_block_complex); + Dynamics1Level granular_stress_relaxation_2nd(soil_block_complex); + //---------------------------------------------------------------------- + // Define the methods for I/O operations, observations + // and regression tests of the simulation. + //---------------------------------------------------------------------- + RestartIO restart_io(io_environment, sph_system.real_bodies_); + RegressionTestDynamicTimeWarping>> + write_soil_mechanical_energy(io_environment, soil_block, gravity_ptr); + //---------------------------------------------------------------------- + // Prepare the simulation with cell linked list, configuration + // and case specified initial condition if necessary. + //---------------------------------------------------------------------- + sph_system.initializeSystemCellLinkedLists(); + sph_system.initializeSystemConfigurations(); + wall_boundary_normal_direction.exec(); + soil_initial_condition.exec(); + //---------------------------------------------------------------------- + // Load restart file if necessary. + //---------------------------------------------------------------------- + if (sph_system.RestartStep() != 0) + { + GlobalStaticVariables::physical_time_ = restart_io.readRestartFiles(sph_system.RestartStep()); + soil_block.updateCellLinkedList(); + soil_block_complex.updateConfiguration(); + } + //---------------------------------------------------------------------- + // Setup for time-stepping control + //---------------------------------------------------------------------- + size_t number_of_iterations = sph_system.RestartStep(); + int screen_output_interval = 500; + int observation_sample_interval = screen_output_interval * 2; + int restart_output_interval = screen_output_interval * 10; + Real End_Time = 0.5; /**< End time. */ + Real D_Time = End_Time / 25; /**< Time stamps for output of body states. */ + Real Dt = 0.1 * D_Time; + //---------------------------------------------------------------------- + // Statistics for CPU time + //---------------------------------------------------------------------- + TickCount t1 = TickCount::now(); + TimeInterval interval; + TimeInterval interval_computing_time_step; + TimeInterval interval_computing_soil_stress_relaxation; + TimeInterval interval_updating_configuration; + TickCount time_instance; + //---------------------------------------------------------------------- + // First output before the main loop. + //---------------------------------------------------------------------- + body_states_recording.writeToFile(); + write_soil_mechanical_energy.writeToFile(number_of_iterations); + //---------------------------------------------------------------------- + // Main loop starts here. + //---------------------------------------------------------------------- + while (GlobalStaticVariables::physical_time_ < End_Time) + { + Real integration_time = 0.0; + /** Integrate time (loop) until the next output time. */ + while (integration_time < D_Time) + { + /** outer loop for dual-time criteria time-stepping. */ + time_instance = TickCount::now(); + soil_step_initialization.exec(); - ReloadParticleIO write_particle_reload_files(io_environment, soil_block); - /** A Physics relaxation step. */ - relax_dynamics::RelaxationStepInner relaxation_step_inner(soil_block_complex.getInnerRelation()); - /** - * @brief Particle relaxation starts here. - */ - random_column_particles.exec(0.25); - relaxation_step_inner.SurfaceBounding().exec(); - body_states_recording.writeToFile(0.0); + soil_density_by_summation.exec(); + interval_computing_time_step += TickCount::now() - time_instance; - /** relax particles of the insert body. */ - int ite_p = 0; - while (ite_p < 1000) - { - relaxation_step_inner.exec(); - ite_p += 1; - if (ite_p % 200 == 0) - { - std::cout << std::fixed << std::setprecision(9) << "Relaxation steps for the column body N = " << ite_p << "\n"; - write_column_to_vtp.writeToFile(ite_p); - } - } - std::cout << "The physics relaxation process of cylinder body finish !" << std::endl; - /** Output results. */ - write_particle_reload_files.writeToFile(0.0); - return 0; - } - //---------------------------------------------------------------------- - // Define the numerical methods used in the simulation. - // Note that there may be data dependence on the sequence of constructions. - //---------------------------------------------------------------------- - SimpleDynamics soil_initial_condition(soil_block); - SharedPtr gravity_ptr = makeShared(Vec3d(0.0, -gravity_g, 0.0)); - SimpleDynamics wall_boundary_normal_direction(wall_boundary); - SimpleDynamics soil_step_initialization(soil_block, gravity_ptr); - ReduceDynamics soil_acoustic_time_step(soil_block, 0.1); - InteractionWithUpdate soil_density_by_summation(soil_block_complex); - InteractionDynamics stress_diffusion(soil_block_complex.getInnerRelation()); - Dynamics1Level granular_stress_relaxation_1st(soil_block_complex); - Dynamics1Level granular_stress_relaxation_2nd(soil_block_complex); - //---------------------------------------------------------------------- - // Define the methods for I/O operations, observations - // and regression tests of the simulation. - //---------------------------------------------------------------------- - RestartIO restart_io(io_environment, sph_system.real_bodies_); - RegressionTestDynamicTimeWarping>> - write_soil_mechanical_energy(io_environment, soil_block, gravity_ptr); - //---------------------------------------------------------------------- - // Prepare the simulation with cell linked list, configuration - // and case specified initial condition if necessary. - //---------------------------------------------------------------------- - sph_system.initializeSystemCellLinkedLists(); - sph_system.initializeSystemConfigurations(); - wall_boundary_normal_direction.exec(); - soil_initial_condition.exec(); - //---------------------------------------------------------------------- - // Load restart file if necessary. - //---------------------------------------------------------------------- - if (sph_system.RestartStep() != 0) - { - GlobalStaticVariables::physical_time_ = restart_io.readRestartFiles(sph_system.RestartStep()); - soil_block.updateCellLinkedList(); - soil_block_complex.updateConfiguration(); - } - //---------------------------------------------------------------------- - // Setup for time-stepping control - //---------------------------------------------------------------------- - size_t number_of_iterations = sph_system.RestartStep(); - int screen_output_interval = 500; - int observation_sample_interval = screen_output_interval * 2; - int restart_output_interval = screen_output_interval * 10; - Real End_Time = 0.5; /**< End time. */ - Real D_Time = End_Time / 25; /**< Time stamps for output of body states. */ - Real Dt = 0.1 * D_Time; - //---------------------------------------------------------------------- - // Statistics for CPU time - //---------------------------------------------------------------------- - TickCount t1 = TickCount::now(); - TimeInterval interval; - TimeInterval interval_computing_time_step; - TimeInterval interval_computing_soil_stress_relaxation; - TimeInterval interval_updating_configuration; - TickCount time_instance; - //---------------------------------------------------------------------- - // First output before the main loop. - //---------------------------------------------------------------------- - body_states_recording.writeToFile(); - write_soil_mechanical_energy.writeToFile(number_of_iterations); - //---------------------------------------------------------------------- - // Main loop starts here. - //---------------------------------------------------------------------- - while (GlobalStaticVariables::physical_time_ < End_Time) - { - Real integration_time = 0.0; - /** Integrate time (loop) until the next output time. */ - while (integration_time < D_Time) - { - /** outer loop for dual-time criteria time-stepping. */ - time_instance = TickCount::now(); - soil_step_initialization.exec(); + time_instance = TickCount::now(); + Real relaxation_time = 0.0; + while (relaxation_time < Dt) + { + Real dt = soil_acoustic_time_step.exec(); - soil_density_by_summation.exec(); - interval_computing_time_step += TickCount::now() - time_instance; + granular_stress_relaxation_1st.exec(dt); + stress_diffusion.exec(); + granular_stress_relaxation_2nd.exec(dt); - time_instance = TickCount::now(); - Real relaxation_time = 0.0; - while (relaxation_time < Dt) - { - Real dt = soil_acoustic_time_step.exec(); + relaxation_time += dt; + integration_time += dt; + GlobalStaticVariables::physical_time_ += dt; - granular_stress_relaxation_1st.exec(dt); - stress_diffusion.exec(); - granular_stress_relaxation_2nd.exec(dt); + interval_computing_soil_stress_relaxation += TickCount::now() - time_instance; - relaxation_time += dt; - integration_time += dt; - GlobalStaticVariables::physical_time_ += dt; + /** screen output, write body reduced values and restart files */ + if (number_of_iterations % screen_output_interval == 0) + { + std::cout << std::fixed << std::setprecision(9) << "N=" << number_of_iterations << std::setprecision(4) << " Time = " + << GlobalStaticVariables::physical_time_ + << std::scientific << " dt = " << dt << "\n"; - interval_computing_soil_stress_relaxation += TickCount::now() - time_instance; + if (number_of_iterations % observation_sample_interval == 0 && number_of_iterations != sph_system.RestartStep()) + { + write_soil_mechanical_energy.writeToFile(number_of_iterations); + } + if (number_of_iterations % restart_output_interval == 0) + restart_io.writeToFile(number_of_iterations); + } + number_of_iterations++; + soil_block.updateCellLinkedList(); + soil_block_complex.updateConfiguration(); + } + /** Update cell linked list and configuration. */ + time_instance = TickCount::now(); + interval_updating_configuration += TickCount::now() - time_instance; + } + TickCount t2 = TickCount::now(); + body_states_recording.writeToFile(); + TickCount t3 = TickCount::now(); + interval += t3 - t2; + } + TickCount t4 = TickCount::now(); - /** screen output, write body reduced values and restart files */ - if (number_of_iterations % screen_output_interval == 0) - { - std::cout << std::fixed << std::setprecision(9) << "N=" << number_of_iterations << std::setprecision(4) << " Time = " - << GlobalStaticVariables::physical_time_ - << std::scientific << " dt = " << dt << "\n"; + TimeInterval tt; + tt = t4 - t1 - interval; + std::cout << std::fixed << "Total wall time for computation: " << tt.seconds() + << " seconds." << std::endl; + std::cout << std::fixed << std::setprecision(9) << "interval_computing_time_step =" + << interval_computing_time_step.seconds() << "\n"; + std::cout << std::fixed << std::setprecision(9) << "interval_computing_soil_stress_relaxation = " + << interval_computing_soil_stress_relaxation.seconds() << "\n"; + std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " + << interval_updating_configuration.seconds() << "\n"; + std::cout << "total time steps = " << number_of_iterations << "\n"; - if (number_of_iterations % observation_sample_interval == 0 && number_of_iterations != sph_system.RestartStep()) - { - write_soil_mechanical_energy.writeToFile(number_of_iterations); - } - if (number_of_iterations % restart_output_interval == 0) - restart_io.writeToFile(number_of_iterations); - } - number_of_iterations++; - soil_block.updateCellLinkedList(); - soil_block_complex.updateConfiguration(); - } - /** Update cell linked list and configuration. */ - time_instance = TickCount::now(); - interval_updating_configuration += TickCount::now() - time_instance; - } - TickCount t2 = TickCount::now(); - body_states_recording.writeToFile(); - TickCount t3 = TickCount::now(); - interval += t3 - t2; - } - TickCount t4 = TickCount::now(); + // sph_system.GenerateRegressionData() = true; + if (sph_system.GenerateRegressionData()) + { + write_soil_mechanical_energy.generateDataBase(1.0e-3); + } + else if (sph_system.RestartStep() == 0) + { + write_soil_mechanical_energy.testResult(); + } - TimeInterval tt; - tt = t4 - t1 - interval; - std::cout << std::fixed << "Total wall time for computation: " << tt.seconds() - << " seconds." << std::endl; - std::cout << std::fixed << std::setprecision(9) << "interval_computing_time_step =" - << interval_computing_time_step.seconds() << "\n"; - std::cout << std::fixed << std::setprecision(9) << "interval_computing_soil_stress_relaxation = " - << interval_computing_soil_stress_relaxation.seconds() << "\n"; - std::cout << std::fixed << std::setprecision(9) << "interval_updating_configuration = " - << interval_updating_configuration.seconds() << "\n"; - std::cout << "total time steps = " << number_of_iterations << "\n"; - //sph_system.generate_regression_data_ = true; - if (sph_system.generate_regression_data_) - { - write_soil_mechanical_energy.generateDataBase(1.0e-3); - } - else if (sph_system.RestartStep() == 0) - { - write_soil_mechanical_energy.testResult(); - } - return 0; + return 0; } diff --git a/tests/user_examples/test_3d_repose_angle/run_test.sh b/tests/user_examples/test_3d_repose_angle/run_test.sh deleted file mode 100644 index 945e1e1ac2..0000000000 --- a/tests/user_examples/test_3d_repose_angle/run_test.sh +++ /dev/null @@ -1,2 +0,0 @@ -./test_3d_repose_angle --r=true -./test_3d_repose_angle --r=false --i=true \ No newline at end of file diff --git a/tests/webassembly_models/bernoulli_beam/CMakeLists.txt b/tests/webassembly_models/bernoulli_beam/CMakeLists.txt index 5fd9622dbb..0258166434 100755 --- a/tests/webassembly_models/bernoulli_beam/CMakeLists.txt +++ b/tests/webassembly_models/bernoulli_beam/CMakeLists.txt @@ -22,7 +22,7 @@ target_link_libraries(${PROJECT_NAME} structural_simulation_module) if(NOT EMSCRIPTEN) add_test(NAME ${PROJECT_NAME} - COMMAND ${PROJECT_NAME} --r=true + COMMAND ${PROJECT_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) endif()