Skip to content

Commit

Permalink
Pull webassembly and recent changes (#67)
Browse files Browse the repository at this point in the history
* Verification cases thesis (#15)

* ConstrainSolidBody renamed

* constrain solid body reagion added

* force boundary condition

* force BC edited

* Pressure bc (#16)

* SurfacePressureFromSource added

* SurfacePressureFromSource::Update

* BC prob works but the particle normals are missing

* time dependent surface pressure works

* cube case moved to source tests

* Add test folder (#18)

* Translate body part (#45)

* Feature/contact stent 2 (#10)

* PositionSolidBody added

* boundary condition works but breaks numerically

* no message

* first unit test added

* indentation change

* PositionSolidBody test

* remove file

* small fixes

* position constraint changed
works between start and end time

* scaling boundary condition

* PositionScaleSolidBody unit test

* particel adaptation changed

* system resolution ratio added to particle adaptation

* add googletest to docker and workflow

* unit test removed temporarily

* unit rest removed

* SolidParticleRelaxation added to update initial particle position

* gtest added again

* gtest install changed

* gtest

* gtest

* gtest

* gtest

* cd path updated

* change to shared pointers

* unit test pointers changed

* gtest added to docker

* initialization changed

* disable tests for simbody

* errors fixed

* TranslationSolidBody added; translation cylinder

* whitespace

* fixes

* TranslateSolidBody corrected

* writeToFile update

* change SET to set

* catch(out_of_range& e) added

* change to size_t

* cmake minimum removed

* BoundingBox test changed

* fix writeToFIle

* test change

* Feature/position bc stent (#34)

* PositionSolidBody added

* boundary condition works but breaks numerically

* no message

* first unit test added

* indentation change

* PositionSolidBody test

* remove file

* small fixes

* position constraint changed
works between start and end time

* scaling boundary condition

* PositionScaleSolidBody unit test

* particel adaptation changed

* system resolution ratio added to particle adaptation

* add googletest to docker and workflow

* unit test removed temporarily

* unit rest removed

* SolidParticleRelaxation added to update initial particle position

* gtest added again

* gtest install changed

* gtest

* gtest

* gtest

* gtest

* cd path updated

* change to shared pointers

* unit test pointers changed

* gtest added to docker

* initialization changed

* errors fixed

* TranslationSolidBody added; translation cylinder

* whitespace

* fixes

* TranslateSolidBody corrected

* writeToFile update

* change SET to set

* catch(out_of_range& e) added

* change to size_t

* cmake minimum removed

* BoundingBox test changed

* fix writeToFIle

* test change

Co-authored-by: JohnVirtonomy <[email protected]>

* -Werror only works for linux

* TEST TranslateSolidBodyTuple

* Update CMakeLists.txt

remove werror flag for msvc

* update from bitbucket 01.07.2021

* delete repeated files

* brief information on google test in repo readme

* delete clapack and simbody folder in root

* google test works for windows but the unit test case did not copy stl file right in windows

* now test_3d_unit works in windows.

* information on installing google test in windows

* add a comment on install ing for VS in windows

* translation with same scale&unit test update

* skip testing when [ci skip] in the commit message

* update test_3d_unit - TranslateSolidBody not work

* time-dependent-contact

* number of time dep. contacts fixed

* setup unit test for time dependent contact

* Translate Solid Body fixed
but tolerance is only 0.01

* output changed to 100 files always

* 07.13.2021 update

* typo

* new files from bitbucket

* update 07.13.2021

* time dependent contact fixed

* time dep contact fixed

* remove cout

* time dep. contact tests finished

* renaming

* fix naming

* move test class into seperate header

* cmake changes

* changing function names to lower case

* change cmake list

* small fix

Co-authored-by: Ubuntu <virtonomy@SPHsimulation2.qg4qjrxycqxetcothedhm1ylih.ax.internal.cloudapp.net>
Co-authored-by: JohnVirtonomy <[email protected]>
Co-authored-by: Xiangyu Hu <[email protected]>
Co-authored-by: Wen-Yang Chu <[email protected]>
Co-authored-by: Xiangyu Hu <xiangyu.hu@tum>
Co-authored-by: Xiangyu Hu <[email protected]>

* TranslateSolidBodyPart added

* particle relaxation fixed

* change Get_ to get_

* checkIfPointInBoundingBox moved

Co-authored-by: Ubuntu <virtonomy@SPHsimulation2.qg4qjrxycqxetcothedhm1ylih.ax.internal.cloudapp.net>
Co-authored-by: JohnVirtonomy <[email protected]>
Co-authored-by: Xiangyu Hu <[email protected]>
Co-authored-by: Wen-Yang Chu <[email protected]>
Co-authored-by: Xiangyu Hu <xiangyu.hu@tum>
Co-authored-by: Xiangyu Hu <[email protected]>

* update from bitbucket 07-30-2021

* replace the wrong gpuSPHinXsys

* Simbody artifacts instead of installation

* simbody variable added to cmake command

* change path

* conflict resolved

* remove doubled test

Co-authored-by: Ubuntu <virtonomy@SPHsimulation2.qg4qjrxycqxetcothedhm1ylih.ax.internal.cloudapp.net>
Co-authored-by: JohnVirtonomy <[email protected]>
Co-authored-by: Xiangyu Hu <[email protected]>
Co-authored-by: Wen-Yang Chu <[email protected]>
Co-authored-by: Xiangyu Hu <xiangyu.hu@tum>
Co-authored-by: Xiangyu Hu <[email protected]>

* Pressure bc (#20)

* SurfacePressureFromSource added

* SurfacePressureFromSource::Update

* BC prob works but the particle normals are missing

* stress relaxation changed to Kirchhof

* time dependent surface pressure works

* cube case moved to source tests

* cube test removed

* add overtime to position based tests

* go back to last working state

* back to working version

Co-authored-by: Ubuntu <virtonomy@SPHbence.qg4qjrxycqxetcothedhm1ylih.ax.internal.cloudapp.net>

* simulation class remvoed (#21)

* fix numerical damping (#23)

* Simbody lib seperate (#26)

* remove submodules

* simbody added on no lapack

* simbody

* cases user moved

* scripts removed

* simbody set to master

* variables removed

* 3d lib cmake

* boost option

* simbody linking to built libraries

* renaming + 2D cmake

* option subdir

* werror

* eigen in simbody

* eigen added

* eigen

* eigen include

* eigen

* add wasmtbb

* working wasm example

* cmake changes

* restore working wasm build

* change memory pool for wasm

* work on eigen

Co-authored-by: wen-yang chu <[email protected]>

* update simbody

* Replace clapack (#27)

* work on eigen

* all tests pass with Eigen

* macro renamed simbody

* all SPH tests pass for static build

* remove wasm files

* first setup of spring on surface normal direction (#22)

* first setup of spring on surface normal direction

* adjusted combi of spring and pressure BC

* correction of damping coefficient

* simulation runs
but too small time steps, only one vtu-file

* consideration normal portion in opposite direction

* creation of tests for vector calculations

* simplification of vector norm calculation

* small vector test working, but failing

* small vector tests passing

* angle tests added

* correction of Vector Projection
more test examples

* correction of normal spring
beam still spinning

* adding of functions for vector calculations

* change of spring force in right direction

* debugging, still spinning after timestep 18

* change of vector calculation example

* correction of normal spring force

* for-loop removed, checking of spring & damping

* area moved and considered in damping

* adding gtest to CMakeLists

* simplified dot_product_2 calculation

* change from Vecd to Vec3d for calculations

* changed Vector declaration and functions

* correction of Spring and Damping

Co-authored-by: JohnVirtonomy.io <[email protected]>

* emscripten option to disable gtest (#28)

* emscripten option to disable gtest

* comment out compiling flags

* bug fix

Co-authored-by: wen-yang chu <[email protected]>

* Fix zero pos particles (#31)

* change pressure BC to be define by body part

* SpringNormalOnSurfaceParticles with body part

* option to use inner or outer surface for spring

* zero position of particles fixed

* fix BodyPartByParticle (#34)

* Dynamic heart (#29)

* change pressure BC to be define by body part

* SpringNormalOnSurfaceParticles with body part

* option to use inner or outer surface for spring

* zero position of particles fixed

* adding function to avoid LevelSetComplexShape

* "virtual" added to comply with github CI test

* both options for normalDirectionCalculation

* "virtual" removed since no change in CI test

* additional findNormalDirection dor 2D_build

* comment to see if geometry_level_set is called

* accelaration output added to vtu

* adding displacement output & removing density

* Vec3d to Vecd

* adding normal vectors to vtu-File

* von Mises Strain implemented

* CMake name change to differentiate BUILD_TEST

* test for strain calculation

* correction of von Mises strain calculation

* displ., normal, strain output calc. added in 2D

Co-authored-by: JohnVirtonomy <[email protected]>

* Fix wasm merge2 (#37)

* add EMSCRIPTEN macro to disable macro

* remove image stuff with emscripten

* simbody static lib with emscripten

Co-authored-by: Wen-Yang Chu <[email protected]>
Co-authored-by: JohnVirtonomy <[email protected]>

* Production 1 freatures (#32)

* cherry pick fixing zero position

* option to write levelset data

* fix BodyPartByParticle

* small_shift changed

* small shift changed back

* fix normal calculation bug

Co-authored-by: JohnVirtonomy <[email protected]>

* vtu ouput update (#39)

* SurfaceOnlyBodyStatesRecordingToVtu class

* class, functions for only surface particles output

* comment out cout of number of surface particles

* ShapeSurface in constructor only called at start

* correction of surface ouput; still some issues

* final correction of surface particle output

Co-authored-by: JohnVirtonomy <[email protected]>

* add writer for vtu file to string

* revert commit

* add writer for vtu file to string (#40)

* add small shift option to level set (#38)

* add small shift option to level set

* throw exceptions if instability occurs

* fix comment

* Kirchhof relaxation stability improved, removed B_

* fix 2D error

* 2d self contact changed

Co-authored-by: JohnVirtonomy <[email protected]>

* Triangle mesh from buffer constructor (#44)

* triangle mesh buffer constructor

* Triangle mesh from buffer only for emcc

* structural simulation to gitHub (#41)

* structural simulation to gitHub

* change class

* fix wasm compilation

Co-authored-by: JohnVirtonomy <[email protected]>
Co-authored-by: BenceVirtonomy <[email protected]>

* Surface spring (#45)

* surface spring constraint added with test

* add surface fixation

* surface spring

* better exception

* findTBB edit

* change error message

Co-authored-by: JohnVirtonomy <[email protected]>

Co-authored-by: Ubuntu <virtonomy@SPHsimulation2.qg4qjrxycqxetcothedhm1ylih.ax.internal.cloudapp.net>
Co-authored-by: JohnVirtonomy <[email protected]>
Co-authored-by: Xiangyu Hu <[email protected]>
Co-authored-by: Wen-Yang Chu <[email protected]>
Co-authored-by: Xiangyu Hu <xiangyu.hu@tum>
Co-authored-by: Xiangyu Hu <[email protected]>
Co-authored-by: Ubuntu <virtonomy@SPHbence.qg4qjrxycqxetcothedhm1ylih.ax.internal.cloudapp.net>
Co-authored-by: JohnVirtonomy <[email protected]>
Co-authored-by: JohnVirtonomy.io <[email protected]>
Co-authored-by: Antonov548 <[email protected]>
Co-authored-by: mrezavandVirtonomy <[email protected]>
  • Loading branch information
12 people authored Oct 22, 2021
1 parent efcd778 commit faa88ca
Show file tree
Hide file tree
Showing 48 changed files with 2,382 additions and 91 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ option(STATIC_BUILD "STATIC_BUILD" 0)
option(ONLY_3D "ONLY_3D" 0)
option(BUILD_WITH_SIMBODY "BUILD_WITH_SIMBODY" 0)
option(EMSCRIPTEN "EMSCRIPTEN" 0)
option(BUILD_TESTS "BUILD_TESTS" 1)
option(BUILD_SPHINXSYS_TESTS "BUILD_SPHINXSYS_TESTS" 1)

if(EMSCRIPTEN)
set(STATIC_BUILD 1)
set(BUILD_WITH_SIMBODY 1)
set(ONLY_3D 1)
set(BUILD_TESTS 1)
set(BUILD_SPHINXSYS_TESTS 1)
add_definitions(-D__SIMBODY_WITHOUT_LAPACK__)
add_definitions(-D__EIGEN__)
add_definitions(-D__EMSCRIPTEN__)
Expand Down Expand Up @@ -128,10 +128,12 @@ endif()

add_subdirectory(SPHINXsys)

if(BUILD_TESTS)
if(BUILD_SPHINXSYS_TESTS)
add_subdirectory(tests)
endif()

if(ACTIVATE_CUDA)
add_subdirectory(cases_test_gpu)
endif()

add_subdirectory(modules)
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ namespace SPH {
}
}
//=================================================================================================//
void LevelSetDataPackage::markNearInterface()
void LevelSetDataPackage::markNearInterface(Real small_shift_factor)
{
Real small_shift = 0.75 * grid_spacing_;
Real small_shift = small_shift_factor * grid_spacing_;
//corner averages, note that the first row and first column are not used
PackageTemporaryData<Real> corner_averages;
for (int i = 1; i != AddressSize(); ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,34 @@ namespace SPH {
+ 3.0 * sigmaxy * sigmaxy);
}
//=================================================================================================//
Vecd ElasticSolidParticles::displacement(size_t particle_i) //not tested in 2D
{
Vecd disp = pos_n_[particle_i] - pos_0_[particle_i];
return disp;
}
//=================================================================================================//
Vecd ElasticSolidParticles::normal(size_t particle_i) //not tested in 2D
{
Vecd normal_vec = n_[particle_i];
return normal_vec;
}
//=================================================================================================//
Real ElasticSolidParticles::von_Mises_strain(size_t particle_i) //not tested in 2D
{

Mat2d F = F_[particle_i];
Mat2d epsilon = 0.5 * (~F * F - Mat2d(1.0)); //calculation of the Green-Lagrange strain tensor


Real epsilonxx = epsilon(0, 0);
Real epsilonyy = epsilon(1, 1);
Real epsilonzz = 0; //z-components zero for 2D measures
Real epsilonxy = epsilon(0, 1);
Real epsilonxz = 0; //z-components zero for 2D measures
Real epsilonyz = 0; //z-components zero for 2D measures

return sqrt( (1.0 / 3.0) * (std::pow(epsilonxx - epsilonyy, 2.0) + std::pow(epsilonyy - epsilonzz, 2.0) + std::pow(epsilonzz - epsilonxx, 2.0))
+ 2.0 * (std::pow(epsilonxy, 2.0) + std::pow(epsilonyz, 2.0) + std::pow(epsilonxz, 2.0)));
}
//=================================================================================================//
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef __EMSCRIPTEN__

#include "complex_shape_image_mesh.h"
#include "image_mesh_shape.h"

Expand Down Expand Up @@ -161,4 +163,6 @@ namespace SPH
return BoundingBox(lower_bound, upper_bound);
}
//=================================================================================================//
}
}

#endif // __EMSCRIPTEN__
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#ifndef COMPLEX_SHAPE_IMAGE_MESH_H
#define COMPLEX_SHAPE_IMAGE_MESH_H

#ifndef __EMSCRIPTEN__

#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING

#include "base_geometry.h"
Expand Down Expand Up @@ -88,3 +90,5 @@ namespace SPH
}

#endif //COMPLEX_SHAPE_IMAGE_MESH_H

#endif // __EMSCRIPTEN__
12 changes: 12 additions & 0 deletions SPHINXsys/src/for_3D_build/geometries/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ namespace SPH
polymesh.scaleMesh(scale_factor);
triangle_mesh_ = generateTriangleMesh(polymesh.transformMesh(translation));
}
#ifdef __EMSCRIPTEN__
//=================================================================================================//
TriangleMeshShape::TriangleMeshShape(const uint8_t* buffer, Vec3d translation, Real scale_factor)
: Shape("TriangleMeshShape")
{
SimTK::PolygonalMesh polymesh;
polymesh.loadStlBuffer(buffer);
polymesh.scaleMesh(scale_factor);
triangle_mesh_ = generateTriangleMesh(polymesh.transformMesh(translation));
}
#endif
//=================================================================================================//
TriangleMeshShape::TriangleMeshShape(Vec3d halfsize, int resolution, Vec3d translation)
: Shape("TriangleMeshShape")
Expand Down Expand Up @@ -146,6 +157,7 @@ namespace SPH
//=================================================================================================//
Vec3d ComplexShape::findClosestPoint(const Vec3d &input_pnt)
{
//std::cout << "ComplexShape::findSignedDistance(const Vec3d &input_pnt) called";
return complex_shape_mesh_->findClosestPoint(input_pnt);
}
//=================================================================================================//
Expand Down
12 changes: 8 additions & 4 deletions SPHINXsys/src/for_3D_build/geometries/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ namespace SPH
public:
//constructor for load stl file from out side
TriangleMeshShape(std::string file_path_name, Vec3d translation, Real scale_factor);
#ifdef __EMSCRIPTEN__
//constructor for load stl file from buffer
TriangleMeshShape(const uint8_t* buffer, Vec3d translation, Real scale_factor);
#endif
// constructor for brick geometry
TriangleMeshShape(Vec3d halfsize, int resolution, Vec3d translation);
// constructor for sphere geometry
Expand All @@ -90,12 +94,10 @@ namespace SPH

class ComplexShape : public Shape
{
Vec3d findClosestPoint(const Vec3d &input_pnt);

public:
ComplexShape() : Shape("ComplexShape") { complex_shape_mesh_ = nullptr; };
ComplexShape(std::string complex_shape_name) : Shape(complex_shape_name) { complex_shape_mesh_ = nullptr; };
ComplexShape(ComplexShapeMesh*complex_shape_mesh) : Shape("ComplexShape") { complex_shape_mesh_ = complex_shape_mesh; };
ComplexShape(ComplexShapeMesh* complex_shape_mesh) : Shape("ComplexShape") { complex_shape_mesh_ = complex_shape_mesh; };
virtual ~ComplexShape() {};
virtual BoundingBox findBounds() override;

Expand Down Expand Up @@ -125,11 +127,13 @@ namespace SPH
virtual bool checkNearSurface(const Vec3d &input_pnt, Real threshold);
/** Signed distance is negative for point within the complex shape. */
virtual Real findSignedDistance(const Vec3d &input_pnt);
/** find closest point on the surface */
virtual Vec3d findClosestPoint(const Vec3d &input_pnt);
/** Normal direction point toward outside of the complex shape. */
virtual Vec3d findNormalDirection(const Vec3d &input_pnt);

protected:
/** shape container<pointer to geomtry, operation> */
/** shape container<pointer to geometry, operation> */

ComplexShapeMesh* complex_shape_mesh_;
};
Expand Down
4 changes: 4 additions & 0 deletions SPHINXsys/src/for_3D_build/geometries/image_mesh_shape.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef __EMSCRIPTEN__

#include "image_mesh_shape.h"

namespace SPH
Expand Down Expand Up @@ -69,3 +71,5 @@ namespace SPH
//=================================================================================================//

}

#endif // __EMSCRIPTEN__
4 changes: 4 additions & 0 deletions SPHINXsys/src/for_3D_build/geometries/image_mesh_shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#ifndef IMAGE_MESH_SHAPE_H
#define IMAGE_MESH_SHAPE_H

#ifndef __EMSCRIPTEN__

#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING

#include "base_geometry.h"
Expand Down Expand Up @@ -85,4 +87,6 @@ namespace SPH
};
}

#endif // __EMSCRIPTEN__

#endif //IMAGE_MESH_SHAPE_H
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ namespace SPH {
}
}
//=================================================================================================//
void LevelSetDataPackage::markNearInterface()
{
Real small_shift = 0.75 * grid_spacing_;
void LevelSetDataPackage::markNearInterface(Real small_shift_factor)
{
// small_shift_factor = 0.75 by default, can be increased for difficult geometries for smoothing
Real small_shift = small_shift_factor * grid_spacing_;
//corner averages, note that the first row and first column are not used
PackageTemporaryData<Real> corner_averages;
for (int i = 1; i != AddressSize(); ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,34 @@ namespace SPH {
+ 3.0 * (sigmaxy * sigmaxy + sigmaxz * sigmaxz + sigmayz * sigmayz));
}
//=================================================================================================//
Vecd ElasticSolidParticles::displacement(size_t particle_i)
{
Vecd disp = pos_n_[particle_i] - pos_0_[particle_i];
return disp;
}
//=================================================================================================//
Vecd ElasticSolidParticles::normal(size_t particle_i)
{
Vecd normal_vec = n_[particle_i];
return normal_vec;
}
//=================================================================================================//
Real ElasticSolidParticles::von_Mises_strain(size_t particle_i)
{

Mat3d F = F_[particle_i];
Mat3d epsilon = 0.5 * (~F * F - Matd(1.0)); //calculation of the Green-Lagrange strain tensor


Real epsilonxx = epsilon(0, 0);
Real epsilonyy = epsilon(1, 1);
Real epsilonzz = epsilon(2, 2);
Real epsilonxy = epsilon(0, 1);
Real epsilonxz = epsilon(0, 2);
Real epsilonyz = epsilon(1, 2);

return sqrt( (1.0 / 3.0) * (std::pow(epsilonxx - epsilonyy, 2.0) + std::pow(epsilonyy - epsilonzz, 2.0) + std::pow(epsilonzz - epsilonxx, 2.0))
+ 2.0 * (std::pow(epsilonxy, 2.0) + std::pow(epsilonyz, 2.0) + std::pow(epsilonxz, 2.0)));
}
//=================================================================================================//
}
10 changes: 8 additions & 2 deletions SPHINXsys/src/shared/bodies/base_body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ namespace SPH
return body_domain_bounds_;
}
//=================================================================================================//
void SPHBody::writeParticlesToVtuFile(std::ofstream &output_file)
void SPHBody::writeParticlesToVtuFile(std::ostream &output_file)
{
base_particles_->writeParticlesToVtuFile(output_file);
newly_updated_ = false;
}
//=================================================================================================//
void SPHBody::writeSurfaceParticlesToVtuFile(std::ofstream &output_file, ShapeSurface& surface_particles)
{
base_particles_->writeSurfaceParticlesToVtuFile(output_file, surface_particles);
newly_updated_ = false;
}
//=================================================================================================//
void SPHBody::writeParticlesToPltFile(std::ofstream &output_file)
{
if (newly_updated_)
Expand Down Expand Up @@ -184,7 +190,7 @@ namespace SPH
if (fabs(phi) < particle_spacing_min_)
tagAParticle(i);
}
std::cout << "Number of surface particles : " << body_part_particles_.size() << std::endl;
//std::cout << "Number of surface particles : " << body_part_particles_.size() << std::endl;
}
//=================================================================================================//
ShapeSurfaceLayer::ShapeSurfaceLayer(SPHBody *body, Real layer_thickness)
Expand Down
21 changes: 19 additions & 2 deletions SPHINXsys/src/shared/bodies/base_body.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace SPH
class BaseParticles;
class BaseCellLinkedList;
class SPHBodyRelation;
class ShapeSurface;

/**
* @class SPHBody
Expand Down Expand Up @@ -110,7 +111,8 @@ namespace SPH
virtual void assignBaseParticles(BaseParticles *base_particles);
void allocateConfigurationMemoriesForBufferParticles();

virtual void writeParticlesToVtuFile(std::ofstream &output_file);
virtual void writeParticlesToVtuFile(std::ostream &output_file);
virtual void writeSurfaceParticlesToVtuFile(std::ofstream &output_file, ShapeSurface& surface_particles);
virtual void writeParticlesToPltFile(std::ofstream &output_file);
virtual void writeParticlesToXmlForRestart(std::string &filefullpath);
virtual void readParticlesFromXmlForRestart(std::string &filefullpath);
Expand Down Expand Up @@ -207,13 +209,28 @@ namespace SPH
IndexVector body_part_particles_; /**< Collection particle in this body part. */

BodyPartByParticle(SPHBody *body, std::string body_part_name)
: BodyPartByShape(body, body_part_name){};
: BodyPartByShape(body, body_part_name),
body_part_bounds_(Vecd(0), Vecd(0)), body_part_bounds_set_(false)
{};

virtual ~BodyPartByParticle(){};

void setBodyPartBounds(BoundingBox bbox){
body_part_bounds_ = bbox;
body_part_bounds_set_ = true;
};

BoundingBox getBodyPartBounds(){
if (!body_part_bounds_set_) std::cout << "WARNING: the body part bounds are not set for BodyPartByParticle." << std::endl;
return body_part_bounds_;
}

protected:
void tagAParticle(size_t particle_index);
virtual void tagBodyPart() override;

BoundingBox body_part_bounds_;
bool body_part_bounds_set_;
};

/**
Expand Down
4 changes: 4 additions & 0 deletions SPHINXsys/src/shared/common/image_mhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#ifndef IMAGE_MHD_H
#define IMAGE_MHD_H

#ifndef __EMSCRIPTEN__

#include "small_vectors.h"
#include "sph_data_containers.h"

Expand Down Expand Up @@ -161,4 +163,6 @@ namespace SPH {

#include "image_mhd.hpp"

#endif //__EMSCRIPTEN__

#endif //IMAGE_MHD_H
10 changes: 8 additions & 2 deletions SPHINXsys/src/shared/common/image_mhd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
* *
* --------------------------------------------------------------------------*/
/**
* @file image_mesh_shape.h
* @file image_mhd.hpp
* @brief x
* @details x
* x
* @author Yijin Mao
*/
#pragma once
#ifndef IMAGE_MHD_HPP
#define IMAGE_MHD_HPP

#ifndef __EMSCRIPTEN__

#include "image_mhd.h"
#include "boost/algorithm/string.hpp"
Expand Down Expand Up @@ -521,3 +524,6 @@ namespace SPH {

}
}
#endif __EMSCRIPTEN__

#endif IMAGE_MHD_HPP
Loading

0 comments on commit faa88ca

Please sign in to comment.