Skip to content

Commit

Permalink
Merge branch 'develop' into tupek/contact_adjoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tupek2 authored Dec 11, 2024
2 parents 6dccb91 + 83513c2 commit 67221a1
Show file tree
Hide file tree
Showing 105 changed files with 4,214 additions and 1,735 deletions.
2 changes: 1 addition & 1 deletion .gitlab/build_toss4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ toss4-clang_14_0_6-src:
COMPILER: "[email protected]"
HOST_CONFIG: "ruby-toss_4_x86_64_ib-${COMPILER}.cmake"
EXTRA_CMAKE_OPTIONS: "-DENABLE_BENCHMARKS=ON"
DO_INTEGRATION_TESTS: "yes"
#DO_INTEGRATION_TESTS: "yes"
ALLOC_NODES: "2"
ALLOC_TIME: "30"
ALLOC_DEADLINE: "60"
Expand Down
4 changes: 3 additions & 1 deletion cmake/SeracBasics.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ endif()

option(SERAC_ENABLE_PROFILING "Enable profiling functionality" OFF)

cmake_dependent_option(SERAC_ENABLE_BENCHMARKS "Enable benchmark executables" ON "ENABLE_BENCHMARKS" OFF)
if (ENABLE_BENCHMARKS)
set(SERAC_ENABLE_BENCHMARKS ON)
endif()

# User turned on benchmarking but explicitly turned off profiling. Error out.
if ((ENABLE_BENCHMARKS OR SERAC_ENABLE_BENCHMARKS) AND NOT SERAC_ENABLE_PROFILING)
Expand Down
9 changes: 4 additions & 5 deletions examples/buckling/cylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ int main(int argc, char* argv[])

// Create and refine mesh
std::string filename = SERAC_REPO_DIR "/data/meshes/hollow-cylinder.mesh";
auto mesh = serac::buildMeshFromFile(filename);
auto pmesh = mesh::refineAndDistribute(std::move(mesh), serial_refinement, parallel_refinement);
serac::StateManager::setMesh(std::move(pmesh), mesh_tag);
auto mesh = mesh::refineAndDistribute(serac::buildMeshFromFile(filename), serial_refinement, parallel_refinement);
auto& pmesh = serac::StateManager::setMesh(std::move(mesh), mesh_tag);

// Surface attributes for boundary conditions
std::set<int> xneg{2};
Expand Down Expand Up @@ -160,8 +159,8 @@ int main(int argc, char* argv[])
auto lambda = 1.0;
auto G = 0.1;
solid_mechanics::NeoHookean mat{.density = 1.0, .K = (3 * lambda + 2 * G) / 3, .G = G};

solid_solver->setMaterial(mat);
Domain whole_mesh = EntireDomain(pmesh);
solid_solver->setMaterial(mat, whole_mesh);

// Set up essential boundary conditions
// Bottom of cylinder is fixed
Expand Down
9 changes: 5 additions & 4 deletions examples/contact/beam_bending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ int main(int argc, char* argv[])
// Construct the appropriate dimension mesh and give it to the data store
std::string filename = SERAC_REPO_DIR "/data/meshes/beam-hex-with-contact-block.mesh";

auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 2, 0);
serac::StateManager::setMesh(std::move(mesh), "beam_mesh");
auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 2, 0);
auto& pmesh = serac::StateManager::setMesh(std::move(mesh), "beam_mesh");

serac::LinearSolverOptions linear_options{.linear_solver = serac::LinearSolver::Strumpack, .print_level = 1};
#ifndef MFEM_USE_STRUMPACK
Expand Down Expand Up @@ -78,7 +78,8 @@ int main(int argc, char* argv[])
solid_solver.setParameter(1, G_field);

serac::solid_mechanics::ParameterizedNeoHookeanSolid mat{1.0, 0.0, 0.0};
solid_solver.setMaterial(serac::DependsOn<0, 1>{}, mat);
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
solid_solver.setMaterial(serac::DependsOn<0, 1>{}, mat, whole_mesh);

// Pass the BC information to the solver object
solid_solver.setDisplacementBCs({1}, [](const mfem::Vector&, mfem::Vector& u) {
Expand Down Expand Up @@ -117,4 +118,4 @@ int main(int argc, char* argv[])
serac::exitGracefully();

return 0;
}
}
8 changes: 5 additions & 3 deletions examples/contact/ironing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ int main(int argc, char* argv[])
// Construct the appropriate dimension mesh and give it to the data store
std::string filename = SERAC_REPO_DIR "/data/meshes/ironing.mesh";

auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 2, 0);
serac::StateManager::setMesh(std::move(mesh), "ironing_mesh");
auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 2, 0);
auto& pmesh = serac::StateManager::setMesh(std::move(mesh), "ironing_mesh");

serac::LinearSolverOptions linear_options{.linear_solver = serac::LinearSolver::Strumpack, .print_level = 1};

#ifndef MFEM_USE_STRUMPACK
SLIC_INFO_ROOT("Contact requires MFEM built with strumpack.");
return 1;
Expand Down Expand Up @@ -78,7 +79,8 @@ int main(int argc, char* argv[])
solid_solver.setParameter(1, G_field);

serac::solid_mechanics::ParameterizedNeoHookeanSolid mat{1.0, 0.0, 0.0};
solid_solver.setMaterial(serac::DependsOn<0, 1>{}, mat);
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
solid_solver.setMaterial(serac::DependsOn<0, 1>{}, mat, whole_mesh);

// Pass the BC information to the solver object
solid_solver.setDisplacementBCs({5}, [](const mfem::Vector&, mfem::Vector& u) {
Expand Down
9 changes: 5 additions & 4 deletions examples/contact/sphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ int main(int argc, char* argv[])
cube_mesh.SetCurvature(p);

std::vector<mfem::Mesh*> mesh_ptrs{&ball_mesh, &cube_mesh};
auto mesh = serac::mesh::refineAndDistribute(mfem::Mesh(mesh_ptrs.data(), static_cast<int>(mesh_ptrs.size())), 0, 0);
serac::StateManager::setMesh(std::move(mesh), "sphere_mesh");
auto mesh = serac::mesh::refineAndDistribute(mfem::Mesh(mesh_ptrs.data(), static_cast<int>(mesh_ptrs.size())), 0, 0);
auto& pmesh = serac::StateManager::setMesh(std::move(mesh), "sphere_mesh");

serac::LinearSolverOptions linear_options{.linear_solver = serac::LinearSolver::Strumpack, .print_level = 1};
#ifndef MFEM_USE_STRUMPACK
Expand All @@ -75,7 +75,8 @@ int main(int argc, char* argv[])
nonlinear_options, linear_options, serac::solid_mechanics::default_quasistatic_options, name, "sphere_mesh");

serac::solid_mechanics::NeoHookean mat{1.0, 10.0, 0.25};
solid_solver.setMaterial(mat);
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
solid_solver.setMaterial(mat, whole_mesh);

// Pass the BC information to the solver object
solid_solver.setDisplacementBCs({3}, [](const mfem::Vector&, mfem::Vector& u) {
Expand Down Expand Up @@ -122,4 +123,4 @@ int main(int argc, char* argv[])
serac::exitGracefully();

return 0;
}
}
9 changes: 5 additions & 4 deletions examples/contact/twist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ int main(int argc, char* argv[])
// Construct the appropriate dimension mesh and give it to the data store
std::string filename = SERAC_REPO_DIR "/data/meshes/twohex_for_contact.mesh";

auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 3, 0);
serac::StateManager::setMesh(std::move(mesh), "twist_mesh");
auto mesh = serac::mesh::refineAndDistribute(serac::buildMeshFromFile(filename), 3, 0);
auto& pmesh = serac::StateManager::setMesh(std::move(mesh), "twist_mesh");

serac::LinearSolverOptions linear_options{.linear_solver = serac::LinearSolver::Strumpack, .print_level = 1};
#ifndef MFEM_USE_STRUMPACK
Expand All @@ -61,7 +61,8 @@ int main(int argc, char* argv[])
nonlinear_options, linear_options, serac::solid_mechanics::default_quasistatic_options, name, "twist_mesh");

serac::solid_mechanics::NeoHookean mat{1.0, 10.0, 10.0};
solid_solver.setMaterial(mat);
serac::Domain whole_mesh = serac::EntireDomain(pmesh);
solid_solver.setMaterial(mat, whole_mesh);

