Skip to content

Commit

Permalink
Merge pull request #1209 from LLNL/mish2/remove_dead_boundary_conditi…
Browse files Browse the repository at this point in the history
…on_code

remove dead boundary condition code
  • Loading branch information
chapman39 authored Sep 18, 2024
2 parents e86f702 + 019bffb commit af22df5
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 397 deletions.
33 changes: 0 additions & 33 deletions src/serac/infrastructure/tests/error_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,39 +57,6 @@ TEST(ErrorHandling, BcOneComponentVectorCoefDofs)
EXPECT_THROW(BoundaryCondition(coef, 0, *space, dofs), SlicErrorException);
}

TEST(ErrorHandling, BcRetrieveScalarCoef)
{
auto mesh = mesh::refineAndDistribute(buildDiskMesh(10), 0, 0);

auto [space, coll] = serac::generateParFiniteElementSpace<H1<1>>(mesh.get());

auto coef = std::make_shared<mfem::ConstantCoefficient>(1.0);
BoundaryCondition bc(coef, -1, *space, std::set<int>{});
EXPECT_NO_THROW(bc.scalarCoefficient());
EXPECT_THROW(bc.vectorCoefficient(), SlicErrorException);

const auto& const_bc = bc;
EXPECT_NO_THROW(const_bc.scalarCoefficient());
EXPECT_THROW(const_bc.vectorCoefficient(), SlicErrorException);
}

TEST(ErrorHandling, BcRetrieveVecCoef)
{
auto mesh = mesh::refineAndDistribute(buildDiskMesh(10), 0, 0);

auto [space, coll] = serac::generateParFiniteElementSpace<H1<1>>(mesh.get());

mfem::Vector vec;
auto coef = std::make_shared<mfem::VectorConstantCoefficient>(vec);
BoundaryCondition bc(coef, {}, *space, std::set<int>{});
EXPECT_NO_THROW(bc.vectorCoefficient());
EXPECT_THROW(bc.scalarCoefficient(), SlicErrorException);

const auto& const_bc = bc;
EXPECT_NO_THROW(const_bc.vectorCoefficient());
EXPECT_THROW(const_bc.scalarCoefficient(), SlicErrorException);
}

TEST(ErrorHandling, InvalidCmdlineArg)
{
// The command is actually --input-file
Expand Down
59 changes: 0 additions & 59 deletions src/serac/physics/boundary_conditions/boundary_condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,6 @@ void BoundaryCondition::setTrueDofList(const mfem::Array<int>& true_dofs)
mfem::FiniteElementSpace::MarkerToList(local_dof_marker, local_dofs_);
}

void BoundaryCondition::setLocalDofList(const mfem::Array<int>& local_dofs)
{
local_dofs_ = local_dofs;

// Create a marker arrays for the true and local dofs
mfem::Array<int> true_dof_marker(space_.GetTrueVSize());
mfem::Array<int> local_dof_marker(space_.GetVSize());

mfem::FiniteElementSpace::ListToMarker(local_dofs_, space_.GetVSize(), local_dof_marker);

space_.GetRestrictionMatrix()->BooleanMult(local_dof_marker, true_dof_marker);

mfem::FiniteElementSpace::MarkerToList(true_dof_marker, true_dofs_);
}

