added subdomain indexing for outer edges, for use in robin BC

This commit is contained in:
jakob.schratter 2026-01-24 14:26:22 +01:00
commit 99b46ad7ec
5 changed files with 143 additions and 33 deletions

View file

@ -412,7 +412,7 @@ void FEM_Matrix::CalculateLaplaceMult(vector<double> &f)
auto subdomain = sd_vec[i];
double lambda = ThermalConductivity(subdomain);
cout << subdomain << endl;
//cout << subdomain << endl;
CalcElemSpecific(ia.data() + 3 * i, xc.data(), lambda, ske);
//AddElem(ia.data()+3 * i, ske, fe, _id.data(), _ik.data(), _sk.data(), f.data()); // GH: deprecated
@ -423,9 +423,6 @@ void FEM_Matrix::CalculateLaplaceMult(vector<double> &f)
cout << "finished in " << duration << " sec. ########\n"; // ToDo: change to systemclock
//Debug();
return;
}
@ -583,6 +580,99 @@ void FEM_Matrix::ApplyDirichletBC(std::vector<double> const &u, std::vector<doub
}
void FEM_Matrix::ApplyRobinBC_mult(std::vector<double> const &u, std::vector<double> &f, const double u_out)
{
auto const RobinEdges = _mesh.OuterEdges;
auto const RobinEdgesSubdomains = _mesh.OuterEdgesSubdomains;
for (int i = 0; i < RobinEdges.size(); ++i)
{
cout << "Edge number " << RobinEdges[i] << ", subdomain: " << RobinEdgesSubdomains[i] << endl;
}
// Jakob Todo
auto const idx = _mesh.Index_DirichletNodes(); // ALL boundary nodes
const vector<int> sd_vec = _mesh.ElementSubdomains;
for (int i = 0; i < idx.size(); ++i) {
int const row = idx[i];
int subdomain = sd_vec[row];
// cout << "row: " << row;
// cout << ", subdomain: " << subdomain << endl;
double alpha = Heat_transfer_coefficient(subdomain);
f[row] += u_out*alpha/2;
for (int ij = _id[row]; ij < _id[row + 1]; ++ij)
{
int const col = _ik[ij];
if(col == row)
{
_sk[ij] += alpha/3;
}
else
{
int const id1 = fetch(col, row); // Find entry (col,row)
assert(id1 >= 0);
_sk[id1] += alpha/6;
}
}
}
return;
}
double FEM_Matrix::Heat_transfer_coefficient(const int subdomain)
{
int matlab_sd_index = subdomain - 1;
double alpha = 0.0;
switch (matlab_sd_index)
{
// outside
case 0:
alpha = 1.0;
break;
// ceramic
case 1:
alpha = 1.0;
break;
// water
case 2:
alpha = 1.0;
break;
// air
case 3:
alpha = 1.0;
break;
default:
alpha = 1.0;
break;
}
return alpha;
}
void FEM_Matrix::AddElem_3(int const ial[3], double const ske[3][3], double const fe[3], vector<double> &f)
{