// Pass the BC information to the solver object
solid_solver.setDisplacementBCs({3}, [](const mfem::Vector&, mfem::Vector& u) {
Expand Down Expand Up @@ -108,4 +109,4 @@ int main(int argc, char* argv[])
serac::exitGracefully();

return 0;
}
}
6 changes: 4 additions & 2 deletions examples/simple_conduction/without_input_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main(int argc, char* argv[])

std::string mesh_tag{"mesh"};

serac::StateManager::setMesh(std::move(mesh), mesh_tag);
auto& pmesh = serac::StateManager::setMesh(std::move(mesh), mesh_tag);
// _create_mesh_end

// _create_module_start
Expand All @@ -54,7 +54,9 @@ int main(int argc, char* argv[])
// _conductivity_start
constexpr double kappa = 0.5;
serac::heat_transfer::LinearIsotropicConductor mat(1.0, 1.0, kappa);
heat_transfer.setMaterial(mat);

serac::Domain whole_domain = serac::EntireDomain(pmesh);
heat_transfer.setMaterial(mat, whole_domain);

// _conductivity_end
// _bc_start
Expand Down
7 changes: 3 additions & 4 deletions scripts/llnl/common_build_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,7 @@ def get_build_dir(prefix, host_config):


def get_repo_dir():
script_dir = os.path.dirname(os.path.realpath(__file__))
return os.path.abspath(pjoin(script_dir, "../.."))
return os.path.abspath(pjoin(get_script_dir(), "../.."))


def get_build_and_test_root(prefix, timestamp):
Expand Down Expand Up @@ -685,7 +684,7 @@ def get_shared_spot_dir():


def get_uberenv_path():
return pjoin(get_script_dir(), "../uberenv/uberenv.py")
return pjoin(get_repo_dir(), "scripts/uberenv/uberenv.py")


def on_rz():
Expand All @@ -703,7 +702,7 @@ def get_script_dir():
def get_project_name():
global _project_name
if not _project_name:
uberenv_config_path = os.path.abspath(os.path.join(get_script_dir(), "../../.uberenv_config.json"))
uberenv_config_path = pjoin(get_repo_dir(), ".uberenv_config.json")
_project_name = "UNKNOWN_PROJECT"
if os.path.exists(uberenv_config_path):
with open(uberenv_config_path) as json_file:
Expand Down
6 changes: 6 additions & 0 deletions scripts/llnl/run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def main():
for cali_file in cali_files:
if os.path.exists(cali_file):
shutil.copy2(cali_file, spot_dir)
# Update group and permissions of new caliper file
cali_file = os.path.join(spot_dir, os.path.basename(cali_file))
group_info = grp.getgrnam("smithdev")
os.chown(cali_file, -1, group_info.gr_gid)
os.chmod(cali_file,
stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP)

# Print SPOT url
if on_rz():
Expand Down
6 changes: 3 additions & 3 deletions src/docs/sphinx/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Quickstart Guide
Getting Serac
-------------

Serac is hosted on `GitHub <https://github.com/LLNL/serac>`_. Serac uses git submodules, so the project must be cloned recursively. Use either of the following commands to pull Serac's repository:
Serac is hosted on `GitHub <https://github.com/LLNL/serac>`_. Serac uses git submodules, so the project must be cloned
recursively. Use either of the following commands to pull Serac's repository:

.. code-block:: bash
Expand Down Expand Up @@ -212,8 +213,7 @@ Some build options frequently used by Serac include:
* ``ENABLE_ASAN``: Enables the Address Sanitizer for memory safety inspections, defaults to ``OFF``
* ``SERAC_ENABLE_TESTS``: Enables Serac unit tests, defaults to ``ON``
* ``SERAC_ENABLE_CODEVELOP``: Enables local development build of MFEM/Axom, see :ref:`codevelop-label`, defaults to ``OFF``
* ``SERAC_USE_VDIM_ORDERING``: Sets the vector ordering to be ``byVDIM``, which is significantly faster for algebraic multigrid,
but may conflict with other packages if Serac is being used as a dependency, defaults to ``OFF``.
* ``SERAC_USE_VDIM_ORDERING``: Sets the vector ordering to be ``byVDIM``, which is significantly faster for algebraic multigrid, defaults to ``ON``.

Once the build has been configured, Serac can be built with the following commands:

