Skip to content

Commit

Permalink
Cleaner version
Browse files Browse the repository at this point in the history
  • Loading branch information
larsson4 committed Mar 1, 2024
1 parent 3ab7232 commit 50fcc96
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
27 changes: 16 additions & 11 deletions src/linelast_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ bool LinElastSolver::BCExistsOnBdr(const int &global_battr_idx)
{
assert((global_battr_idx >= 0) && (global_battr_idx < global_bdr_attributes.Size()));
assert(bdr_coeffs.Size() == global_bdr_attributes.Size());
return (bdr_coeffs[global_battr_idx]);
if(type_idx[global_battr_idx] == LinElastProblem::BoundaryType::NEUMANN)
return false;
else
return (bdr_coeffs[global_battr_idx]);
}

void LinElastSolver::BuildRHSOperators()
Expand All @@ -175,17 +178,19 @@ void LinElastSolver::SetupRHSBCOperators()
int idx = meshes[m]->bdr_attributes.Find(global_bdr_attributes[b]);
if (idx < 0)
continue;

if (type_idx[b] == LinElastProblem::BoundaryType::NEUMANN)
{
bs[m]->AddBdrFaceIntegrator(new VectorBoundaryLFIntegrator(*bdr_coeffs[b]), *bdr_markers[b]);
}

if (!BCExistsOnBdr(b))
continue;

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]);
}
else if (type_idx[b] == LinElastProblem::BoundaryType::NEUMANN)
{
bs[m]->AddBdrFaceIntegrator(new VectorBoundaryLFIntegrator(*bdr_coeffs[b]), *bdr_markers[b]);
}
}
}
}
Expand Down Expand Up @@ -375,7 +380,7 @@ bool LinElastSolver::Solve()
}

return converged;
}
}

void LinElastSolver::AddBCFunction(std::function<void(const Vector &, Vector &)> F, const int battr)
{
Expand Down Expand Up @@ -422,7 +427,6 @@ void LinElastSolver::SetupDomainBCOperators()
continue;
if (!BCExistsOnBdr(b))
continue;
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,9 +457,10 @@ void LinElastSolver::SetParameterizedProblem(ParameterizedProblem *problem)
for (int b = 0; b < global_bdr_attributes.Size(); b++)
{
int ti = problem->battr.Find(global_bdr_attributes[b]);
assert(ti >=0);

if (ti >=0)
{
type_idx[b] = (LinElastProblem::BoundaryType)problem->bdr_type[ti];
;
switch (problem->bdr_type[ti])
{
case LinElastProblem::BoundaryType::DIRICHLET:
Expand All @@ -470,6 +475,8 @@ void LinElastSolver::SetParameterizedProblem(ParameterizedProblem *problem)
default:
break;
}
}

}

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

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
13 changes: 9 additions & 4 deletions src/parameterized_problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,19 @@ LinElastDisp::LinElastDisp()
: LinElastProblem()
{
// pointer to static function.
bdr_type.SetSize(2);
battr.SetSize(2);
vector_bdr_ptr.SetSize(2);
bdr_type.SetSize(3);
battr.SetSize(3);
vector_bdr_ptr.SetSize(3);
for (size_t i = 0; i < vector_bdr_ptr.Size(); i++)
{
bdr_type[i] = LinElastProblem::DIRICHLET;
battr[i] = i+1;
vector_bdr_ptr[i] = &(function_factory::linelast_disp::init_disp);
}

battr[2] = 3;
bdr_type[2] = LinElastProblem::ZERO;
vector_bdr_ptr[2] = NULL;

// Set materials
general_scalar_ptr.SetSize(2);
Expand Down Expand Up @@ -636,6 +640,7 @@ LinElastDispLCantilever::LinElastDispLCantilever()
vector_bdr_ptr.SetSize(3);
for (size_t i = 0; i < 2; i++)
{
battr[i] = i+1;
bdr_type[i] = LinElastProblem::DIRICHLET;
vector_bdr_ptr[i] = &(function_factory::linelast_disp::init_disp_lcantilever);
}
Expand Down Expand Up @@ -753,4 +758,4 @@ LinElastForceCantilever::LinElastForceCantilever()

general_vector_ptr.SetSize(1);
general_vector_ptr[0] = NULL;
}
}

0 comments on commit 50fcc96

Please sign in to comment.