Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload all code of water entry/eixt #383

Merged
merged 13 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "wetting_coupled_spatial_temporal_method.h"

namespace SPH
{
//=====================================================================================================//
namespace fluid_dynamics
{
//=================================================================================================//
NonWettingSurfaceIndication::
NonWettingSurfaceIndication(BaseInnerRelation &inner_relation,
BaseContactRelation &contact_relation, Real threshold, Real criterion)
: FreeSurfaceIndicationComplex(inner_relation, contact_relation, threshold), wetting_criterion(criterion)
{
for (size_t k = 0; k != contact_particles_.size(); ++k)
{
contact_phi_.push_back(this->contact_particles_[k]->template getVariableByName<Real>("Phi"));
}
}
//=================================================================================================//
NonWettingSurfaceIndication::
NonWettingSurfaceIndication(ComplexRelation &complex_relation, Real threshold, Real criterion)
: NonWettingSurfaceIndication(complex_relation.getInnerRelation(),
complex_relation.getContactRelation(), threshold, criterion) {}

//=================================================================================================//
} // namespace fluid_dynamics
//=================================================================================================//
} // namespace SPH
//=================================================================================================//
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* ------------------------------------------------------------------------- *
* SPHinXsys *
* ------------------------------------------------------------------------- *
* SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle *
* Hydrodynamics for industrial compleX systems. It provides C++ APIs for *
* physical accurate simulation and aims to model coupled industrial dynamic *
* systems including fluid, solid, multi-body dynamics and beyond with SPH *
* (smoothed particle hydrodynamics), a meshless computational method using *
* particle discretization. *
* *
* SPHinXsys is partially funded by German Research Foundation *
* (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1, *
* HU1527/12-1 and HU1527/12-4. *
* *
* Portions copyright (c) 2017-2023 Technical University of Munich and *
* the authors' affiliations. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may *
* not use this file except in compliance with the License. You may obtain a *
* copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
* *
* ------------------------------------------------------------------------- */
/**
* @file fluid_surface_complex.h
* @brief Here, we define the algorithm classes for fluid dynamics within the body.
* @details We consider here weakly compressible fluids. The algorithms may be
* different for free surface flow and the one without free surface.
* @author Chi Zhang and Xiangyu Hu
*/

#ifndef WETTING_COUPLED_SPATIAL_TEMPORAL_COMPLEX_H
#define WETTING_COUPLED_SPATIAL_TEMPORAL_COMPLEX_H

#include "fluid_surface_complex.h"

namespace SPH
{
namespace fluid_dynamics
{
/**
* @class NonWettingSurfaceIndication
* @brief Non wetting surface particles include free-surface ones and interfacial ones near the non-wetted structure.
* @brief Even the position divergence of interfacial fluid pariticles has satisfied with the threshold of spatial-temporal
identification approach to be identified as internal ones,they will remain as free-surface ones if without
any wetted neighboring solid particles.
*/
class NonWettingSurfaceIndication : public FreeSurfaceIndicationComplex
{
public:
NonWettingSurfaceIndication(BaseInnerRelation &inner_relation,
BaseContactRelation &contact_relation, Real threshold = 0.75, Real criterion = 0.99);
explicit NonWettingSurfaceIndication(ComplexRelation &complex_relation, Real threshold = 0.75, Real criterion = 0.99);
virtual ~NonWettingSurfaceIndication(){};

inline void interaction(size_t index_i, Real dt = 0.0)
{
FreeSurfaceIndicationInner::interaction(index_i, dt);

ShuoguoZhangTUM marked this conversation as resolved.
Show resolved Hide resolved
Real pos_div = 0.0;
for (size_t k = 0; k < contact_configuration_.size(); ++k)
{
Neighborhood &contact_neighborhood = (*contact_configuration_[k])[index_i];
for (size_t n = 0; n != contact_neighborhood.current_size_; ++n)
{
pos_div -= contact_neighborhood.dW_ijV_j_[n] * contact_neighborhood.r_ij_[n];
}
}
pos_div_[index_i] += pos_div;

if (pos_div_[index_i] > this->threshold_by_dimensions_)
{
for (size_t k = 0; k < contact_configuration_.size(); ++k)
{
Neighborhood &contact_neighborhood = (*contact_configuration_[k])[index_i];
for (size_t n = 0; n != contact_neighborhood.current_size_; ++n)
{
size_t j = contact_neighborhood.j_[n];
if ((*(contact_phi_[k]))[j] > wetting_criterion)
{
pos_div_[index_i] = 2.0 * this->threshold_by_dimensions_;
break;
}
else
{
pos_div_[index_i] = 0.5 * this->threshold_by_dimensions_;
}
}
if (pos_div_[index_i] == 2.0 * this->threshold_by_dimensions_)
break;
}
}
};

protected:
Real wetting_criterion;
StdVec<StdLargeVec<Real> *> contact_phi_;
};

using WettingCoupledSpatialTemporalFreeSurfaceIdentificationComplex =
SpatialTemporalFreeSurfaceIdentification<NonWettingSurfaceIndication>;
using SpatialTemporalFreeSurfaceIdentificationComplex =
SpatialTemporalFreeSurfaceIdentification<FreeSurfaceIndicationComplex>;


} // namespace fluid_dynamics
} // namespace SPH
#endif // WETTING_COUPLED_SPATIAL_TEMPORAL_COMPLEX_H
38 changes: 38 additions & 0 deletions tests/user_examples/test_2d_water_entry_exit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SPHINXSYS_PROJECT_DIR}/cmake) # main (top) cmake dir