Expand Down
60 changes: 30 additions & 30 deletions src/drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@
#
# SPDX-License-Identifier: (BSD-3-Clause)

blt_add_executable( NAME serac_driver
SOURCES serac.cpp
DEPENDS_ON serac_physics serac_mesh
OUTPUT_NAME serac
)

if (SERAC_ENABLE_TESTS)
set(input_files_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../data/input_files/tests)

# Run basic test for the Serac driver
blt_add_test(NAME serac_driver_solid
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o driver_solid -i ${input_files_dir}/solid/dyn_solve.lua
NUM_MPI_TASKS 1 )

blt_add_test(NAME serac_driver_heat_transfer
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o driver_heat_transfer -i ${input_files_dir}/heat_transfer/static_solve.lua
NUM_MPI_TASKS 1 )

blt_add_test(NAME serac_driver_help
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac --help
NUM_MPI_TASKS 1 )

blt_add_test(NAME serac_driver_docs
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o docs -d -i ${input_files_dir}/solid/qs_linear.lua
NUM_MPI_TASKS 1 )
endif()

install( TARGETS serac_driver
RUNTIME DESTINATION bin
)
#blt_add_executable( NAME serac_driver
# SOURCES serac.cpp
# DEPENDS_ON serac_physics serac_mesh
# OUTPUT_NAME serac
# )
#
#if (SERAC_ENABLE_TESTS)
# set(input_files_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../data/input_files/tests)
#
# # Run basic test for the Serac driver
# blt_add_test(NAME serac_driver_solid
# COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o driver_solid -i ${input_files_dir}/solid/dyn_solve.lua
# NUM_MPI_TASKS 1 )
#
# blt_add_test(NAME serac_driver_heat_transfer
# COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o driver_heat_transfer -i ${input_files_dir}/heat_transfer/static_solve.lua
# NUM_MPI_TASKS 1 )
#
# blt_add_test(NAME serac_driver_help
# COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac --help
# NUM_MPI_TASKS 1 )
#
# blt_add_test(NAME serac_driver_docs
# COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o docs -d -i ${input_files_dir}/solid/qs_linear.lua
# NUM_MPI_TASKS 1 )
#endif()
#
#install( TARGETS serac_driver
# RUNTIME DESTINATION bin
# )
7 changes: 7 additions & 0 deletions src/serac/infrastructure/accelerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ void zero_out(axom::Array<T, dim, space>& arr)
{
std::memset(arr.data(), 0, static_cast<std::size_t>(arr.size()) * sizeof(T));
}

/// @brief set the contents of an array to zero, byte-wise
template <typename T, int dim>
void zero_out(axom::ArrayView<T, dim, axom::MemorySpace::Host>& arr)
{
std::memset(arr.data(), 0, static_cast<std::size_t>(arr.size()) * sizeof(T));
}
#ifdef __CUDACC__
/// @overload
template <typename T, int dim>
Expand Down
6 changes: 0 additions & 6 deletions src/serac/infrastructure/debug_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ std::ostream& operator<<(std::ostream& out, DoF dof)
return out;
}

std::ostream& operator<<(std::ostream& out, serac::SignedIndex i)
{
out << "{" << i.index_ << ", " << i.sign_ << "}";
return out;
}

/**
* @brief write a 2D array of values out to file, in a space-separated format
* @tparam T the type of each value in the array
Expand Down
3 changes: 2 additions & 1 deletion src/serac/numerics/functional/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set(functional_depends serac_mesh ${serac_device_depends})
set(functional_headers
differentiate_wrt.hpp
boundary_integral_kernels.hpp
dof_numbering.hpp
element_restriction.hpp
geometry.hpp
geometric_factors.hpp
Expand All @@ -22,6 +21,7 @@ set(functional_headers
function_signature.hpp
functional_qoi.inl
integral.hpp
interior_face_integral_kernels.hpp
isotropic_tensor.hpp
polynomials.hpp
quadrature.hpp
Expand All @@ -30,6 +30,7 @@ set(functional_headers
tensor.hpp
tuple.hpp
tuple_tensor_dual_functions.hpp
typedefs.hpp
)

set(functional_sources
Expand Down
Loading

0 comments on commit 67221a1

Please sign in to comment.