made better
This commit is contained in:
parent
c39a976ebd
commit
1151fb33b2
4 changed files with 56 additions and 14 deletions
|
|
@ -496,14 +496,13 @@ void Mesh::Visualize_paraview(vector<double> const &v) const
|
|||
return;
|
||||
}
|
||||
|
||||
std::tuple<double,double> Mesh::AverageVectorFunction_perSubdomain(std::vector<double> &v, int target_sd) const
|
||||
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
|
||||
{
|
||||
|
|
@ -519,16 +518,41 @@ std::tuple<double,double> Mesh::AverageVectorFunction_perSubdomain(std::vector<d
|
|||
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
|
||||
return cumulative_element_temp/subdomain_element_counter;
|
||||
}
|
||||
|
||||
double Mesh::CheckTemp_mult(std::vector<double> &v, int target_sd, double goal_temp) const
|
||||
{
|
||||
assert(2==Ndims());
|
||||
int const nnode = Nnodes(); // number of vertices in mesh
|
||||
assert( nnode == static_cast<int>(v.size()) );
|
||||
|
||||
double elements_temp_reached = 0.0;
|
||||
int subdomain_element_counter = 0;
|
||||
for (int e = 0; e < Nelems(); ++e) // loop over all elements
|
||||
{
|
||||
int sd = ElementSubdomains[e]; // get subdomain of element e
|
||||
if (sd == target_sd) // if is target subdomain then
|
||||
{
|
||||
subdomain_element_counter++;
|
||||
int base = e * _nvert_e; // get starting index of element in coordinate vector
|
||||
double cumulative_node_temp = 0.0;
|
||||
for (int k = 0; k < _nvert_e; ++k) // loop over vertices of element
|
||||
{
|
||||
elements_temp_reached++; // add to counter
|
||||
int node = _ia[base + k]; // global index of vertex
|
||||
cumulative_node_temp += v[node]; // set function
|
||||
}
|
||||
if (cumulative_node_temp/_nvert_e > goal_temp)
|
||||
{
|
||||
elements_temp_reached++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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));
|
||||
|
||||
return 100 * elements_temp_reached / subdomain_element_counter;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue