22 #ifndef FORCESTRUCTS_HPP
23 #define FORCESTRUCTS_HPP
25 #include <LbmLib/include/Field.hpp>
26 #include <LbmLib/include/nodes/EulerianPoint.hpp>
27 #include <LbmLib/include/nodes/GeometryNode.hpp>
28 #include <LbmLib/include/solver/ForceSolver.hpp>
29 #include <UtilLib/include/Exception.hpp>
42 namespace ForceStructs{
68 std::shared_ptr<nodes::GeometryNode> >& nodes)
72 (nodes::getDistance(*(nodes.at(this->id2_)),
73 *(nodes.at(this->id1_))) - this->l0_);
75 nodes.at(this->id1_)->addForce(f *
76 (nodes.at(this->id2_)->getPos() - nodes.at(this->id1_)->getPos()) /
77 nodes::getDistance(*(nodes.at(this->id2_)), *(nodes.at(this->id1_))));
80 lbm_fail(
"Could not compute and set the forces.");
85 (*stream) << this->type <<
"\t" << this->id1_ <<
"\t" << this->id2_ <<
"\t" << this->k_ <<
86 "\t" << this->l0_ <<
"\n";
98 const unsigned int type = 0;
99 const unsigned int id1_;
100 const unsigned int id2_;
110 std::shared_ptr<ForceType0> loadForceType0(std::stringstream*
const stream) {
111 unsigned int type, id1, id2;
113 (*stream) >> type >> id1 >> id2 >> k >> l0;
114 return std::make_shared<ForceType0>(ForceType0(id1, id2, k, l0));
143 std::shared_ptr<nodes::GeometryNode> >& nodes) {
145 const double f = k_ * (nodes::getDistance(tempNode, *(nodes.at(id1_))) - l0_);
146 double distance = nodes::getDistance(tempNode, *(nodes.at(id1_)));
147 if (distance != 0.0) {
148 nodes.at(id1_)->addForce(f * (tempNode.
getPos() - nodes.at(
149 id1_)->getPos()) / distance);
154 (*stream) << type <<
"\t" << id1_ <<
"\t" << x_ <<
'\t' <<
155 y_ <<
"\t" << k_ <<
"\t" << l0_ <<
"\n";
167 const unsigned int type = 1;
168 const unsigned int id1_;
180 std::shared_ptr<ForceType1> loadForceType1(std::stringstream*
const stream) {
181 unsigned int type, id1;
183 (*stream) >> type >> id1 >> x >> y >> k >> l0;
185 return std::make_shared<ForceType1>(ForceType1(id1, x, y, k, l0));
208 std::shared_ptr<nodes::GeometryNode> >& nodes) {
213 (*stream) << type <<
"\t" << id1_ <<
"\t" << fx_ <<
"\t" << fy_ <<
"\n";
225 const unsigned int type = 2;
226 const unsigned int id1_;
236 std::shared_ptr<ForceType2> loadForceType2(std::stringstream*
const stream) {
237 unsigned int type, id1;
239 (*stream) >> type >> id1 >> fx >> fy;
241 return std::make_shared<ForceType2>(ForceType2(id1, fx, fy));
267 std::shared_ptr<nodes::GeometryNode> >& nodes) {
269 const double f = this->k_ * (nodes::getDistance(tempNode, *(nodes.at(this->id1_))) - this->l0_);
272 if (nodes.at(this->id1_)->getYPos() < this->y_) {
278 nodes.at(this->id1_)->addForce(force);
282 (*stream) << type <<
"\t" << id1_ <<
"\t" <<
283 y_ <<
"\t" << k_ <<
"\t" << l0_ <<
"\n";
295 const unsigned int type = 3;
296 const unsigned int id1_;
307 std::shared_ptr<ForceType3> loadForceType3(std::stringstream*
const stream) {
308 unsigned int type, id1;
310 (*stream) >> type >> id1 >> y >> k >> l0;
311 return std::make_shared<ForceType3>(ForceType3(id1, y, k, l0));
337 std::shared_ptr<nodes::GeometryNode> >& nodes) {
339 const double f = this->k_ * (nodes::getDistance(tempNode, *(nodes.at(this->id1_))) - this->l0_);
341 if (nodes.at(this->id1_)->getXPos() < this->x_) {
348 nodes.at(this->id1_)->addForce(force);
352 (*stream) << type <<
"\t" << id1_ <<
"\t" <<
353 x_ <<
"\t" << k_ <<
"\t" << l0_ <<
"\n";
365 const unsigned int type = 4;
366 const unsigned int id1_;
377 std::shared_ptr<ForceType4> loadForceType4(std::stringstream*
const stream) {
378 unsigned int type, id1;
380 (*stream) >> type >> id1 >> x >> k >> l0;
382 return std::make_shared<ForceType4>(ForceType4(id1, x, k, l0));
406 std::shared_ptr<nodes::GeometryNode> >& nodes)
409 nodes.at(this->id1_)->addForce(this->f_ *
410 (nodes.at(this->id2_)->getPos() - nodes.at(this->id1_)->getPos()) /
411 nodes::getDistance(*(nodes.at(this->id2_)), *(nodes.at(this->id1_))));
414 lbm_fail(
"Could not compute and set the forces.");
419 (*stream) << this->type <<
"\t" << this->id1_ <<
"\t" << this->id2_ <<
"\t" << this->f_ <<
"\n";
431 const unsigned int type = 5;
432 const unsigned int id1_;
433 const unsigned int id2_;
442 std::shared_ptr<ForceType5> loadForceType5(std::stringstream*
const stream) {
443 unsigned int type, id1, id2;
445 (*stream) >> type >> id1 >> id2 >> f;
447 return std::make_shared<ForceType5>(ForceType5(id1, id2, f));
471 std::shared_ptr<nodes::GeometryNode> >& nodes)
473 assert(nodes.find(this->id1_) != nodes.end());
474 assert(nodes.find(this->id2_) != nodes.end());
476 nodes.at(this->id1_)->addForce(this->f_ *
477 (nodes.at(this->id2_)->getPos() - nodes.at(this->id1_)->getPos()) /
478 nodes::getDistance(*(nodes.at(this->id2_)), *(nodes.at(this->id1_))));
481 lbm_fail(
"Could not compute and set the forces.");
486 (*stream) << this->type <<
"\t" << this->id1_ <<
"\t" << this->id2_ <<
"\t" << this->f_ <<
"\n";
498 const unsigned int type = 6;
499 const unsigned int id1_;
500 const unsigned int id2_;
509 std::shared_ptr<ForceType6> loadForceType6(std::stringstream*
const stream) {
510 unsigned int type, id1, id2;
512 (*stream) >> type >> id1 >> id2 >> f;
513 return std::make_shared<ForceType6>(ForceType6(id1, id2, f));
540 std::shared_ptr<nodes::GeometryNode> >& nodes)
543 const double f = k_ *
544 (nodes::getDistance(*(nodes.at(this->id2_)),
545 *(nodes.at(this->id1_))) - this->l0_);
547 nodes.at(this->id1_)->addForce(f *
548 (nodes.at(this->id2_)->getPos() - nodes.at(this->id1_)->getPos()) /
549 nodes::getDistance(*(nodes.at(this->id2_)), *(nodes.at(this->id1_))));
552 lbm_fail(
"Could not compute and set the forces.");
557 (*stream) << this->type <<
"\t" << this->id1_ <<
"\t" << this->id2_ <<
"\t" << this->k_ <<
558 "\t" << this->l0_ <<
"\n";
570 const unsigned int type = 7;
571 const unsigned int id1_;
572 const unsigned int id2_;
582 std::shared_ptr<ForceType7> loadForceType7(std::stringstream*
const stream) {
583 unsigned int type, id1, id2;
585 (*stream) >> type >> id1 >> id2 >> k >> l0;
587 return std::make_shared<ForceType7>(ForceType7(id1, id2, k, l0));
598 #endif // FORCESTRUCTS_HPP
unsigned int getPartnerGeometryNode(void) const
getPartnerGeometryNode
a spring force between a node and a horzontal slider (sliding at hight y)
void writeForceStruct(std::ofstream *const stream) const
writes the force struct to the ostream
a spring force between a node and a certain point
void calculateForce(const std::map< unsigned int, std::shared_ptr< nodes::GeometryNode > > &nodes)
calculates the force on the geometry nodes
void writeForceStruct(std::ofstream *const stream) const
writes the force struct to the ostream
ForceType0(unsigned int id1, unsigned int id2, double k, double l0)
the constructor of this force
void calculateForce(const std::map< unsigned int, std::shared_ptr< nodes::GeometryNode > > &nodes)
calculates the force on the geometry nodes
void calculateForce(const std::map< unsigned int, std::shared_ptr< nodes::GeometryNode > > &nodes)
calculates the force on the geometry nodes
unsigned int getType() const
Returns the force type.
ForceType3(unsigned int id1, double y, double k, double l0)
the constructor of this force
void writeForceStruct(std::ofstream *const stream) const
writes the force struct to the ostream
ForceType4(unsigned int id1, double x, double k, double l0)
the constructor of this force
void calculateForce(const std::map< unsigned int, std::shared_ptr< nodes::GeometryNode > > &nodes)
calculates the force on the geometry nodes
void calculateForce(const std::map< unsigned int, std::shared_ptr< nodes::GeometryNode > > &nodes)
calculates the force on the geometry nodes
void calculateForce(const std::map< unsigned int, std::shared_ptr< nodes::GeometryNode > > &nodes)
calculates the force on the geometry nodes
unsigned int getPartnerGeometryNode(void) const
getPartnerGeometryNode
a constant force between 2 nodes
void writeForceStruct(std::ofstream *const stream) const
writes the force struct to the ostream
unsigned int getPartnerGeometryNode(void) const
getPartnerGeometryNode
T x
x the value in x direction
unsigned int getType() const
Returns the force type.
unsigned int getType() const
Returns the force type.
a spring froce between 2 nodes
unsigned int getType() const
Returns the force type.
unsigned int getPartnerGeometryNode(void) const
getPartnerGeometryNode
a constant force between 2 nodes
unsigned int getPartnerGeometryNode(void) const
getPartnerGeometryNode
void writeForceStruct(std::ofstream *const stream) const
writes the force struct to the ostream
unsigned int getType() const
Returns the force type.
unsigned int getPartnerGeometryNode(void) const
getPartnerGeometryNode
unsigned int getPartnerGeometryNode(void) const
getPartnerGeometryNode
unsigned int getType() const
Returns the force type.
unsigned int getType() const
Returns the force type.
ForceType7(unsigned int id1, unsigned int id2, double k, double l0)
the constructor of this force
ForceType5(unsigned int id1, unsigned int id2, double f)
the constructor of this force
ForceType1(unsigned int id1, double x, double y, double k, double l0)
the constructor of this force
unsigned int getType() const
Returns the force type.
the base class for all forces
void writeForceStruct(std::ofstream *const stream) const
writes the force struct to the ostream
a spring force between a node and a vertical slider (sliding at width x)
Field< double > getPos() const
getPos Getter for the pos
void writeForceStruct(std::ofstream *const stream) const
writes the force struct to the ostream
a spring froce between 2 nodes
void calculateForce(const std::map< unsigned int, std::shared_ptr< nodes::GeometryNode > > &nodes)
calculates the force on the geometry nodes
ForceType6(unsigned int id1, unsigned int id2, double f)
the constructor of this force
void calculateForce(const std::map< unsigned int, std::shared_ptr< nodes::GeometryNode > > &nodes)
calculates the force on the geometry nodes
The LagrangianPoint class A class for storing a point's coordinates and its velocity This class is th...
unsigned int getPartnerGeometryNode(void) const
getPartnerGeometryNode
void writeForceStruct(std::ofstream *const stream) const
writes the force struct to the ostream
ForceType2(unsigned int id1, double fx, double fy)
the constructor of this force