Пример #1
0
void WarmCallInfo::print() const {
  tty->print("%s : C=%6.1f P=%6.1f W=%6.1f S=%6.1f H=%6.1f -> %p",
             is_cold() ? "cold" : is_hot() ? "hot " : "warm",
             count(), profit(), work(), size(), compute_heat(), next());
  tty->cr();
  if (call() != NULL)  call()->dump();
}
void GeodesicInHeat::compute_distance(const Vertex& start_vertex)
{
	int n = mesh.n_vertices();
	int start_idx = start_vertex.idx();
	VecN delta(n);
	delta.setZero();
	delta(start_idx) =1.0f;

	//The laplacian, gradient divergence matrix only need to compute once.
	if (!initialized)
		initialization();
	float timestep = avglength*avglength*factor;
	VecN uNeumann = compute_heat(delta,Laplacian, AreaMatrix,timestep);
	VecN uDirichlet = compute_heat(delta, LaplacianDirichlet, AreaMatrix, timestep);
	VecN u =0.5*uNeumann+0.5*uDirichlet;

	//Method::the three boundary function will active one, if all false, display the average.
	if (Neumann)
		u = uNeumann;
	if (Dirichlet)
		u = uDirichlet;
	MatMxN X = compute_gradient(Grad_x, Grad_y, Grad_z, u);
	VecN div_X = compute_divergence(Div_x, Div_y, Div_z, X);

	Eigen::SimplicialCholesky<Sparse, Eigen::RowMajor> Solver;
	Solver.compute(Laplacian);
	VecN phi = Solver.solve(div_X);	
	
	//shift phi and find out the Max G, Min G and the Max geodesic distance span along edge.
	for (auto const& vertex : mesh.vertices())
	{
		float d1 = phi[vertex.idx()];
		HeatDisplay[vertex] = d1;
		float d2 = 0.0;
		for (auto const& vj : mesh.vertices(vertex))
		{
			float d = std::abs(phi[vertex.idx()] - phi[vj.idx()]);
			if (d > d2)
				d2 = d;
		}
		if (d1 > MaxGeodesic)
			MaxGeodesic = d1;
		if (d2 > MaxEdgeSpan)
			MaxEdgeSpan = d2;
		if (d1 < MinGeodesic)
			MinGeodesic = d1;
	}
	
	for (auto const& vertex : mesh.vertices())
	{
		HeatDisplay[vertex] = HeatDisplay[vertex] - MinGeodesic;
		HeatDistance[vertex] = HeatDisplay[vertex];
	}
	MaxGeodesic -= MinGeodesic;
	MinGeodesic = 0;

	if (Neumann) {
		mLogger() << "Heat: Neumann Boudary Condition, M=" << factor;
		return;
	}
	if (Dirichlet) {
		mLogger() << "Heat: Dirichlet Boudary Condition, M=" << factor;
		return;
	}
	mLogger() << "Heat: Average Boudary Condition, M=" << factor;
}