Изменение ГУ
This commit is contained in:
@@ -20,7 +20,7 @@ public:
|
||||
double X() const;
|
||||
double Y() const;
|
||||
|
||||
//double Dist(const Node*) const;
|
||||
double Dist(const Node*) const;
|
||||
void LinkX(Node*, Node*);
|
||||
void LinkY(Node*, Node*);
|
||||
Node*& l();
|
||||
@@ -30,8 +30,6 @@ public:
|
||||
void SetT(double);
|
||||
bool IsBound();
|
||||
void SetB(int);
|
||||
|
||||
double operator-(const Node*) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
39
src/Node.cpp
39
src/Node.cpp
@@ -9,64 +9,60 @@ double Node::T() const {
|
||||
if (_btype == 2) {
|
||||
if (!_left)
|
||||
if (_right)
|
||||
return _right->T();
|
||||
return _right->T() / (1 + Dist(_right));
|
||||
if (!_right)
|
||||
if (_left)
|
||||
return _left->T();
|
||||
return _left->T() / (1 + Dist(_left));
|
||||
if (!_above)
|
||||
if (_below)
|
||||
return _below->T();
|
||||
return _below->T() / (1 + Dist(_below));
|
||||
if (!_below)
|
||||
if (_above)
|
||||
return _above->T();
|
||||
return _above->T() / (1 + Dist(_above));
|
||||
if (_right && _left) {
|
||||
if (_right->IsBound())
|
||||
return _left->T();
|
||||
return _right->T();
|
||||
return _left->T() / (1 + Dist(_left));
|
||||
return _right->T() / (1 + Dist(_right));
|
||||
}
|
||||
if (_above && _below) {
|
||||
if (_above->IsBound())
|
||||
return _below->T();
|
||||
return _above->T();
|
||||
return _below->T() / (1 + Dist(_below));
|
||||
return _above->T() / (1 + Dist(_above));
|
||||
}
|
||||
}
|
||||
|
||||
if (_btype == 3) {
|
||||
if (!_left)
|
||||
if (_right)
|
||||
return _right->T() / (1 + this - _right);
|
||||
return _right->T();
|
||||
if (!_right)
|
||||
if (_left)
|
||||
return _left->T() / (1 + this - _left);
|
||||
return _left->T();
|
||||
if (!_above)
|
||||
if (_below)
|
||||
return _below->T() / (1 + this - _below);
|
||||
return _below->T();
|
||||
if (!_below)
|
||||
if (_above)
|
||||
return _above->T() / (1 + this - _above);
|
||||
return _above->T();
|
||||
if (_right && _left) {
|
||||
if (_right->IsBound())
|
||||
return _left->T() / (1 + this - _left);
|
||||
return _right->T() / (1 + this - _right);
|
||||
return _left->T();
|
||||
return _right->T();
|
||||
}
|
||||
if (_above && _below) {
|
||||
if (_above->IsBound())
|
||||
return _below->T() / (1 + this - _below);
|
||||
return _above->T() / (1 + this - _above);
|
||||
return _below->T();
|
||||
return _above->T();
|
||||
}
|
||||
}
|
||||
|
||||
return _t;
|
||||
}
|
||||
|
||||
double Node::operator-(const Node* to) const {
|
||||
double Node::Dist(const Node* to) const {
|
||||
return std::sqrt(pow(X() - to->X(), 2) + pow(Y() - to->Y(), 2));
|
||||
}
|
||||
|
||||
//double Node::Dist(const Node* to) const {
|
||||
// return std::sqrt(pow(X() - to->X(), 2) + pow(Y() - to->Y(), 2));
|
||||
//}
|
||||
|
||||
Node*& Node::l() { return _left; }
|
||||
Node*& Node::r() { return _right; }
|
||||
Node*& Node::u() { return _above; }
|
||||
@@ -88,4 +84,3 @@ void Node::SetT(double t) {
|
||||
|
||||
bool Node::IsBound() { return _btype; }
|
||||
void Node::SetB(int type) { _btype = type; }
|
||||
|
||||
|
||||
@@ -80,8 +80,8 @@ void Solver::SolveImplicit(System& sys, double tstop) const {
|
||||
|
||||
void Solver::SolveLine(System& sys, std::vector<Node*>& n) const {
|
||||
int size = n.size() - 2;
|
||||
double mu1 = (n.front() - n[1]) / sys.step();
|
||||
double mu2 = (n.back() - n[n.size() - 2]) / sys.step();
|
||||
double mu1 = n.front()->Dist(n[1]) / sys.step();
|
||||
double mu2 = n.back()->Dist(n[n.size() - 2]) / sys.step();
|
||||
/* Защита от нуля */
|
||||
if (mu2 == 0.)
|
||||
mu2 = .1;
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -36,12 +36,12 @@ int main()
|
||||
3 - конвекция
|
||||
4 - отсутствует
|
||||
*/
|
||||
int left = 1;
|
||||
int top = 3;
|
||||
int right = 1;
|
||||
int bottom = 3;
|
||||
int arc_bound = 4;
|
||||
int hole_bound = 2;
|
||||
int left = 3;
|
||||
int top = 1;
|
||||
int right = 3;
|
||||
int bottom = 1;
|
||||
int arc_bound = 3;
|
||||
int hole_bound = 1;
|
||||
|
||||
double step_5 = 5;
|
||||
double step_10 = 10;
|
||||
|
||||
Reference in New Issue
Block a user