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;
|
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
|
vector<int> Mesh::Index_DirichletNodes() const
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,9 @@ public:
|
||||||
[[nodiscard]] virtual std::vector<int> Index_DirichletNodes() const;
|
[[nodiscard]] virtual std::vector<int> Index_DirichletNodes() const;
|
||||||
|
|
||||||
|
|
||||||
|
[[nodiscard]] double AverageVectorFunction_perSubdomain(std::vector<double> &v, int target_sd) const;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the indices of those vertices with Dirichlet boundary conditions.
|
* Determines the indices of those vertices with Dirichlet boundary conditions.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -433,7 +433,7 @@ double FEM_Matrix::ThermalConductivity(const int subdomain)
|
||||||
{
|
{
|
||||||
// ceramic mug
|
// ceramic mug
|
||||||
case 0:
|
case 0:
|
||||||
lambda = 3.0; // anything from 1 to 4
|
lambda = 4.0; // anything from 1 to 4
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// water
|
// water
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ int main(int argc, char **argv )
|
||||||
// ##########################################
|
// ##########################################
|
||||||
|
|
||||||
double dt = 1.0; // time step
|
double dt = 1.0; // time step
|
||||||
int steps = 20; // number of time iterations
|
//int steps = 200; // number of time iterations
|
||||||
|
|
||||||
double u0_mug = 18.0;
|
double u0_mug = 18.0;
|
||||||
double u0_fluid = 80.0;
|
double u0_fluid = 80.0;
|
||||||
|
|
@ -76,9 +76,12 @@ int main(int argc, char **argv )
|
||||||
mesh_c.Init_Solution_mult(uv, 1, [u0_fluid](double x, double y) -> double { return u0_fluid; }); // fluid
|
mesh_c.Init_Solution_mult(uv, 1, [u0_fluid](double x, double y) -> double { return u0_fluid; }); // fluid
|
||||||
mesh_c.Init_Solution_mult(uv, 2, [u0_air](double x, double y) -> double { return u0_air; }); // air
|
mesh_c.Init_Solution_mult(uv, 2, [u0_air](double x, double y) -> double { return u0_air; }); // air
|
||||||
|
|
||||||
|
//mesh_c.Visualize(uv);
|
||||||
|
|
||||||
auto t3 = system_clock::now(); // start timer
|
auto t3 = system_clock::now(); // start timer
|
||||||
for (int step = 0; step < steps; ++step)
|
double average_cup_temperature = u0_mug;
|
||||||
|
while (average_cup_temperature < 67)
|
||||||
|
//for (int step = 0; step < steps; ++step)
|
||||||
{
|
{
|
||||||
vector<double> G(Mdt.Nrows(), 0.0);
|
vector<double> G(Mdt.Nrows(), 0.0);
|
||||||
Mdt.Mult(G, uv); // G = M/dt * u_{n}
|
Mdt.Mult(G, uv); // G = M/dt * u_{n}
|
||||||
|
|
@ -91,6 +94,9 @@ int main(int argc, char **argv )
|
||||||
|
|
||||||
JacobiSolve(SK, H, uv); // solve: (M/dt + K + C) * u_{n+1} = F + M/dt * u_{n}
|
JacobiSolve(SK, H, uv); // solve: (M/dt + K + C) * u_{n+1} = F + M/dt * u_{n}
|
||||||
// ----- SK ----- ------ H -------
|
// ----- SK ----- ------ H -------
|
||||||
|
|
||||||
|
average_cup_temperature = mesh_c.AverageVectorFunction_perSubdomain(uv, 0);
|
||||||
|
cout << "Average cup temperature: " << average_cup_temperature << endl;
|
||||||
}
|
}
|
||||||
auto t4 = system_clock::now(); // stop timer
|
auto t4 = system_clock::now(); // stop timer
|
||||||
|
|
||||||
|
|
|
||||||
10730
mgrid_2/uv.txt
10730
mgrid_2/uv.txt
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue