Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
boundary_condition_manager.cpp
1 // Copyright (c) 2019-2024, Lawrence Livermore National Security, LLC and
2 // other Serac Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
8 
9 #include <algorithm>
10 #include <iterator>
11 
13 
14 namespace serac {
15 
16 void BoundaryConditionManager::addEssential(const std::set<int>& ess_bdr, serac::GeneralCoefficient ess_bdr_coef,
17  mfem::ParFiniteElementSpace& space, const std::optional<int> component)
18 {
19  std::set<int> filtered_attrs;
20  std::set_difference(ess_bdr.begin(), ess_bdr.end(), attrs_in_use_.begin(), attrs_in_use_.end(),
21  std::inserter(filtered_attrs, filtered_attrs.begin()));
22 
23  // Check if anything was removed
24  if (filtered_attrs.size() < ess_bdr.size()) {
25  SLIC_WARNING_ROOT("Multiple definition of essential boundary! Using first definition given.");
26  }
27 
28  ess_bdr_.emplace_back(ess_bdr_coef, component, space, filtered_attrs);
29  attrs_in_use_.insert(ess_bdr.begin(), ess_bdr.end());
30  all_dofs_valid_ = false;
31 }
32 
33 void BoundaryConditionManager::addNatural(const std::set<int>& nat_bdr, serac::GeneralCoefficient nat_bdr_coef,
34  mfem::ParFiniteElementSpace& space, const std::optional<int> component)
35 {
36  nat_bdr_.emplace_back(nat_bdr_coef, component, space, nat_bdr);
37  all_dofs_valid_ = false;
38 }
39 
40 void BoundaryConditionManager::addEssential(const mfem::Array<int>& true_dofs,
41  std::shared_ptr<mfem::VectorCoefficient> ess_bdr_coef,
42  mfem::ParFiniteElementSpace& space)
43 {
44  ess_bdr_.emplace_back(ess_bdr_coef, std::nullopt, space, true_dofs);
45  all_dofs_valid_ = false;
46 }
47 
48 void BoundaryConditionManager::updateAllDofs() const
49 {
50  all_true_dofs_.DeleteAll();
51  all_local_dofs_.DeleteAll();
52  for (const auto& bc : ess_bdr_) {
53  all_true_dofs_.Append(bc.getTrueDofList());
54  all_local_dofs_.Append(bc.getLocalDofList());
55  }
56  all_true_dofs_.Sort();
57  all_local_dofs_.Sort();
58  all_true_dofs_.Unique();
59  all_local_dofs_.Unique();
60  all_dofs_valid_ = true;
61 }
62 
63 } // namespace serac
This file contains the declaration of the boundary condition manager class.
void addNatural(const std::set< int > &nat_bdr, serac::GeneralCoefficient nat_bdr_coef, mfem::ParFiniteElementSpace &space, const std::optional< int > component={})
Set the natural boundary conditions from a list of boundary markers and a coefficient.
void addEssential(const std::set< int > &ess_bdr, serac::GeneralCoefficient ess_bdr_coef, mfem::ParFiniteElementSpace &space, const std::optional< int > component={})
Set the essential boundary conditions from a list of boundary markers and a coefficient.
This file contains the all the necessary functions and macros required for logging as well as a helpe...
Accelerator functionality.
Definition: serac.cpp:38