set(CMAKE_VERBOSE_MAKEFILE on)

STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} )
PROJECT("${CURRENT_FOLDER}")



SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/")
SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input")
SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload")

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} ${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()

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)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<result>
<Snapshot_Element>
<Snapshot number_of_snapshot_for_local_result_="23" />
</Snapshot_Element>
<Result_Element>
<Particle_0 snapshot_0="0" snapshot_1="0" snapshot_2="0" snapshot_3="0.26824761949884235" snapshot_4="0.4730243946282956" snapshot_5="0.74587925241894071" snapshot_6="0.72242583246899739" snapshot_7="1.0870796359291397" snapshot_8="0.5682468472962563" snapshot_9="0.080383330251895799" snapshot_10="0.28951507448785041" snapshot_11="0.19503809881383863" snapshot_12="0.072247067621478339" snapshot_13="0.035605086322673521" snapshot_14="0.078924044748357097" snapshot_15="0.24978032310464621" snapshot_16="0.28252482137663387" snapshot_17="0.15952092372783219" snapshot_18="0.15307918833519168" snapshot_19="0.095080477191072876" snapshot_20="0.044194752631769751" snapshot_21="0.025363818478689421" snapshot_22="0.4551060768497584" />
</Result_Element>
</result>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<result>
<Snapshot_Element>
<Snapshot number_of_snapshot_for_local_result_="23" />
</Snapshot_Element>
<Result_Element>
<Particle_0 snapshot_0="0" snapshot_1="0" snapshot_2="0" snapshot_3="0.26824761956935955" snapshot_4="0.47302439486463893" snapshot_5="0.74588067344078801" snapshot_6="0.72193405874996353" snapshot_7="1.1261790827731351" snapshot_8="0.59383508816735919" snapshot_9="0.25240999590614466" snapshot_10="0.30566895950967043" snapshot_11="0.17371303994787599" snapshot_12="0.10493709564791738" snapshot_13="0.040965428157454159" snapshot_14="0.073776302344906536" snapshot_15="0.25387079940163582" snapshot_16="0.2777096055007699" snapshot_17="0.18727559494591406" snapshot_18="0.15023074525997723" snapshot_19="0.094780833589947933" snapshot_20="0.049784791524005098" snapshot_21="0.028947481780696508" snapshot_22="0.77785682130437295" />
</Result_Element>
</result>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<result>
<Snapshot_Element>
<Snapshot number_of_snapshot_for_local_result_="23" />
</Snapshot_Element>
<Result_Element>
<Particle_0 snapshot_0="0" snapshot_1="0" snapshot_2="0" snapshot_3="0.2682476195412844" snapshot_4="0.47302448444365897" snapshot_5="0.74588226196639718" snapshot_6="0.72228266702877364" snapshot_7="1.1256682005482554" snapshot_8="0.44350066049561476" snapshot_9="0.24926134935006949" snapshot_10="0.39149771463015298" snapshot_11="0.22487722496839638" snapshot_12="0.042894954501629716" snapshot_13="0.069398823961160275" snapshot_14="0.033657753591351001" snapshot_15="0.25189361494282553" snapshot_16="0.26230617619410124" snapshot_17="0.19596774244520693" snapshot_18="0.14535307307625736" snapshot_19="0.11183689814420757" snapshot_20="0.076086793367831168" snapshot_21="0.02834455916269147" snapshot_22="0.37818345401739356" />
</Result_Element>
</result>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dtw_distance>
<DTWDistance Pressure_0="1.078460056924573" />
</dtw_distance>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
true
21
4
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<result>
<Snapshot_Element>
<Snapshot number_of_snapshot_for_local_result_="23" />
</Snapshot_Element>
<Result_Element>
<Particle_0 snapshot_0="1.0000000000000016" snapshot_1="0.99908073979547907" snapshot_2="0.9972535745709904" snapshot_3="0.97934908582374036" snapshot_4="0.96681779377513877" snapshot_5="0.9609435530819791" snapshot_6="0.95483654608254354" snapshot_7="0.91693034033482201" snapshot_8="0.89034597029198026" snapshot_9="0.82298470556549053" snapshot_10="0.77388107898670888" snapshot_11="0.64359526718536286" snapshot_12="0.59284102898789648" snapshot_13="0.54316549181859042" snapshot_14="0.52693679182409836" snapshot_15="0.50910549193526555" snapshot_16="0.49098941767463433" snapshot_17="0.47418058373116045" snapshot_18="0.45910910872711319" snapshot_19="0.44671211083616774" snapshot_20="0.43914896846695872" snapshot_21="0.43020444713463862" snapshot_22="0.42109977970773788" />
</Result_Element>
</result>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<result>
<Snapshot_Element>
<Snapshot number_of_snapshot_for_local_result_="23" />
</Snapshot_Element>
<Result_Element>
<Particle_0 snapshot_0="1.0000000000000013" snapshot_1="0.99908073979547884" snapshot_2="0.99725357457060326" snapshot_3="0.97934908582084113" snapshot_4="0.96681779390432554" snapshot_5="0.96094354739906396" snapshot_6="0.95483667401992078" snapshot_7="0.91700198965761337" snapshot_8="0.890298343167784" snapshot_9="0.82347793544468728" snapshot_10="0.77411350801162282" snapshot_11="0.64661134753812921" snapshot_12="0.59474259967521981" snapshot_13="0.54242004915481623" snapshot_14="0.52660072249066781" snapshot_15="0.51246729660496948" snapshot_16="0.4933639974490498" snapshot_17="0.47463211305291358" snapshot_18="0.46251664631840911" snapshot_19="0.45283168245170557" snapshot_20="0.44519260475260247" snapshot_21="0.43611794304528545" snapshot_22="0.42560609742829392" />
</Result_Element>
</result>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<result>
<Snapshot_Element>
<Snapshot number_of_snapshot_for_local_result_="23" />
</Snapshot_Element>
<Result_Element>
<Particle_0 snapshot_0="1.0000000000000013" snapshot_1="0.99908073979548129" snapshot_2="0.99725357457195196" snapshot_3="0.97934908582514835" snapshot_4="0.9668177937724618" snapshot_5="0.96094355935347275" snapshot_6="0.95483644361309716" snapshot_7="0.9168952018698473" snapshot_8="0.89045591055620532" snapshot_9="0.82226712645025335" snapshot_10="0.7740482143577585" snapshot_11="0.64372878458122351" snapshot_12="0.59197947331431133" snapshot_13="0.53896777564558884" snapshot_14="0.52361514426760103" snapshot_15="0.50585369010145087" snapshot_16="0.48669689464087029" snapshot_17="0.47110675895795073" snapshot_18="0.45475361279453147" snapshot_19="0.44335740932927675" snapshot_20="0.43355538864165893" snapshot_21="0.42704792183618945" snapshot_22="0.41940662237264842" />
</Result_Element>
</result>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dtw_distance>
<DTWDistance TotalMechanicalEnergy_0="0.2" />
</dtw_distance>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
true
12
4
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# !/usr/bin/env python3
import os
import sys

