fixed robin BC
This commit is contained in:
parent
decfe1d710
commit
bbceb5cf06
8 changed files with 47974 additions and 1832 deletions
|
|
@ -598,11 +598,11 @@ void FEM_Matrix::ApplyDirichletBC(std::vector<double> const &u, std::vector<doub
|
|||
int const row = idx[i];
|
||||
for (int ij = _id[row]; ij < _id[row + 1]; ++ij) {
|
||||
int const col = _ik[ij];
|
||||
if (col == row) {
|
||||
if (col == row) { // then col = _ik[_id[row]]
|
||||
_sk[ij] = 1.0;
|
||||
f[row] = u[row];
|
||||
}
|
||||
else {
|
||||
else { // col != row, then
|
||||
int const id1 = fetch(col, row); // Find entry (col,row)
|
||||
assert(id1 >= 0);
|
||||
f[col] -= _sk[id1] * u[row];
|
||||
|
|
@ -620,43 +620,46 @@ void FEM_Matrix::ApplyRobinBC_mult(std::vector<double> &f, const double u_out)
|
|||
{
|
||||
auto const RobinEdges = _mesh.OuterEdges;
|
||||
auto const RobinEdgesSubdomains = _mesh.OuterEdgesSubdomains;
|
||||
auto const RobinEdgeNodes = _mesh.OuterEdgesNodes;
|
||||
assert(RobinEdgeNodes.size() == 2 * RobinEdges.size());
|
||||
|
||||
auto const BoundaryEdges = _mesh.BoundaryEdges();
|
||||
auto const BoundaryEdgeNodes = _mesh.BoundaryEdgeNodes();
|
||||
|
||||
assert (BoundaryEdgeNodes.size() == 2* BoundaryEdges.size());
|
||||
|
||||
vector<double> Coordinates = _mesh.GetCoords();
|
||||
vector<double> const Coordinates = _mesh.GetCoords();
|
||||
|
||||
for (size_t i = 0; i < RobinEdges.size(); ++i)
|
||||
{
|
||||
//cout << "Edge number " << RobinEdges[i] << ", subdomain: " << RobinEdgesSubdomains[i] << " " << endl;
|
||||
double alpha = Heat_transfer_coefficient(RobinEdgesSubdomains[i]);
|
||||
int const subdomain = RobinEdgesSubdomains[i];
|
||||
double const alpha = Heat_transfer_coefficient(subdomain);
|
||||
|
||||
//int const EdgeNumber = RobinEdges[i];
|
||||
|
||||
int const EdgeNode1 = BoundaryEdgeNodes[2*i];
|
||||
int const EdgeNode2 = BoundaryEdgeNodes[2*i + 1];
|
||||
int const EdgeNode1 = RobinEdgeNodes[2*i];
|
||||
int const EdgeNode2 = RobinEdgeNodes[2*i + 1];
|
||||
|
||||
//cout << "Edge number " << EdgeNumber << ", subdomain: " << subdomain << " ";
|
||||
//cout << "Node1: " << EdgeNode1 << " Node2: " << EdgeNode2 << " " << endl;
|
||||
|
||||
double x_1 = Coordinates[2*EdgeNode1];
|
||||
double y_1 = Coordinates[2*EdgeNode1 + 1];
|
||||
double x_2 = Coordinates[2*EdgeNode2];
|
||||
double y_2 = Coordinates[2*EdgeNode2 + 1];
|
||||
|
||||
double x_1 = Coordinates[EdgeNode1];
|
||||
double y_1 = Coordinates[EdgeNode1 + 1];
|
||||
double x_2 = Coordinates[EdgeNode2];
|
||||
double y_2 = Coordinates[EdgeNode2 + 1];
|
||||
double EdgeLength = sqrt((x_2 - x_1)*(x_2 - x_1) + (y_2 - y_1)*(y_2 - y_1));
|
||||
//cout << EdgeLength << endl;
|
||||
|
||||
int ii = fetch(EdgeNode1, EdgeNode1);
|
||||
int jj = fetch(EdgeNode2, EdgeNode2);
|
||||
int ij = fetch(EdgeNode1, EdgeNode2);
|
||||
int ji = fetch(EdgeNode2, EdgeNode1);
|
||||
|
||||
|
||||
int ii = _id[EdgeNode1];
|
||||
int jj = _id[EdgeNode2];
|
||||
int ij = fetch(_ik[_id[EdgeNode1]], EdgeNode1);
|
||||
int ji = fetch(_ik[_id[EdgeNode2]], EdgeNode2);
|
||||
cout << "ii: " << ii << ", jj: " << jj << ", ij: " << ij << ", ji: " << ji << endl;
|
||||
|
||||
_sk[ii] += EdgeLength*alpha/3;
|
||||
_sk[jj] += EdgeLength*alpha/3;
|
||||
_sk[ij] += EdgeLength*alpha/6;
|
||||
_sk[ji] += EdgeLength*alpha/6;
|
||||
|
||||
f[ii] += EdgeLength*alpha*u_out/2;
|
||||
f[jj] += EdgeLength*alpha*u_out/2;
|
||||
f[EdgeNode1] += EdgeLength*alpha*u_out/2;
|
||||
f[EdgeNode2] += EdgeLength*alpha*u_out/2;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue