add another 67 degree break condition

This commit is contained in:
dino.celebic 2026-01-26 17:24:33 +01:00
commit c39a976ebd
5 changed files with 17 additions and 7 deletions

View file

@ -496,13 +496,14 @@ void Mesh::Visualize_paraview(vector<double> const &v) const
return;
}
double Mesh::AverageVectorFunction_perSubdomain(std::vector<double> &v, int target_sd) const
std::tuple<double,double> Mesh::AverageVectorFunction_perSubdomain(std::vector<double> &v, int target_sd) const
{
assert(2==Ndims());
int const nnode = Nnodes(); // number of vertices in mesh
assert( nnode == static_cast<int>(v.size()) );
double cumulative_element_temp = 0.0;
double elements_temp_reached = 0.0;
int subdomain_element_counter = 0;
for (int e = 0; e < Nelems(); ++e) // loop over all elements
{
@ -518,14 +519,19 @@ double Mesh::AverageVectorFunction_perSubdomain(std::vector<double> &v, int targ
cumulative_node_temp += v[node]; // set function
}
cumulative_element_temp += cumulative_node_temp/_nvert_e;
if (cumulative_node_temp/_nvert_e > 67.0) // check if element has reached temp
{
elements_temp_reached++; // add to counter
}
}
}
return cumulative_element_temp/subdomain_element_counter;
// average temperature % of elements reached temperature 67
return std::make_tuple(cumulative_element_temp/subdomain_element_counter, 100 * elements_temp_reached / static_cast<double>(subdomain_element_counter));
}
vector<int> Mesh::Index_DirichletNodes() const
{
assert(2==Ndims()); // not in 3D currently

View file

@ -231,9 +231,8 @@ public:
[[nodiscard]] virtual std::vector<int> Index_DirichletNodes() const;
[[nodiscard]] double AverageVectorFunction_perSubdomain(std::vector<double> &v, int target_sd) const;
[[nodiscard]] std::tuple<double,double> AverageVectorFunction_perSubdomain(std::vector<double> &v, int target_sd) const;
/**
* Determines the indices of those vertices with Dirichlet boundary conditions.
*

View file

@ -83,9 +83,11 @@ int main(int argc, char **argv )
auto t3 = system_clock::now(); // start timer
double average_cup_temperature = u0_mug;
double percentage_temp_reached = 0.0;
double time_count = 0;
while (average_cup_temperature < 67.0)
// while (percentage_temp_reached < 60.0)
//for (int step = 0; step < steps; ++step)
{
vector<double> G(Mdt.Nrows(), 0.0);
@ -100,8 +102,9 @@ int main(int argc, char **argv )
JacobiSolve(SK, H, uv); // solve: (M/dt + K + C) * u_{n+1} = F + M/dt * u_{n}
// ----- SK ----- ------ H -------
average_cup_temperature = mesh_c.AverageVectorFunction_perSubdomain(uv, 0);
tie(average_cup_temperature, percentage_temp_reached) = mesh_c.AverageVectorFunction_perSubdomain(uv, 0);
cout << "Average cup temperature: " << average_cup_temperature << " after " << time_count << " seconds. " << endl;
cout << "% of mug elements reached temperature 67º: " << percentage_temp_reached << endl;
time_count += dt;
}
auto t4 = system_clock::now(); // stop timer

View file

@ -23,6 +23,7 @@ h = patch('Faces', ia, 'Vertices', xc, 'FaceVertexCData', v, ...
axis equal tight;
colorbar;
colormap(jet);
caxis([18 85]);
title('Heat distribution');
waitfor(h) % wait for closing the figure