From 4d28c38d7483affc25661ea3c7100adeb7fef4fc Mon Sep 17 00:00:00 2001 From: Kenny Swartz Date: Mon, 9 Mar 2026 23:16:36 -0700 Subject: [PATCH 1/3] adding essential bc method that uses domain --- src/smith/physics/heat_transfer.hpp | 20 ++++++++++++++++ .../physics/tests/thermal_statics_patch.cpp | 23 ++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/smith/physics/heat_transfer.hpp b/src/smith/physics/heat_transfer.hpp index c4b171c5b7..d6a34250ca 100644 --- a/src/smith/physics/heat_transfer.hpp +++ b/src/smith/physics/heat_transfer.hpp @@ -308,6 +308,26 @@ class HeatTransfer, std::integer_sequ } } + /** + * @brief Set essential temperature boundary conditions (strongly enforced) + * + * @param[in] applied_temperature The prescribed boundary temperature function + * @param[in] domain The domain over which the temperature is prescribed + * + * @note This should be called prior to completeSetup() + */ + template + void setTemperatureBCs(AppliedTemperatureFunction applied_temperature, Domain& domain) + { + auto mfem_coefficient_function = ([applied_temperature](const mfem::Vector& X_mfem, double t) { + auto X = make_tensor([&X_mfem](int k) { return X_mfem[k]; }); + return applied_temperature(X, t); + }); + temp_bdr_coef_ = std::make_shared(mfem_coefficient_function); + auto dof_list = domain.dof_list(&temperature_.space()); + bcs_.addEssential(dof_list, temp_bdr_coef_, temperature_.space(), 0); + } + /** * @brief Set essential temperature boundary conditions (strongly enforced) * diff --git a/src/smith/physics/tests/thermal_statics_patch.cpp b/src/smith/physics/tests/thermal_statics_patch.cpp index ccf9886f45..9b6f745f0f 100644 --- a/src/smith/physics/tests/thermal_statics_patch.cpp +++ b/src/smith/physics/tests/thermal_statics_patch.cpp @@ -67,14 +67,24 @@ class AffineSolution { * * @param material Material model used in the problem * @param physics The HeatTransfer module for the problem - * @param essential_boundaries Boundary attributes on which essential boundary conditions are desired + * @param essential_domain Domain on which essential boundary conditions are desired */ template - void applyLoads(const Material& material, HeatTransfer& physics, std::set essential_boundaries, Domain & boundary) const + void applyLoads(const Material& material, HeatTransfer& physics, Domain &essential_domain, Domain & boundary) const { // essential BCs - auto ebc_func = [*this](const auto& X, auto){ return this->operator()(X); }; - physics.setTemperatureBCs(essential_boundaries, ebc_func); + // auto ebc_func = [*this](const auto& X, auto){ return this->operator()(X); }; + // physics.setTemperatureBCs(essential_boundaries, ebc_func); + auto ebc_func = [*this](const auto &X, auto) { + mfem::Vector X_mfem(dim); + X_mfem(0) = X[0]; + X_mfem(1) = X[1]; + if constexpr (dim==3) { + X_mfem(2) = X[2]; + } + return this->operator()(X_mfem); + }; + physics.setTemperatureBCs(ebc_func, essential_domain); // natural BCs auto temp_grad = make_tensor([&](int i) { return A(i); }); @@ -178,7 +188,8 @@ double solution_error(const ExactSolution& exact_temperature, PatchBoundaryCondi heat_transfer::LinearIsotropicConductor mat(1.0,1.0,1.0); thermal.setMaterial(mat, mesh->entireBody()); - exact_temperature.applyLoads(mat, thermal, essentialBoundaryAttributes(bc), mesh->entireBoundary()); + mesh->addDomainOfBoundaryElements("essBdr", by_attr(essentialBoundaryAttributes(bc))); + exact_temperature.applyLoads(mat, thermal, mesh->domain("essBdr"), mesh->entireBoundary()); // Finalize the data structures thermal.completeSetup(); @@ -264,4 +275,4 @@ int main(int argc, char* argv[]) ::testing::InitGoogleTest(&argc, argv); smith::ApplicationManager applicationManager(argc, argv); return RUN_ALL_TESTS(); -} +} \ No newline at end of file From 8db47862d267e7923273fbba4a721c5ce0f34a64 Mon Sep 17 00:00:00 2001 From: Kenny Swartz Date: Mon, 9 Mar 2026 23:22:18 -0700 Subject: [PATCH 2/3] removing commented code --- src/smith/physics/tests/thermal_statics_patch.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/smith/physics/tests/thermal_statics_patch.cpp b/src/smith/physics/tests/thermal_statics_patch.cpp index 9b6f745f0f..58278ebeec 100644 --- a/src/smith/physics/tests/thermal_statics_patch.cpp +++ b/src/smith/physics/tests/thermal_statics_patch.cpp @@ -73,8 +73,6 @@ class AffineSolution { void applyLoads(const Material& material, HeatTransfer& physics, Domain &essential_domain, Domain & boundary) const { // essential BCs - // auto ebc_func = [*this](const auto& X, auto){ return this->operator()(X); }; - // physics.setTemperatureBCs(essential_boundaries, ebc_func); auto ebc_func = [*this](const auto &X, auto) { mfem::Vector X_mfem(dim); X_mfem(0) = X[0]; From 26f1967b55fd6ffaf85cba8f890a33fafcef58ca Mon Sep 17 00:00:00 2001 From: Michael Tupek <135926736+tupek2@users.noreply.github.com> Date: Fri, 13 Mar 2026 15:59:21 -0700 Subject: [PATCH 3/3] Update src/smith/physics/tests/thermal_statics_patch.cpp --- src/smith/physics/tests/thermal_statics_patch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smith/physics/tests/thermal_statics_patch.cpp b/src/smith/physics/tests/thermal_statics_patch.cpp index 58278ebeec..8b3db4a96e 100644 --- a/src/smith/physics/tests/thermal_statics_patch.cpp +++ b/src/smith/physics/tests/thermal_statics_patch.cpp @@ -273,4 +273,4 @@ int main(int argc, char* argv[]) ::testing::InitGoogleTest(&argc, argv); smith::ApplicationManager applicationManager(argc, argv); return RUN_ALL_TESTS(); -} \ No newline at end of file +}