|
A Membrane consists of masses connected by springs. More...
#include <Membrane.h>
Classes | |
struct | Edge |
Public Member Functions | |
Membrane () | |
Default constructor. More... | |
Membrane (ParticleSpecies *membraneSpecies, ParticleSpecies *membraneParticleSpecies) | |
~Membrane () override | |
Copy constructor. More... | |
Membrane * | copy () const |
Copy method. It calls the copy constructor of this Object. More... | |
void | read (std::istream &is) override |
Reads a Membrane from an input stream, for example a restart file. More... | |
void | write (std::ostream &os) const override |
Writes a Membrane to an output stream, for example a restart file. More... | |
std::string | getName () const override |
Returns the name of the object, here the string "Membrane". More... | |
void | setKnAndCrittDampCoeff (Mdouble Kn, Mdouble critDampCoeff) |
Set the parameters needed for the stretching forces. More... | |
void | setElasticModulusAndThickness (Mdouble E, Mdouble thickness) |
Set the elastic modulus and thickness of the membrane \deltails The supplied values are used to calculate the spring constant of the membrane. More... | |
void | setSpringConstant (Mdouble k) |
Set the spring constant of the membrane. More... | |
void | setCriticalDampingCoefficient (Mdouble coeff) |
Set damping coefficient for the distance springs. More... | |
void | setKeAndKd (Mdouble Ke, Mdouble Kd) |
Set the parameters needed for the bending forces. More... | |
void | setBendingAreaConstant (bool areaConstant) |
void | setThickness (Mdouble thickness) |
Set the thickness of the membrane. More... | |
Mdouble | getKn () |
Mdouble | getCriticalDampingCoefficient () |
Mdouble | getKe () |
Mdouble | getKd () |
Mdouble | getThickness () |
Mdouble | getBendingAreaConstant () |
void | setParticleRadius (Mdouble radius) |
Set the radius of the vertex particles. More... | |
Mdouble | getParticleRadius () |
Returns the radius of the vertex particles. More... | |
void | setDPMBase (DPMBase *dpm) |
Set a pointer to DPMBase. More... | |
DPMBase * | getDPMBase () |
Get the stored pointer to DPMBase. More... | |
std::vector< BaseParticle * > | getVertexParticles () |
Returns a vector with pointers to the vertex particles. More... | |
std::vector< MeshTriangle * > | getFaces () |
Returns a vecter with pointers to the mesh triangles. More... | |
void | saveVertexPositions (std::ostream &os) |
save the current positions of the vertex particles to a stream More... | |
void | loadVertexPositions (std::istream &is) |
Load the positions of the vertex particles from a stream and apply them to existing particles. More... | |
void | saveAsOFF (unsigned int d) |
Save the Membrane as a .off file. More... | |
void | saveAsSTL (std::string fileName) |
Save the Membrane as a .stl file. More... | |
void | loadFromSTL (BaseParticle &p0, std::string fileName) |
Load the Membrane geometry from a .stl file. More... | |
void | loadFromSTL (BaseParticle &p0, std::string fileName, Mdouble eps) |
Load the Membrane geometry from a .stl file. More... | |
void | buildMesh (BaseParticle &p0, std::vector< Vec3D > vertexPositions, std::vector< unsigned int > edgeVertices, std::vector< unsigned int > faceVertices) |
Build the geometry from specified positions and their connectivity. More... | |
void | adjustVertexParticleSize () |
Calculates an updated radius for every vertex particle in order to account for the correct mass. More... | |
void | updateEdgeMass () |
Set the correct edge mass by taking the mass from the conencted vertices. More... | |
void | computeAdditionalForces () |
Compute the forces due to the mass spring system. More... | |
void | applyPressure (Mdouble pressure) |
Apply a surface pressure to the membrane. More... | |
void | handleParticleRemoval (unsigned int id) |
Handles the removal of vertex particles from the particle handler. More... | |
void | handleParticleAddition (unsigned int id, BaseParticle *p) |
Handles the addition of vertex particles to the particle handler. More... | |
Mdouble | getVolume () |
Calculate the volume of the membrane. More... | |
Public Member Functions inherited from BaseObject | |
BaseObject ()=default | |
Default constructor. More... | |
BaseObject (const BaseObject &p)=default | |
Copy constructor, copies all the objects BaseObject contains. More... | |
virtual | ~BaseObject ()=default |
virtual destructor More... | |
virtual void | moveInHandler (unsigned int index) |
Except that it is virtual, it does the same thing as setIndex() does. More... | |
void | setIndex (unsigned int index) |
Allows one to assign an index to an object in the handler/container. More... | |
void | setId (unsigned long id) |
Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More... | |
unsigned int | getIndex () const |
Returns the index of the object in the handler. More... | |
unsigned int | getId () const |
Returns the unique identifier of any particular object. More... | |
void | setGroupId (unsigned groupId) |
unsigned | getGroupId () const |
Private Member Functions | |
void | createVertexParticles (BaseParticle &p0, std::vector< Vec3D > vertexPositions) |
Handles the actual creation of vertex particles. More... | |
void | initializeEdgeBendingQuantities () |
Compute the forces due to the mass spring system. More... | |
void | updateFaceNeighbors () |
Update the faces to have the correct neighbors. More... | |
unsigned int | addVertex (std::vector< Vec3D > &vertices, Vec3D pos, Mdouble eps) |
Helper function to check if a given vertex already exists. More... | |
bool | addEdge (std::vector< unsigned int > &edges, std::map< std::pair< unsigned int, unsigned int >, int > &map, unsigned int v0, unsigned int v1) |
Helper function to check if a given edge already exists. More... | |
Private Attributes | |
std::vector< BaseParticle * > | vertexParticle_ |
std::vector< unsigned int > | vertexParticleId_ |
unsigned int | vertexInitId_ |
std::vector< MeshTriangle * > | face_ |
std::vector< unsigned int > | faceVertices_ |
std::vector< Edge > | edge_ |
Mdouble | particleRadius_ |
Mdouble | Kn_ |
Mdouble | critDampCoeff_ |
Mdouble | Ke_ |
Mdouble | Kd_ |
Mdouble | thickness_ |
bool | bendingAreaConstant_ |
ParticleSpecies * | membraneSpecies_ = nullptr |
ParticleSpecies * | membraneParticleSpecies_ = nullptr |
DPMBase * | DPMBase_ = nullptr |
A Membrane consists of masses connected by springs.
This class assumes, that the masses are connected in a triangular mesh. Additionally, for correct calculation of the spring constant for the distance spring, a hexagonal unit cell is assumed.
This class creates the particles required for the mass spring system. For contact detections, further triangular wall elements are created
Please make sure to provide appropriate a species for the particles as well as the wall elements (e.g giving the particles a species so that they do not interact with other particles in the simulation).
An instance of the membrane may be initialized with the following lines, e.g. by using a STL file:
Note that the method computeAdditionalForces needs to be called from the overridden DPMBase::computeAdditionalForces every timestep for the Membrane to work.
As an example please also have a look at the Driver code MembraneDemo
Membrane::Membrane | ( | ) |
Default constructor.
References bendingAreaConstant_, critDampCoeff_, DEBUG, Kd_, Ke_, Kn_, logger, particleRadius_, thickness_, and vertexInitId_.
Referenced by copy().
Membrane::Membrane | ( | ParticleSpecies * | membraneSpecies, |
ParticleSpecies * | membraneParticleSpecies | ||
) |
References membraneParticleSpecies_, and membraneSpecies_.
|
override |
Copy constructor.
Destructor.
|
private |
Helper function to check if a given edge already exists.
[in] | edges | The vector, where the new edge should be added |
[in] | map | A map used to dtermin, if the edge already exists |
[in] | v0 | The index of the first point of the edge |
[in] | v0 | The index of the second point of the edge |
This function adds a given edge to the vector edges, if it is not already contained.
Referenced by loadFromSTL().
|
private |
Helper function to check if a given vertex already exists.
[in] | vertices | The vector, where the new position should be added |
[in] | pos | The new position to add to the vector |
[in] | eps | The distance between two points below which they are assumed to be the same. |
This function adds a given position pos to the vector vertices, if it is not already contained.
References constants::i.
Referenced by loadFromSTL().
void Membrane::adjustVertexParticleSize | ( | ) |
Calculates an updated radius for every vertex particle in order to account for the correct mass.
Calculates an updated radius for every vertex particle in order to account for the correct mass.
References face_, ParticleSpecies::getDensity(), constants::i, membraneParticleSpecies_, constants::pi, vertexInitId_, and vertexParticle_.
void Membrane::applyPressure | ( | Mdouble | pressure | ) |
Apply a surface pressure to the membrane.
[in] | pressure | Value of the surface pressure acing on the membrane [Pa] |
This function applies a given pressure to the surface by calling the function applyPressure of a MeshTriangle.
References DEBUG, face_, constants::i, and logger.
void Membrane::buildMesh | ( | BaseParticle & | p0, |
std::vector< Vec3D > | vertexPositions, | ||
std::vector< unsigned int > | edgeVertices, | ||
std::vector< unsigned int > | faceVertices | ||
) |
Build the geometry from specified positions and their connectivity.
[in] | p0 | BaseParticle that will be used for the vertex particles |
[in] | vertexPositions | The position of the vertices |
[in] | edgeVertices | A vector of indices, where two consecutive values define the vertex particles connected by the edge |
[in] | faceVertices | A vector of indices, where three consecutive values define the vertex particles making up the triangle face |
This function creates the actual mesh including the vertex particles and wall elements. The mass of the triangles is set to match the actual weight of the cooresponding triangle. The density of the particle species is set, so that the mass of a vertex particle is equal to 5/3 times the mass of a triangle.
References MeshTriangle::actionsAfterParticleGhostUpdate(), createVertexParticles(), edge_, Membrane::Edge::effectiveMass, face_, MeshTriangle::getArea(), ParticleSpecies::getDensity(), getDPMBase(), Vec3D::getLength(), BaseHandler< T >::getObjectById(), constants::i, initializeEdgeBendingQuantities(), Membrane::Edge::initialLength, Membrane::Edge::initialState, membraneParticleSpecies_, membraneSpecies_, DPMBase::particleHandler, particleRadius_, constants::pi, ParticleSpecies::setDensity(), MeshTriangle::setMass(), BaseWall::setSpecies(), MeshTriangle::setVertexIds(), MeshTriangle::setVertices(), thickness_, updateFaceNeighbors(), Membrane::Edge::vertex, Membrane::Edge::vertexId, and vertexParticleId_.
Referenced by loadFromSTL().
void Membrane::computeAdditionalForces | ( | ) |
Compute the forces due to the mass spring system.
This function iterates through all edges to calculate the forces due to the mass spring system. Ideally this function is called from the computeAllForces function of DPMBase.
References bendingAreaConstant_, critDampCoeff_, edge_, constants::i, Kd_, Ke_, and Kn_.
Referenced by MembraneDemo::computeAdditionalForces(), and MembraneSelfTest::computeAdditionalForces().
Membrane * Membrane::copy | ( | ) | const |
Copy method. It calls the copy constructor of this Object.
Copy assignment operator.
\param[in] other The Membrane that must be copied. ‍/
Membrane::Membrane(const Membrane& other) : BaseObject(other) { face_ = other.face_; membraneSpecies_ = other.membraneSpecies_; DPMBase_ = other.DPMBase_;
logger(DEBUG, "Membrane(Membrane&) constructed."); }
Membrane::~Membrane() { logger(DEBUG, "~Membrane() has been called."); }
/*!
References Membrane().
|
private |
Handles the actual creation of vertex particles.
[in] | p0 | The template particle used to create the vertex particles |
This function creates a particle for every position in the vector vertexPositions
References BaseHandler< T >::copyAndAddObject(), getDPMBase(), ParticleHandler::getNumberOfRealObjects(), constants::i, DPMBase::particleHandler, BaseInteractable::setPosition(), vertexInitId_, vertexParticle_, and vertexParticleId_.
Referenced by buildMesh().
|
inline |
References bendingAreaConstant_.
|
inline |
References critDampCoeff_.
Referenced by MembraneDemo::setUpMembrane(), and MembraneSelfTest::setUpMembrane().
|
inline |
Get the stored pointer to DPMBase.
References DPMBase_.
Referenced by buildMesh(), createVertexParticles(), initializeEdgeBendingQuantities(), read(), and saveVertexPositions().
|
inline |
|
inline |
|
inline |
|
inline |
|
overridevirtual |
Returns the name of the object, here the string "Membrane".
Implements BaseObject.
|
inline |
Returns the radius of the vertex particles.
References particleRadius_.
Referenced by MembraneDemo::setUpMembrane(), and MembraneSelfTest::setUpMembrane().
|
inline |
References thickness_.
|
inline |
Returns a vector with pointers to the vertex particles.
References vertexParticle_.
Referenced by MembraneDemo::fixMembraneEdges(), and MembraneSelfTest::fixMembraneEdges().
Mdouble Membrane::getVolume | ( | ) |
Calculate the volume of the membrane.
This function computes the current volume enclosed by the membrane. Note: This function uses the Divergence theorem to integrate along the surface. The volume is therefore only accurate, if the surface is closed.
References Vec3D::dot(), and face_.
void Membrane::handleParticleAddition | ( | unsigned int | id, |
BaseParticle * | p | ||
) |
Handles the addition of vertex particles to the particle handler.
[in] | id | The id of the added particle |
[in] | p | Pointer to the added particle |
This function handles the addition of a particle with the given id to the particle handler. If the particle is contained in an edge, the edge is potentially. reactivated. This function is potentially usable for MPI parallelization
References edge_, constants::i, vertexInitId_, vertexParticle_, and vertexParticleId_.
void Membrane::handleParticleRemoval | ( | unsigned int | id | ) |
Handles the removal of vertex particles from the particle handler.
[in] | id | The id of the removed particle |
This function handles the removal of a particle with the given id from the particle handler. If the particle was contained in an edge, the edge is disabled. This function is potentially usable for MPI parallelization
References edge_, constants::i, vertexInitId_, vertexParticle_, and vertexParticleId_.
|
private |
Compute the forces due to the mass spring system.
This function initializes the quantities and pointer needed on the edges for calculating the forces due to the mass spring system.
References edge_, face_, MeshTriangle::getArea(), getDPMBase(), BaseHandler< T >::getObjectById(), MeshTriangle::getVertexIds(), constants::i, and DPMBase::particleHandler.
Referenced by buildMesh().
void Membrane::loadFromSTL | ( | BaseParticle & | p0, |
std::string | fileName | ||
) |
Load the Membrane geometry from a .stl file.
[in] | p0 | BaseParticle that will be used for the vertex particles |
[in] | fileName | The name of the file to load. |
This function loads the geometry from the STL file and calls the function buildMesh.
Referenced by MembraneDemo::setUpMembrane(), and MembraneSelfTest::setUpMembrane().
void Membrane::loadFromSTL | ( | BaseParticle & | p0, |
std::string | fileName, | ||
Mdouble | eps | ||
) |
Load the Membrane geometry from a .stl file.
[in] | p0 | BaseParticle that will be used for the vertex particles |
[in] | fileName | The name of the file to load. |
[in] | eps | The distance between two points below which they are assumed to be the same. |
This function loads the geometry from the STL file and calls the function buildMesh.
References addEdge(), addVertex(), buildMesh(), ERROR, constants::i, and logger.
void Membrane::loadVertexPositions | ( | std::istream & | is | ) |
Load the positions of the vertex particles from a stream and apply them to existing particles.
References constants::i, logger, PROCESSOR_ID, vertexParticle_, and vertexParticleId_.
|
overridevirtual |
Reads a Membrane from an input stream, for example a restart file.
[in] | is | The input stream from which the Membrane is read, usually a restart file. |
Implements BaseObject.
References bendingAreaConstant_, Membrane::Edge::checkActive(), critDampCoeff_, DPMBase_, edge_, Membrane::Edge::effectiveMass, Membrane::Edge::face, face_, Membrane::Edge::faceInitialArea, Membrane::Edge::faceVertex, Membrane::Edge::faceVertexId, getDPMBase(), BaseHandler< T >::getObjectById(), constants::i, Membrane::Edge::initialLength, Membrane::Edge::initialSineHalfTheta, Membrane::Edge::initialState, Kd_, Ke_, Kn_, logger, membraneParticleSpecies_, membraneSpecies_, n, DPMBase::particleHandler, particleRadius_, DPMBase::speciesHandler, thickness_, Membrane::Edge::uPre, Membrane::Edge::vertex, Membrane::Edge::vertexId, vertexInitId_, vertexParticle_, vertexParticleId_, and DPMBase::wallHandler.
void Membrane::saveAsOFF | ( | unsigned int | d | ) |
Save the Membrane as a .off file.
[in] | unsigned | int d |
This function saves the current geometry of the membrane to a file named membrane.$d.off.
References face_, vertexInitId_, and vertexParticle_.
void Membrane::saveAsSTL | ( | std::string | fileName | ) |
Save the Membrane as a .stl file.
[in] | fileName | The name of the file where the data is written to. |
This function writes the current geometry of the Membrane to a STL file.
void Membrane::saveVertexPositions | ( | std::ostream & | os | ) |
save the current positions of the vertex particles to a stream
References getDPMBase(), getMPISum(), BaseHandler< T >::getObjectById(), BaseInteractable::getPosition(), constants::i, BaseParticle::isMPIParticle(), DPMBase::particleHandler, PROCESSOR_ID, and vertexParticleId_.
void Membrane::setBendingAreaConstant | ( | bool | areaConstant | ) |
If set to true, the bending penalty is calulated using the initial triangle area instead of the current one.
References bendingAreaConstant_.
void Membrane::setCriticalDampingCoefficient | ( | Mdouble | coeff | ) |
Set damping coefficient for the distance springs.
References critDampCoeff_.
Referenced by MembraneDemo::setUpMembrane(), and MembraneSelfTest::setUpMembrane().
|
inline |
Set a pointer to DPMBase.
References DPMBase_.
Referenced by MembraneDemo::read(), MembraneSelfTest::read(), MembraneDemo::setUpMembrane(), and MembraneSelfTest::setUpMembrane().
Set the elastic modulus and thickness of the membrane \deltails The supplied values are used to calculate the spring constant of the membrane.
References Global_Physical_Variables::E, Kn_, setThickness(), and thickness_.
Referenced by MembraneDemo::setUpMembrane(), and MembraneSelfTest::setUpMembrane().
Set the parameters needed for the bending forces.
Referenced by MembraneDemo::setUpMembrane(), and MembraneSelfTest::setUpMembrane().
Set the parameters needed for the stretching forces.
References critDampCoeff_, and Kn_.
void Membrane::setParticleRadius | ( | Mdouble | radius | ) |
Set the radius of the vertex particles.
References logger, and particleRadius_.
Referenced by MembraneDemo::setUpMembrane(), and MembraneSelfTest::setUpMembrane().
void Membrane::setSpringConstant | ( | Mdouble | k | ) |
void Membrane::setThickness | ( | Mdouble | thickness | ) |
Set the thickness of the membrane.
References logger, and thickness_.
Referenced by setElasticModulusAndThickness().
void Membrane::updateEdgeMass | ( | ) |
Set the correct edge mass by taking the mass from the conencted vertices.
Set the correct edge mass by taking the mass from the conencted vertices.
References edge_, vertexInitId_, and vertexParticle_.
Referenced by MembraneDemo::fixMembraneEdges().
|
private |
Update the faces to have the correct neighbors.
This function assigns the coorect neighbors to the wall elements.
References face_, BaseObject::getId(), MeshTriangle::getVertexIds(), constants::i, MeshTriangle::neighbor, and MeshTriangle::vertexNeighbors.
Referenced by buildMesh().
|
overridevirtual |
Writes a Membrane to an output stream, for example a restart file.
[in] | os | The output stream where the Membrane must be written to, usually a restart file. |
Implements BaseObject.
References bendingAreaConstant_, critDampCoeff_, edge_, face_, BaseObject::getId(), constants::i, Kd_, Ke_, Kn_, membraneParticleSpecies_, membraneSpecies_, particleRadius_, thickness_, vertexInitId_, and vertexParticleId_.
|
private |
Stores a pointer to DPMBase
Referenced by computeAdditionalForces(), getBendingAreaConstant(), Membrane(), read(), setBendingAreaConstant(), and write().
|
private |
Stores damping coefficient for the normal springs
Referenced by computeAdditionalForces(), getCriticalDampingCoefficient(), Membrane(), read(), setCriticalDampingCoefficient(), setKnAndCrittDampCoeff(), and write().
|
private |
Stores a pointer to DPMBase
Referenced by getDPMBase(), read(), and setDPMBase().
|
private |
Stores the edges
Referenced by buildMesh(), computeAdditionalForces(), handleParticleAddition(), handleParticleRemoval(), initializeEdgeBendingQuantities(), read(), updateEdgeMass(), and write().
|
private |
Stores pointers to the MeshTriangle objects
Referenced by adjustVertexParticleSize(), applyPressure(), buildMesh(), getFaces(), getVolume(), initializeEdgeBendingQuantities(), read(), saveAsOFF(), saveAsSTL(), updateFaceNeighbors(), and write().
|
private |
Stores the 3 indices per face which can be used to get the ids from vertexParticleId_ // Todo: remove this
|
private |
Stores dissipation constant for the bending
Referenced by computeAdditionalForces(), getKd(), Membrane(), read(), setKeAndKd(), and write().
|
private |
Stores spring constant for the bending
Referenced by computeAdditionalForces(), getKe(), Membrane(), read(), setKeAndKd(), and write().
|
private |
Stores the spring constant for stretching
Referenced by computeAdditionalForces(), getKn(), Membrane(), read(), setElasticModulusAndThickness(), setKnAndCrittDampCoeff(), setSpringConstant(), and write().
|
private |
Stores a pointer to the membrane particle species
Referenced by adjustVertexParticleSize(), buildMesh(), Membrane(), read(), and write().
|
private |
Stores a pointer to the membrane species
Referenced by buildMesh(), Membrane(), read(), and write().
|
private |
Stores the radius of membrane particles
Referenced by buildMesh(), getParticleRadius(), Membrane(), read(), setParticleRadius(), and write().
|
private |
Stores thickness of the Membrane
Referenced by buildMesh(), getThickness(), Membrane(), read(), setElasticModulusAndThickness(), setThickness(), and write().
|
private |
Sores the id of the first particle created for the membrane. This value helps for the eventual MPI parallelization.
Referenced by adjustVertexParticleSize(), createVertexParticles(), handleParticleAddition(), handleParticleRemoval(), Membrane(), read(), saveAsOFF(), updateEdgeMass(), and write().
|
private |
Stores the pointers to the vertex particles
Referenced by adjustVertexParticleSize(), createVertexParticles(), getVertexParticles(), handleParticleAddition(), handleParticleRemoval(), loadVertexPositions(), read(), saveAsOFF(), and updateEdgeMass().
|
private |
Stores the ids of the vertex particles
Referenced by buildMesh(), createVertexParticles(), handleParticleAddition(), handleParticleRemoval(), loadVertexPositions(), read(), saveVertexPositions(), and write().