-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
define normal direction as general dynamics
- Loading branch information
1 parent
3d3c929
commit 2412371
Showing
8 changed files
with
113 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/shared/particle_dynamics/general_dynamics/general_geometric.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "general_geometric.h" | ||
#include "base_particles.hpp" | ||
|
||
namespace SPH | ||
{ | ||
//=============================================================================================// | ||
NormalDirectionFromBodyShape::NormalDirectionFromBodyShape(SPHBody &sph_body) | ||
: LocalDynamics(sph_body), GeneralDataDelegateSimple(sph_body), | ||
body_shape_(*sph_body.body_shape_), pos_(particles_->pos_), | ||
n_(*particles_->registerSharedVariable<Vecd>("NormalDirection")), | ||
n0_(*particles_->registerSharedVariable<Vecd>("InitialNormalDirection")) {} | ||
//=============================================================================================// | ||
void NormalDirectionFromBodyShape::update(size_t index_i, Real dt) | ||
{ | ||
Vecd normal_direction = body_shape_.findNormalDirection(pos_[index_i]); | ||
n_[index_i] = normal_direction; | ||
n0_[index_i] = normal_direction; | ||
} | ||
//=============================================================================================// | ||
NormalDirectionFromShapeAndOp:: | ||
NormalDirectionFromShapeAndOp(SPHBody &sph_body, const std::string &shape_name) | ||
: LocalDynamics(sph_body), GeneralDataDelegateSimple(sph_body), | ||
shape_and_op_(DynamicCast<ComplexShape>(this, sph_body.body_shape_)->getShapeAndOpByName(shape_name)), | ||
shape_(shape_and_op_->first), | ||
switch_sign_(shape_and_op_->second == ShapeBooleanOps::add ? 1.0 : -1.0), | ||
pos_(particles_->pos_), | ||
n_(*particles_->registerSharedVariable<Vecd>("NormalDirection")), | ||
n0_(*particles_->registerSharedVariable<Vecd>("InitialNormalDirection")) {} | ||
//=============================================================================================// | ||
void NormalDirectionFromShapeAndOp::update(size_t index_i, Real dt) | ||
{ | ||
Vecd normal_direction = switch_sign_ * shape_->findNormalDirection(pos_[index_i]); | ||
n_[index_i] = normal_direction; | ||
n0_[index_i] = normal_direction; | ||
} | ||
//=================================================================================================// | ||
} // namespace SPH |
70 changes: 70 additions & 0 deletions
70
src/shared/particle_dynamics/general_dynamics/general_geometric.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* ------------------------------------------------------------------------- * | ||
* 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 general_geometric.h | ||
* @brief This is the particle dynamics applicable for all type bodies | ||
* @author Xiangyu Hu | ||
*/ | ||
|
||
#ifndef GENERAL_GEOMETRIC_H | ||
#define GENERAL_GEOMETRIC_H | ||
|
||
#include "general_dynamics.h" | ||
|
||
namespace SPH | ||
{ | ||
/** | ||
* @class NormalDirectionFromBodyShape | ||
* @brief normal direction at particles | ||
*/ | ||
class NormalDirectionFromBodyShape : public LocalDynamics, public GeneralDataDelegateSimple | ||
{ | ||
public: | ||
explicit NormalDirectionFromBodyShape(SPHBody &sph_body); | ||
virtual ~NormalDirectionFromBodyShape(){}; | ||
void update(size_t index_i, Real dt = 0.0); | ||
|
||
protected: | ||
Shape &body_shape_; | ||
StdLargeVec<Vecd> &pos_, &n_, &n0_; | ||
}; | ||
|
||
/** | ||
* @class NormalDirectionFromShapeAndOp | ||
* @brief normal direction at particles | ||
*/ | ||
class NormalDirectionFromShapeAndOp : public LocalDynamics, public GeneralDataDelegateSimple | ||
{ | ||
public: | ||
explicit NormalDirectionFromShapeAndOp(SPHBody &sph_body, const std::string &shape_name); | ||
virtual ~NormalDirectionFromShapeAndOp(){}; | ||
void update(size_t index_i, Real dt = 0.0); | ||
|
||
protected: | ||
ShapeAndOp *shape_and_op_; | ||
Shape *shape_; | ||
const Real switch_sign_; | ||
StdLargeVec<Vecd> &pos_, &n_, &n0_; | ||
}; | ||
} // namespace SPH | ||
#endif // GENERAL_GEOMETRIC_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters