tmp update
This commit is contained in:
@@ -8,23 +8,22 @@
|
||||
#include "algorithm"
|
||||
#include "ctime"
|
||||
|
||||
#include "gctl/gctl_stream.h"
|
||||
#include "gctl/gctl_heapsort.h"
|
||||
#include "gctl/gctl_geometry2d.h"
|
||||
#include "gctl/gctl_triangle_io.h"
|
||||
#include "gctl/core.h"
|
||||
#include "gctl/geometry.h"
|
||||
#include "gctl/io.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct vertex;
|
||||
struct ele;
|
||||
|
||||
struct source : public gctl::point2d_c
|
||||
struct source : public gctl::point2dc
|
||||
{
|
||||
double rad;
|
||||
double slow;
|
||||
};
|
||||
|
||||
struct vertex : public gctl::vertex2d_c
|
||||
struct vertex : public gctl::vertex2dc
|
||||
{
|
||||
int tag = 0; //0 = far away, 1 = close, 2 = active
|
||||
double slow; // slow are constant within a element. a mean value must be set in local update
|
||||
@@ -152,14 +151,14 @@ int FMM_2D_TRIANGLE::ReadFiles(char* filename)
|
||||
clog << "reading node file:\t" << full_name;
|
||||
|
||||
getline(infile,temp_str);
|
||||
temp_ss = gctl::str2ss(temp_str);
|
||||
gctl::str2ss(temp_str, temp_ss);
|
||||
temp_ss >> node_num_;
|
||||
|
||||
nodes_.resize(node_num_);
|
||||
for (int i = 0; i < node_num_; i++)
|
||||
{
|
||||
getline(infile,temp_str);
|
||||
temp_ss = gctl::str2ss(temp_str);
|
||||
gctl::str2ss(temp_str, temp_ss);
|
||||
temp_ss >> nodes_[i].id >> nodes_[i].x >> nodes_[i].y;
|
||||
}
|
||||
infile.close();
|
||||
@@ -182,14 +181,14 @@ int FMM_2D_TRIANGLE::ReadFiles(char* filename)
|
||||
clog << "reading element file:\t" << full_name;
|
||||
|
||||
getline(infile,temp_str);
|
||||
temp_ss = gctl::str2ss(temp_str);
|
||||
gctl::str2ss(temp_str, temp_ss);
|
||||
temp_ss >> ele_num_;
|
||||
|
||||
elements_.resize(ele_num_);
|
||||
for (int i = 0; i < ele_num_; i++)
|
||||
{
|
||||
getline(infile,temp_str);
|
||||
temp_ss = gctl::str2ss(temp_str);
|
||||
gctl::str2ss(temp_str, temp_ss);
|
||||
temp_ss >> elements_[i].id >> tmp_ids[0] >> tmp_ids[1] >> tmp_ids[2];
|
||||
elements_[i].vec_ptr[0] = &nodes_[tmp_ids[0]];
|
||||
elements_[i].vec_ptr[1] = &nodes_[tmp_ids[1]];
|
||||
@@ -201,7 +200,7 @@ int FMM_2D_TRIANGLE::ReadFiles(char* filename)
|
||||
}
|
||||
|
||||
// reorder the vertice sequence to anti-clockwise
|
||||
gctl::point2d_c v01, v02;
|
||||
gctl::point2dc v01, v02;
|
||||
vertex *tmp_ptr;
|
||||
for (int i = 0; i < ele_num_; i++)
|
||||
{
|
||||
@@ -226,7 +225,7 @@ int FMM_2D_TRIANGLE::ReadFiles(char* filename)
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
// opposite edge length of vertex j
|
||||
elements_[i].edge_l[j] = gctl::geometry2d::distance(elements_[i].vec_ptr[(j+1)%3], elements_[i].vec_ptr[(j+2)%3]);
|
||||
elements_[i].edge_l[j] = gctl::distance(*elements_[i].vec_ptr[(j+1)%3], *elements_[i].vec_ptr[(j+2)%3]);
|
||||
}
|
||||
|
||||
// calculate triangle's area
|
||||
@@ -420,7 +419,7 @@ void FMM_2D_TRIANGLE::CalculateSolution()
|
||||
//this calculation is only valid for testing when there is no abnormal slowness or obstacles.
|
||||
for (int i = 0; i < node_num_; i++)
|
||||
{
|
||||
nodes_[i].syn_time = gctl::geometry2d::distance(&nodes_[i], &init_source_) * init_source_.slow;
|
||||
nodes_[i].syn_time = gctl::distance(nodes_[i], init_source_) * init_source_.slow;
|
||||
}
|
||||
|
||||
//initialize source nodes and close nodes
|
||||
@@ -428,10 +427,10 @@ void FMM_2D_TRIANGLE::CalculateSolution()
|
||||
//and calculate node's time as direct arrival time
|
||||
for (int i = 0; i < node_num_; i++)
|
||||
{
|
||||
if (gctl::geometry2d::distance(&nodes_[i], &init_source_) <= init_source_.rad)
|
||||
if (gctl::distance(nodes_[i], init_source_) <= init_source_.rad)
|
||||
{
|
||||
nodes_[i].tag = 2;
|
||||
nodes_[i].time = gctl::geometry2d::distance(&nodes_[i], &init_source_) * init_source_.slow;
|
||||
nodes_[i].time = gctl::distance(nodes_[i], init_source_) * init_source_.slow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,9 +473,8 @@ void FMM_2D_TRIANGLE::CalculateSolution()
|
||||
while (!nodes_ptr_.empty())
|
||||
{
|
||||
// heap sort close nodes pointers to put a node at the first place if it has the smallest time
|
||||
time_sorter.execute(&nodes_ptr_, [](vector<vertex*> *a, int l_id, int r_id)->bool{
|
||||
if (a->at(l_id)->time < a->at(r_id)->time) return true;
|
||||
else return false;
|
||||
std::sort(nodes_ptr_.begin(), nodes_ptr_.end(), [](vertex *a, vertex *b)->bool{
|
||||
if (a->time < b->time) return true; return false;
|
||||
});
|
||||
|
||||
//change the first node's tag to 2 and update it's neighbor's time if it is not active (tag != 2)
|
||||
@@ -554,11 +552,12 @@ int main(int argc, char* argv[])
|
||||
double ab_slow, ab_xmin, ab_xmax, ab_ymin, ab_ymax;
|
||||
string all_ab_para, old_ab_para;
|
||||
string tmp_str;
|
||||
stringstream tmp_ss;
|
||||
if (argc >= 5)
|
||||
{
|
||||
old_ab_para = argv[4];
|
||||
gctl::replace_all(all_ab_para, old_ab_para, ",", " ");
|
||||
stringstream tmp_ss = gctl::str2ss(all_ab_para);
|
||||
gctl::str2ss(all_ab_para, tmp_ss);
|
||||
while (tmp_ss >> tmp_str)
|
||||
{
|
||||
if (5 != sscanf(tmp_str.c_str(), "%lf/%lf/%lf/%lf/%lf",
|
||||
|
||||
Reference in New Issue
Block a user