path = os.path.abspath('../../../../../PythonScriptStore/RegressionTest')
sys.path.append(path)
from regression_test_base_tool import SphinxsysRegressionTest

"""
case name: test_2d_dambreak
"""

case_name = "test_2d_dambreak"
body_name = "WaterBody"
parameter_name = "TotalMechanicalEnergy"
body_name_1 = "FluidObserver"
parameter_name_1 = "Pressure"

number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1)


while True:
print("Now start a new run......")
sphinxsys.run_case()
number_of_run_times += 1
converged = sphinxsys.read_dat_file()
converged_1 = sphinxsys_1.read_dat_file()
print("Please note: This is the", number_of_run_times, "run!")
if number_of_run_times <= 200:
if (converged == "true") and (converged_1 == "true"):
print("The tested parameters of all variables are converged, and the run will stop here!")
break
elif converged != "true":
print("The tested parameters of", sphinxsys.sphinxsys_parameter_name, "are not converged!")
continue
elif converged_1 != "true":
print("The tested parameters of", sphinxsys_1.sphinxsys_parameter_name, "are not converged!")
continue
else:
print("It's too many runs but still not converged, please try again!")
break
2 changes: 2 additions & 0 deletions tests/user_examples/test_2d_water_entry_exit/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./test_2d_water_entry_exit --r=true
./test_2d_water_entry_exit --r=false --i=true
Loading
Loading