void BoundaryCondition::setDofListsFromAttributeMarkers()
{
auto& mutable_space = const_cast<mfem::ParFiniteElementSpace&>(space_);
Expand Down Expand Up @@ -133,48 +118,4 @@ void BoundaryCondition::apply(mfem::HypreParMatrix& k_mat, mfem::Vector& rhs, mf
mfem::EliminateBC(k_mat, *eliminated_entries, true_dofs_, state, rhs);
}

const mfem::Coefficient& BoundaryCondition::scalarCoefficient() const
{
auto scalar_coef = get_if<std::shared_ptr<mfem::Coefficient>>(&coef_);
if (scalar_coef) {
return **scalar_coef;
} else {
SLIC_ERROR_ROOT("Asking for a scalar coefficient on a BoundaryCondition that contains a vector coefficient.");
exit(1);
}
}

mfem::Coefficient& BoundaryCondition::scalarCoefficient()
{
auto scalar_coef = get_if<std::shared_ptr<mfem::Coefficient>>(&coef_);
if (scalar_coef) {
return **scalar_coef;
} else {
SLIC_ERROR_ROOT("Asking for a scalar coefficient on a BoundaryCondition that contains a vector coefficient.");
exit(1);
}
}

const mfem::VectorCoefficient& BoundaryCondition::vectorCoefficient() const
{
auto vec_coef = get_if<std::shared_ptr<mfem::VectorCoefficient>>(&coef_);
if (vec_coef) {
return **vec_coef;
} else {
SLIC_ERROR_ROOT("Asking for a vector coefficient on a BoundaryCondition that contains a scalar coefficient.");
exit(1);
}
}

mfem::VectorCoefficient& BoundaryCondition::vectorCoefficient()
{
auto vec_coef = get_if<std::shared_ptr<mfem::VectorCoefficient>>(&coef_);
if (vec_coef) {
return **vec_coef;
} else {
SLIC_ERROR_ROOT("Asking for a vector coefficient on a BoundaryCondition that contains a scalar coefficient.");
exit(1);
}
}

} // namespace serac
50 changes: 0 additions & 50 deletions src/serac/physics/boundary_conditions/boundary_condition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,46 +93,6 @@ class BoundaryCondition {
*/
mfem::Array<int>& markers() { return attr_markers_; }

/**
* @brief Accessor for the underlying vector coefficient
*
* This method performs an internal check to verify the underlying GeneralCoefficient
* is in fact a vector.
*
* @return A non-owning reference to the underlying vector coefficient
*/
const mfem::VectorCoefficient& vectorCoefficient() const;

/**
* @brief Accessor for the underlying vector coefficient
*
* This method performs an internal check to verify the underlying GeneralCoefficient
* is in fact a vector.
*
* @return A non-owning reference to the underlying vector coefficient
*/
mfem::VectorCoefficient& vectorCoefficient();

/**
* @brief Accessor for the underlying scalar coefficient
*
* This method performs an internal check to verify the underlying GeneralCoefficient
* is in fact a scalar.
*
* @return A non-owning reference to the underlying scalar coefficient
*/
const mfem::Coefficient& scalarCoefficient() const;

/**
* @brief Accessor for the underlying scalar coefficient
*
* This method performs an internal check to verify the underlying GeneralCoefficient
* is in fact a scalar.
*
* @return A non-owning reference to the underlying scalar coefficient
*/
mfem::Coefficient& scalarCoefficient();

/**
* @brief Returns the DOF indices for an essential boundary condition
* @return A non-owning reference to the array of indices
Expand Down Expand Up @@ -200,16 +160,6 @@ class BoundaryCondition {
*/
void setTrueDofList(const mfem::Array<int>& true_dofs);

/**
* @brief "Manually" set the DOF indices without specifying the field to which they apply
* @param[in] local_dofs The local (finite element/grid function) indices of the DOFs constrained by the boundary
* condition
*
* @note This will set both the true and local internal dof index arrays.
* @note True and local dofs are described in the <a href="https://mfem.org/pri-dual-vec/">MFEM documentation</a>
*/
void setLocalDofList(const mfem::Array<int>& local_dofs);

/**
* @brief A coefficient containing either a mfem::Coefficient or an mfem::VectorCoefficient
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@

namespace serac {

void BoundaryConditionManager::addNatural(const std::set<int>& nat_bdr, serac::GeneralCoefficient nat_bdr_coef,
mfem::ParFiniteElementSpace& space, const std::optional<int> component)
{
nat_bdr_.emplace_back(nat_bdr_coef, component, space, nat_bdr);
all_dofs_valid_ = false;
}

void BoundaryConditionManager::addEssential(const std::set<int>& ess_bdr, serac::GeneralCoefficient ess_bdr_coef,
mfem::ParFiniteElementSpace& space, const std::optional<int> component)
{
Expand Down
Loading

0 comments on commit af22df5

Please sign in to comment.