Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some suggested refactors. #1259

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/serac/infrastructure/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
#include <variant>
#include <optional>

#include "mfem.hpp"
#include "axom/inlet.hpp"
#include "axom/sidre.hpp"

namespace mfem {
class Vector;
class Coefficient;
class VectorCoefficient;
} // namespace mfem

/**
* @brief The input related helper functions and objects
*
Expand Down
6 changes: 5 additions & 1 deletion src/serac/mesh/mesh_utils_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@

#include <memory>
#include <variant>
#include "mfem.hpp"

#include "serac/infrastructure/input.hpp"

namespace mfem {
class Mesh;
class ParMesh;
} // namespace mfem

namespace serac {

/**
Expand Down
8 changes: 6 additions & 2 deletions src/serac/numerics/equation_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
#include <optional>
#include <variant>

#include "mfem.hpp"

#include "serac/infrastructure/input.hpp"
#include "serac/numerics/solver_config.hpp"
#include "serac/numerics/petsc_solvers.hpp"

namespace mfem {
class Solver;
class NewtonSolver;
class vector;
} // namespace mfem

namespace serac {

/**
Expand Down
11 changes: 9 additions & 2 deletions src/serac/numerics/functional/functional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class Functional<test(trials...), exec> {
* at most one of which may be of the type `differentiate_wrt_this(mfem::Vector)`
*/
template <uint32_t wrt, typename... T>
typename operator_paren_return<wrt>::type operator()(DifferentiateWRT<wrt>, double t, const T&... args)
typename operator_paren_return<wrt>::type operator()(DifferentiateWRT<wrt>, double t, const T&... args) const
{
const mfem::Vector* input_T[] = {&static_cast<const mfem::Vector&>(args)...};

Expand Down Expand Up @@ -499,7 +499,7 @@ class Functional<test(trials...), exec> {

/// @overload
template <typename... T>
auto operator()(double t, const T&... args)
auto operator()(double t, const T&... args) const
{
constexpr int num_differentiated_arguments = (std::is_same_v<T, differentiate_wrt_this> + ...);
static_assert(num_differentiated_arguments <= 1,
Expand Down Expand Up @@ -565,6 +565,13 @@ class Functional<test(trials...), exec> {
return df_;
}

/// @brief syntactic sugar: df_dx.Mult(dx, df) <=> mfem::Vector df = df_dx(dx);
const mfem::Vector& operator()(const mfem::Vector& dx) const
{
form_.ActionOfGradient(dx, df_, which_argument);
return df_;
}

/// @brief assemble element matrices and form an mfem::HypreParMatrix
std::unique_ptr<mfem::HypreParMatrix> assemble()
{
Expand Down
2 changes: 0 additions & 2 deletions src/serac/numerics/solver_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#pragma once

#include <variant>

#include "mfem.hpp"
#include "axom/fmt.hpp"

namespace serac {
Expand Down
2 changes: 0 additions & 2 deletions src/serac/physics/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
*/
#pragma once

#include "serac/numerics/odes.hpp"

namespace serac {

/**
Expand Down
2 changes: 1 addition & 1 deletion src/serac/physics/heat_transfer_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#pragma once

#include "serac/physics/materials/thermal_material_input.hpp"
#include "serac/physics/common.hpp"
#include "serac/numerics/odes.hpp"

namespace serac {

Expand Down
1 change: 1 addition & 0 deletions src/serac/physics/solid_mechanics_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "serac/physics/materials/solid_material_input.hpp"
#include "serac/physics/common.hpp"
#include "serac/numerics/odes.hpp"

namespace serac {

Expand Down