LBIBCell
 All Classes Functions Variables Friends Pages
LagrangianPoint.cpp
1 /* Copyright (c) 2013 David Sichau <mail"at"sichau"dot"eu>
2  * 2013-2015 Simon Tanaka <tanakas"at"gmx"dot"ch>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 #include <LbmLib/include/nodes/LagrangianPoint.hpp>
23 #include <LbmLib/include/nodes/EulerianPoint.hpp>
24 #include <LbmLib/include/Constants.hpp>
25 #include <UtilLib/include/Log.hpp>
26 #include <UtilLib/include/Exception.hpp>
27 #include <iostream>
28 #include <string>
29 #include <cmath>
30 #include <cassert>
31 #include <iomanip>
32 
33 namespace LbmLib {
34 namespace nodes {
36  double x,
37  double y) : position_(x, y)
38 {
39  assert(std::isfinite(this->position_.x));
40  assert(std::isfinite(this->position_.y));
41 }
42 
44  return this->velocity_.x;
45 }
46 
48  return this->velocity_.y;
49 }
50 
52  assert(std::isfinite(this->velocity_.x));
53  assert(std::isfinite(this->velocity_.y));
54  return this->velocity_;
55 }
56 
57 double LagrangianPoint::getXPos() const {
58  return this->position_.x;
59 }
60 
61 double LagrangianPoint::getYPos() const {
62  return this->position_.y;
63 }
64 
66  return this->position_;
67 }
68 
70  double x,
71  double y) {
72  this->setXPos(x);
73  this->setYPos(y);
74 }
75 
77 {
78  this->position_.x = x;
79  assert(std::isfinite(this->position_.x));
80 }
81 
83 {
84  this->position_.y = y;
85  assert(std::isfinite(this->position_.y));
86 }
87 
88 std::string LagrangianPoint::getType() const {
89  return "LagrangianPoint";
90 }
91 
93  this->velocity_ = velocity;
94  assert(std::isfinite(this->velocity_.x));
95  assert(std::isfinite(this->velocity_.y));
96  if (((this->velocity_.x * this->velocity_.x) + (this->velocity_.y * this->velocity_.y)) > CS) {
97  std::stringstream message;
98  message <<std::setprecision(12);
99  message << "The magnitude of velocity is too high: vx=" << this->velocity_.x << ", vy=" << this->velocity_.y;
100  LOG(UtilLib::logINFO) << message;
101  lbm_fail(message.str().c_str());
102  }
103 }
104 
105 std::ostream& operator<<(
106  std::ostream& ostr,
107  const LagrangianPoint* pt) {
108  ostr << "(" << pt->getXPos() << ":" << pt->getYPos() << ")";
109  return ostr;
110 }
111 }
112 } // end namespace
virtual void setVelocity(Field< double > velocity)
setVelocity Set the velocity
void setYPos(double y)
setYPos Set a new y position.
double getYPos() const
getYPos Getter for the Y position
void setXPos(double x)
setXPos Set a new x position.
T x
x the value in x direction
Definition: Field.hpp:50
LagrangianPoint(double x, double y)
LagrangianPoint Constructs a new point.
virtual std::string getType() const
getType The type of a node class
double getXPos() const
getXPos Getter for the X position
Field< double > getVelocity() const
getVelocity Getter for the velocity
double getXVelocity() const
getXVelocity Getter for x-velocity component
Field< double > getPos() const
getPos Getter for the pos
double getYVelocity() const
getYVelocity Getter for the y-velocity component
T y
y the value in y direction
Definition: Field.hpp:54
The LagrangianPoint class A class for storing a point's coordinates and its velocity This class is th...
virtual void setPos(double x, double y)
setPos Set the position new override this method to change default behaviour