calculate average temperature in mug
This commit is contained in:
parent
bbceb5cf06
commit
e458b93b28
5 changed files with 5398 additions and 5361 deletions
|
|
@ -496,6 +496,34 @@ void Mesh::Visualize_paraview(vector<double> const &v) const
|
|||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
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
|
||||
{
|
||||
int node = _ia[base + k]; // global index of vertex
|
||||
cumulative_node_temp += v[node]; // set function
|
||||
}
|
||||
cumulative_element_temp += cumulative_node_temp/_nvert_e;
|
||||
}
|
||||
}
|
||||
|
||||
return cumulative_element_temp/subdomain_element_counter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
vector<int> Mesh::Index_DirichletNodes() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue