Skip to content

Commit

Permalink
Fixed double indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
larsson4 committed Mar 1, 2024
1 parent db5df52 commit 3ab7232
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/linelast_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LinElastSolver : public MultiBlockSolver
VectorFunctionCoefficient *init_x = NULL;

// Boundary condition types
Array<LinElastProblem::BoundaryType> bdr_type;
Array<LinElastProblem::BoundaryType> type_idx;

public:
LinElastSolver();
Expand Down
44 changes: 25 additions & 19 deletions src/linelast_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ void LinElastSolver::SetupBCVariables()
bdr_coeffs.SetSize(numBdr);
bdr_coeffs = NULL;

bdr_type.SetSize(numBdr);
bdr_type = -1;

type_idx.SetSize(numBdr);
type_idx = 0;
type_idx = LinElastProblem::BoundaryType::DIRICHLET;

lambda_c.SetSize(numSub);
lambda_c = NULL;
Expand Down Expand Up @@ -181,11 +178,11 @@ void LinElastSolver::SetupRHSBCOperators()
if (!BCExistsOnBdr(b))
continue;

if ( bdr_type[type_idx[b]] == -1 || bdr_type[type_idx[b]] == LinElastProblem::BoundaryType::DIRICHLET) // Default behavior
if (type_idx[b] == LinElastProblem::BoundaryType::DIRICHLET) // Default behavior
{
bs[m]->AddBdrFaceIntegrator(new DGElasticityDirichletLFIntegrator(*bdr_coeffs[b], *lambda_c[m], *mu_c[m], alpha, kappa), *bdr_markers[b]);
bs[m]->AddBdrFaceIntegrator(new DGElasticityDirichletLFIntegrator(*bdr_coeffs[b], *lambda_c[m], *mu_c[m], alpha, kappa), *bdr_markers[b]);
}
else if (bdr_type[type_idx[b]] == LinElastProblem::BoundaryType::NEUMANN)
else if (type_idx[b] == LinElastProblem::BoundaryType::NEUMANN)
{
bs[m]->AddBdrFaceIntegrator(new VectorBoundaryLFIntegrator(*bdr_coeffs[b]), *bdr_markers[b]);
}
Expand Down Expand Up @@ -425,7 +422,7 @@ void LinElastSolver::SetupDomainBCOperators()
continue;
if (!BCExistsOnBdr(b))
continue;
if (bdr_type[type_idx[b]] != LinElastProblem::BoundaryType::NEUMANN)
if (type_idx[b] != LinElastProblem::BoundaryType::NEUMANN)
as[m]->AddBdrFaceIntegrator(new DGElasticityIntegrator(*(lambda_c[m]), *(mu_c[m]), alpha, kappa), *(bdr_markers[b]));
}
}
Expand Down Expand Up @@ -453,16 +450,26 @@ void LinElastSolver::SetParameterizedProblem(ParameterizedProblem *problem)
}

// Set BCs, the switch on BC type is done inside SetupRHSBCOperators
for (int b = 0; b < problem->battr.Size(); b++)
for (int b = 0; b < global_bdr_attributes.Size(); b++)
{
bdr_type[b] = problem->bdr_type[b];
int ti = global_bdr_attributes.Find(problem->battr[b]);
type_idx[ti] = b;

if(problem->bdr_type[b] == LinElastProblem::BoundaryType::DIRICHLET || problem->bdr_type[b] == LinElastProblem::BoundaryType::NEUMANN)
{ assert(problem->vector_bdr_ptr[b]);
AddBCFunction(*(problem->vector_bdr_ptr[b]), problem->battr[b]);
}
int ti = problem->battr.Find(global_bdr_attributes[b]);
assert(ti >=0);
type_idx[b] = (LinElastProblem::BoundaryType)problem->bdr_type[ti];
;
switch (problem->bdr_type[ti])
{
case LinElastProblem::BoundaryType::DIRICHLET:
assert(problem->vector_bdr_ptr[ti]);

AddBCFunction(*(problem->vector_bdr_ptr[ti]), problem->battr[ti]);
break;
case LinElastProblem::BoundaryType::NEUMANN:
assert(problem->vector_bdr_ptr[ti]);
AddBCFunction(*(problem->vector_bdr_ptr[ti]), problem->battr[ti]);

default:
break;
}
}

// Set RHS
Expand Down Expand Up @@ -535,8 +542,7 @@ void LinElastSolver::BuildBdrROMElement(Array<FiniteElementSpace *> &fes_comp)
bdr_marker[comp->bdr_attributes[b] - 1] = 1;
BilinearForm a_comp(fes_comp[c]);

int gidx = global_bdr_attributes.Find(comp->bdr_attributes[b]);
if (bdr_type[type_idx[gidx]] != LinElastProblem::BoundaryType::NEUMANN)
if ((LinElastProblem::BoundaryType)comp->bdr_attributes[b] != LinElastProblem::BoundaryType::NEUMANN)
a_comp.AddBdrFaceIntegrator(new DGElasticityIntegrator(*(lambda_c[c]), *(mu_c[c]), alpha, kappa), bdr_marker);

a_comp.Assemble();
Expand Down

0 comments on commit 3ab7232

Please sign in to comment.