Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
223 commits
Select commit Hold shift + click to select a range
39cf5ab
Working out the new interface.
tupek2 Feb 9, 2026
f8458a6
Merge branch 'tupek/differentiable_block_solver' into tupek/field_sto…
tupek2 Feb 10, 2026
ea0ca71
Some progress on the new design.
tupek2 Feb 10, 2026
0a44b2b
update new gretl.
tupek2 Feb 10, 2026
1b78255
Merge branch 'tupek/differentiable_block_solver' into tupek/field_sto…
tupek2 Feb 10, 2026
a03c722
Refactoring thermo mechanics example to use generic multiphysics time…
mrtupek2 Feb 11, 2026
cf22c89
Cleanup interface by having a build method to construct a system with…
mrtupek2 Feb 11, 2026
8e413ee
--aned
mrtupek2 Feb 11, 2026
1d8a7a5
Working through new interface issues. there is still a crash in the …
mrtupek2 Feb 11, 2026
1e5219f
Address interface changes in contact examples.
tupek2 Feb 11, 2026
a977f34
Still working on debugging reverse pass.
tupek2 Feb 11, 2026
121ff6a
Update new continutation solvers.
mrtupek2 Feb 11, 2026
36eeebb
Progress on debugging issue.
mrtupek2 Feb 12, 2026
d5544ff
Fix bug in sending multiple params to residuals in some cases.
mrtupek2 Feb 12, 2026
edfe764
some docs.
mrtupek2 Feb 12, 2026
9cc8d29
Line changes.
tupek2 Feb 12, 2026
a04b7cb
Use current continutation solvers.
tupek2 Feb 12, 2026
f44f16b
Fix some style.
tupek2 Feb 12, 2026
de69f85
Fix docs and style.
tupek2 Feb 12, 2026
fc8abbe
Add addition runtime checks for consistent use of spaces and fields.
mrtupek2 Feb 12, 2026
2441fcb
Refactor existing solid mechanics state advancer to use the new multi…
mrtupek2 Feb 13, 2026
04370ae
Refactoring to improve testing of backpropagation.
mrtupek2 Feb 13, 2026
ec0ab77
Clearer names for dims and such.
mrtupek2 Feb 13, 2026
211bc93
Fix style.
mrtupek2 Feb 13, 2026
fe0c79e
style change to reduce lines.
mrtupek2 Feb 13, 2026
1148e7f
refactor solid state advancer to reuse the multiphysics advancer.
mrtupek2 Feb 14, 2026
3ca1727
A working state, but there is a lot to cleanup and review.
mrtupek2 Feb 14, 2026
ae37692
Working tests, a bit cleaner interface.
mrtupek2 Feb 14, 2026
3e0bd29
Simplifying tests and implementations.
mrtupek2 Feb 15, 2026
2206310
Some rename clean remove heat transfer weak form that will be unused.
mrtupek2 Feb 15, 2026
8bf0819
Refactor solid mechanics system for cleaner integrand interface.
mrtupek2 Feb 15, 2026
58f2a60
Work out the interface a bit more.
mrtupek2 Feb 15, 2026
83a8e96
Some style adjusts.
mrtupek2 Feb 15, 2026
6302652
Work on simplifying the muliphysics interfaces.
mrtupek2 Feb 15, 2026
0432b96
Update naming, have some initial pressure testing.
mrtupek2 Feb 15, 2026
5e9b405
Get a lightweight thermal only system working.
mrtupek2 Feb 15, 2026
8af4f92
Fix style, accept the template oddness in that test which is due to i…
mrtupek2 Feb 15, 2026
c3bd1df
Small adjust to state variable evolution.
mrtupek2 Feb 16, 2026
c0d05ec
Some stylistic improvements, fix up the test to use state variables a…
mrtupek2 Feb 19, 2026
b51e655
Address a few more style points.
mrtupek2 Feb 19, 2026
7ee6ae3
Merge branch 'develop' into tupek/field_store_interface_extended
tupek2 Feb 19, 2026
154b63b
Fix up a bad change.
tupek2 Feb 19, 2026
126e0b6
Style and docs, , mostly.
tupek2 Feb 19, 2026
eed13b1
Merge branch 'develop' into tupek/field_store_interface_extended
tupek2 Mar 4, 2026
553b28a
Merge branch 'develop' into tupek/field_store_interface_extended
lihanyu97 Mar 10, 2026
731cf21
Change VALUE to VAL
lihanyu97 Mar 11, 2026
128282f
Add SystemSolver to handle multi-block and staggered solves
mrtupek2 Feb 20, 2026
d2b143b
Update GEMINI.md with conventions and project guidelines
mrtupek2 Feb 20, 2026
94c1ecf
Fix brittle name-matching state update in SystemSolver
mrtupek2 Feb 20, 2026
0625e57
Implement global relative tolerance check for SystemSolver
mrtupek2 Feb 20, 2026
9dd806c
Working toward improve sub block solver strategy.
mrtupek2 Feb 20, 2026
9aa4841
another improvement to the convergence logic and interfacing.
mrtupek2 Feb 20, 2026
da6d168
Reduce down to a single differentiable solver option that is the most…
mrtupek2 Mar 4, 2026
8b40d3c
Fix style.
mrtupek2 Mar 4, 2026
b4dd7c0
Fix initialization of initial solver residuals for accurate scaling t…
mrtupek2 Mar 11, 2026
698b63d
Updating plan.
mrtupek2 Mar 11, 2026
0b09149
Update submodules.
mrtupek2 Mar 11, 2026
bae60c3
Merge branch 'develop' into tupek/solver_and_subsolvers
mrtupek2 Mar 11, 2026
29d44aa
Use latests submodules.
mrtupek2 Mar 11, 2026
4c3b689
Fix style.
mrtupek2 Mar 11, 2026
315a2e0
fix docs.
mrtupek2 Mar 11, 2026
c556c8f
Updating to use the new, more flexible solver interface.
mrtupek2 Mar 12, 2026
f13e038
Fix macOS Lapack rpath issue in FindMFEM.cmake
mrtupek2 Mar 12, 2026
29f43e6
Extract helper lambda in system_solver.cpp
mrtupek2 Mar 12, 2026
008cfc3
Improve unit testing of convergence, some better error messaging.
mrtupek2 Mar 12, 2026
5b7c462
Results in the wrong spot.
mrtupek2 Mar 12, 2026
1ed75aa
Remove outputs.
mrtupek2 Mar 12, 2026
dc62836
Cleanup some more extra files.
mrtupek2 Mar 12, 2026
d17b3a2
Remove plans from branch.
mrtupek2 Mar 12, 2026
52d2f53
Allow doxygen to build even if graphviz,dot is not installed on users…
mrtupek2 Mar 12, 2026
cb44b9d
Suppress mac ld warnings.
mrtupek2 Mar 12, 2026
3a49873
Merge branch 'develop' into tupek/solver_and_subsolvers
mrtupek2 Mar 12, 2026
3030d59
Style.
mrtupek2 Mar 12, 2026
ffd2af8
remove more results.
mrtupek2 Mar 12, 2026
c694c39
Remove another file.
mrtupek2 Mar 12, 2026
127d3f6
Get rid of solid_weak_form.
mrtupek2 Mar 12, 2026
0bbccd8
Removed solid_weak_form, utilized the sub solver capabilities in ther…
mrtupek2 Mar 13, 2026
cf6cf4e
Trying to get system solve tests up and going for more cases.
mrtupek2 Mar 15, 2026
7ce4cd1
Trying to get system solver working robustly.
mrtupek2 Mar 15, 2026
75545e6
Merge branch 'develop' into tupek/system_solver
mrtupek2 Mar 15, 2026
62ce1cd
Progress on unifying the system solvers and block preconditioners, etc.
mrtupek2 Mar 16, 2026
f68a47f
Nearly working after merging in block preconditioners.
tupek2 Mar 16, 2026
9c86813
Fix build.
tupek2 Mar 16, 2026
8bb01f2
Fix style.
tupek2 Mar 16, 2026
287e7ee
Fix docs, style.
tupek2 Mar 16, 2026
c6d4e2e
Add headers to cmake.
tupek2 Mar 16, 2026
0dda06b
Try to fix header issue in CI.
tupek2 Mar 16, 2026
ba39695
Trying to address CI issues.
tupek2 Mar 17, 2026
29c1268
Fix issue with using gtest functions in library file.
tupek2 Mar 17, 2026
7d1127e
Fix warnings.
tupek2 Mar 17, 2026
098a7b1
rename some utils.
tupek2 Mar 18, 2026
4e4b9f7
Make thermomechanical problem more buckling.
tupek2 Mar 19, 2026
4669167
Refactoring into a more flexible structure for defining solver tolera…
tupek2 Mar 19, 2026
ba104df
Fix style.
tupek2 Mar 19, 2026
3aa266d
Rename of some solver structures.
tupek2 Mar 19, 2026
0975474
updating solvers to allow for subblock tolerances.
tupek2 Mar 19, 2026
b0aff87
Fix style.
tupek2 Mar 19, 2026
fbb949a
Merge branch 'develop' into tupek/system_solver
tupek2 Mar 19, 2026
e7f9aef
Fix bad merge.
tupek2 Mar 19, 2026
28ade99
Merge branch 'develop' into tupek/system_solver
tupek2 Mar 19, 2026
4dc5525
Merge branch 'tupek/system_solver' of github.com:llnl/serac into tupe…
tupek2 Mar 19, 2026
7d30c99
Merge branch 'tupek/gretl_cpp20' into tupek/system_solver
tupek2 Mar 19, 2026
382b8ac
Fix doc warnings.
tupek2 Mar 19, 2026
cb71e2e
Fix gcc warning.
tupek2 Mar 19, 2026
00f07e6
Remove a troubling unneeded test.
tupek2 Mar 20, 2026
8df2f50
Merge remote-tracking branch 'upstream/develop' into tupek/system_solver
mrtupek2 Mar 22, 2026
6d5722f
Working on cleanup for integration rules and coupled systems.
mrtupek2 Mar 22, 2026
507a338
Cleanup up interface features and testing specific situations of Depe…
mrtupek2 Mar 23, 2026
b1819bb
Fix style.
tupek2 Mar 23, 2026
24e65b6
Fix docs.
tupek2 Mar 23, 2026
a587b70
Add option to paraview writer to not write duals. Also add a method t…
tupek2 Mar 23, 2026
67db0b4
Fix style
tupek2 Mar 23, 2026
97aaec4
Fix docs.
tupek2 Mar 23, 2026
6d6f683
Merge branch 'develop' into tupek/system_solver
tupek2 Mar 24, 2026
3f023b2
Fix pi issue.
tupek2 Mar 24, 2026
ab0a94d
Trying to get reaction forces properly integrated into Differentiable…
tupek2 Mar 26, 2026
a3fbb79
Merge branch 'develop' into tupek/system_solver_reactions
mrtupek2 Mar 26, 2026
fcc68fc
Fix style.
mrtupek2 Mar 26, 2026
3d655a8
Cleanup up a few minor interface decisions.
mrtupek2 Mar 26, 2026
401fabd
fix compile issues in cycle-zero weak form for solid mechanics with i…
mrtupek2 Mar 26, 2026
64ba138
Style and trying to get things more consistent.
mrtupek2 Mar 26, 2026
97c2fc7
Merge branch 'develop' into tupek/system_solver_reactions
tupek2 Mar 26, 2026
45074bd
Merge branch 'develop' into tupek/system_solver_reactions
tupek2 Mar 30, 2026
3d9c014
Unique pointer, and slightly better handling of zero cycle solve.
tupek2 Mar 30, 2026
a064fa7
Merge branch 'develop' into tupek/system_solver
tupek2 Mar 30, 2026
9a4a61e
Merge branch 'tupek/system_solver_reactions' into tupek/system_solver
tupek2 Mar 30, 2026
f25f681
Trying to simplify cycle 0 block solver strategy and get the correct …
tupek2 Mar 30, 2026
d5697e7
style.
tupek2 Mar 30, 2026
66b05ab
Remove some thermoelastic material models and tests that came in, fix…
tupek2 Mar 30, 2026
fa4a959
Remove unneeded paraview shim.
tupek2 Mar 31, 2026
cdba59e
Remove random png.
tupek2 Mar 31, 2026
881894c
Update to new paraview usage.
tupek2 Mar 31, 2026
35434d7
Do not do initial acceleration solve unless needed. Add density to a…
tupek2 Mar 31, 2026
5fb4ba4
Put back accidentally deleted materials.
tupek2 Mar 31, 2026
cd39875
Some test and docmentation cleanup.
tupek2 Mar 31, 2026
769545a
Remove unused time integration rule.
tupek2 Mar 31, 2026
dec64a9
Fix naming and cmakelist issue.
tupek2 Apr 1, 2026
0da8e6e
Add header to cmake.
tupek2 Apr 2, 2026
06f7966
Merge branch 'develop' into tupek/system_solver
tupek2 Apr 6, 2026
c4a7e0c
Merge branch 'develop' into tupek/system_solver
ebchin Apr 6, 2026
e37bab2
More nullptr safety checks, subspace solver a bit safer in case of mu…
tupek2 Apr 6, 2026
b0bfce0
style
tupek2 Apr 6, 2026
dc6cf98
Trying to establish a more specific design for SystemOfEquation (Syst…
mrtupek2 Apr 11, 2026
2e1778f
Fix multiphysics_time_integrator loose ends
mrtupek2 Apr 11, 2026
513972b
Decouple StateAdvancer from SystemBase, add helper functions.
mrtupek2 Apr 12, 2026
d870691
Try to cleanup construction of systems.
mrtupek2 Apr 12, 2026
7ec5a46
Document and update gretl tracking capabilities
mrtupek2 Apr 12, 2026
2564572
Update gretl_notracking.md with the Graph-Resident but Ephemeral plan
mrtupek2 Apr 12, 2026
ed004cd
Update gretl_notracking.md with the finalized Stop-Gradient approach
mrtupek2 Apr 12, 2026
35a8df8
Update gretl_notracking.md reflecting removal of ScopedGraphDisable
mrtupek2 Apr 12, 2026
533b1e2
Update gretl_notracking.md with the no-recompute optimization
mrtupek2 Apr 12, 2026
6797361
We are trying to usable stress output as an option at the end of soli…
mrtupek2 Apr 13, 2026
9f9d51c
Fix style.:
mrtupek2 Apr 13, 2026
6371ba5
Get solid mechanics problems passing, with style.
mrtupek2 Apr 13, 2026
0e9ddbd
Trying to implement system combine functionality.
mrtupek2 Apr 15, 2026
e7456fc
Increment on the path to coupled systems.
mrtupek2 Apr 15, 2026
5a53f4b
Refactor system interface to make it easy to combine systems.
mrtupek2 Apr 16, 2026
1b46d4c
Implement state variable system.
mrtupek2 Apr 16, 2026
4eecd96
Support a None preconditioner.
mrtupek2 Apr 16, 2026
8a99672
Merge branch 'develop' into tupek/system_solver
tupek2 Apr 16, 2026
bc3bfed
Working on merge.
tupek2 Apr 16, 2026
ec1f452
Fix merge issues.
tupek2 Apr 16, 2026
b91c70a
Working toward our dream interface.
mrtupek2 Apr 17, 2026
dbfc11c
Working on simpler build methods.
mrtupek2 Apr 17, 2026
cad8ebb
trying to test 3 systems, also fix up some solve issues identifies as…
mrtupek2 Apr 17, 2026
2cbf8df
Style.
mrtupek2 Apr 17, 2026
d78c213
sub options for block preconditioners
tlroy Apr 17, 2026
91eeab6
Simplify field and system registration.
mrtupek2 Apr 20, 2026
1220878
Remove duplicated test.
mrtupek2 Apr 20, 2026
f7b90f6
style.
mrtupek2 Apr 20, 2026
8231f28
Clean up some interface issues, rename cz to be clearer.
mrtupek2 Apr 21, 2026
cbc7ed7
Fix style.
mrtupek2 Apr 21, 2026
68921aa
Merge branch 'develop' into tupek/system_solver
tupek2 Apr 21, 2026
396392f
Update submodules.
mrtupek2 Apr 21, 2026
16cd1d8
Merge branch 'tupek/system_solver' into tupek/system_solver_extended
mrtupek2 Apr 21, 2026
b461e9c
Remove files that were not indended to be saved
tupek2 Apr 21, 2026
54a04a0
Try to make sure the solver and system responsibilities are clear, cl…
tupek2 Apr 21, 2026
6a69b69
Fix cmake.
tupek2 Apr 21, 2026
63ca16d
Fix docs.
tupek2 Apr 21, 2026
ce5c10e
Use coupled system for interal vars.
tupek2 Apr 21, 2026
00ed115
Fix tests and styles, cleanup duplication.
tupek2 Apr 22, 2026
683ff3a
Working on cleaning up the interface more.
tupek2 Apr 22, 2026
f1b4327
Trying to unify and simplify the interface more.
tupek2 Apr 22, 2026
73ebfb4
Finsih last parts of this increment of design change.
tupek2 Apr 22, 2026
9766610
Fix style.
tupek2 Apr 23, 2026
7186714
Still trying to simplify the interface.
tupek2 Apr 23, 2026
13c504a
Add more examples, and slight clarification of interface issues.
tupek2 Apr 23, 2026
bb01110
Improve examples, more simple syntax.
tupek2 Apr 24, 2026
5ec942b
Working through some improvements.
tupek2 Apr 24, 2026
5e83a33
Working on improving the zero-cycle boundary conditions and time inte…
tupek2 Apr 24, 2026
97bd261
Merge branch 'develop' into tupek/system_solver
tupek2 Apr 24, 2026
37a9c6e
Working through various interface improvements.
mrtupek2 Apr 25, 2026
0a43c11
Address some more interface cleanups.
mrtupek2 Apr 26, 2026
a67b658
Try to avoid duplication in weak form setup.
mrtupek2 Apr 27, 2026
c9cf6c9
Merge branch 'develop' into tupek/system_solver_extended
tupek2 Apr 27, 2026
8d4abcf
remove cmake artifact.
tupek2 Apr 27, 2026
199da1a
Remove more cmake artifact.
tupek2 Apr 27, 2026
3922d93
Remove lock.
tupek2 Apr 27, 2026
5992441
Fix docs.
tupek2 Apr 27, 2026
dd366fa
Merge branch 'develop' into tupek/system_solver
tupek2 Apr 27, 2026
5e2fd30
Fix up completeSetup method to use more useful types and to be called…
tupek2 Apr 27, 2026
201f70c
Merge branch 'develop' into tupek/system_solver
tupek2 Apr 29, 2026
927847e
Simplify test.
tupek2 Apr 29, 2026
9fe8caa
Merge branch 'develop' into tupek/system_solver
tupek2 Apr 29, 2026
4568954
Merge branch 'tupek/system_solver' into tupek/system_solver_extended
mrtupek2 Apr 29, 2026
7093035
Initial implementation for bc ramping for more robust solves.
mrtupek2 Apr 30, 2026
0044f96
style docs.
mrtupek2 Apr 30, 2026
fb0fadc
Implement bc ramping for cutbacks when displacement moves are too much.
mrtupek2 May 3, 2026
c3b6937
Allow for warm-start option.
mrtupek2 May 4, 2026
5049a79
Try to enable warm start option.
mrtupek2 May 4, 2026
52d49c5
Allow for linear warm start and warm start cutback on first iteration.
mrtupek2 May 5, 2026
ddd02bd
Perhaps some cleanup of the new bc ramp capability.
mrtupek2 May 5, 2026
bffc4c8
type alias mfem::future::tuple to smith::tuple and fix ambigious comp…
white238 May 5, 2026
409f0a4
style
white238 May 6, 2026
2ae9e39
fix mfem include
white238 May 6, 2026
8c50439
pin github actions to prevent possible security issue
white238 May 6, 2026
53238ec
Working on getting a robust warm start and boundary condition cutback.
tupek2 May 6, 2026
b37871c
Fix style.
tupek2 May 8, 2026
194d650
Merge branch 'develop' into tupek/system_solver
tupek2 May 8, 2026
f089b19
Merge.
tupek2 May 8, 2026
4b85c39
Fix name.
tupek2 May 8, 2026
47a1039
Merge branch 'tupek/system_solver_extended' into tupek/system_solver_…
tupek2 May 8, 2026
27caf27
Put back warm start solve.
tupek2 May 8, 2026
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ AGENTS.md
agents.md
CLAUDE.md
claude.md
*plan.md
slirp.out
*~
*#
*plan.md
slirp.out

6 changes: 6 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ install(
# Add the conduction examples
add_subdirectory(conduction)

# Add the solid mechanics examples
add_subdirectory(solid_mechanics)

# Add the thermo-mechanics examples
add_subdirectory(thermo_mechanics)

# Add the contact examples
add_subdirectory(contact)

Expand Down
101 changes: 21 additions & 80 deletions examples/contact/homotopy/two_blocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ using VectorSpace = smith::H1<disp_order, dim>;
using DensitySpace = smith::L2<disp_order - 1>;

using SolidMaterial = smith::solid_mechanics::NeoHookeanWithFieldDensity;
using SolidWeakFormT = smith::SolidWeakForm<disp_order, dim, smith::Parameters<DensitySpace>>;
using SolidWeakFormT =
smith::FunctionalWeakForm<dim, smith::H1<disp_order, dim>,
smith::Parameters<smith::H1<disp_order, dim>, smith::H1<disp_order, dim>,
smith::H1<disp_order, dim>, DensitySpace>>;

enum FIELD
{
DISP = SolidWeakFormT::DISPLACEMENT,
VELO = SolidWeakFormT::VELOCITY,
ACCEL = SolidWeakFormT::ACCELERATION,
DENSITY = SolidWeakFormT::NUM_STATES
DISP = 0,
VELO = 1,
ACCEL = 2,
DENSITY = 3
};

/* Nonlinear problem of the form
Expand Down Expand Up @@ -82,74 +85,6 @@ class TiedContactProblem : public EqualityConstrainedHomotopyProblem {
virtual ~TiedContactProblem();
};

class ParaviewWriter {
public:
using StateVecs = std::vector<std::shared_ptr<smith::FiniteElementState>>;
using DualVecs = std::vector<std::shared_ptr<smith::FiniteElementDual>>;

ParaviewWriter(std::unique_ptr<mfem::ParaViewDataCollection> pv_, const StateVecs& states_)
: pv(std::move(pv_)), states(states_)
{
}

ParaviewWriter(std::unique_ptr<mfem::ParaViewDataCollection> pv_, const StateVecs& states_, const StateVecs& duals_)
: pv(std::move(pv_)), states(states_), dual_states(duals_)
{
}

void write(int step, double time, const std::vector<smith::FiniteElementState const*>& current_states)
{
SMITH_MARK_FUNCTION;
SLIC_ERROR_ROOT_IF(current_states.size() != states.size(), "wrong number of output states to write");

for (size_t n = 0; n < states.size(); ++n) {
auto& state = states[n];
*state = *current_states[n];
state->gridFunction();
}

pv->SetCycle(step);
pv->SetTime(time);
pv->Save();
}

private:
std::unique_ptr<mfem::ParaViewDataCollection> pv;
StateVecs states;
StateVecs dual_states;
};

auto createParaviewOutput(const mfem::ParMesh& mesh, const std::vector<const smith::FiniteElementState*>& states,
std::string output_name)
{
if (output_name == "") {
output_name = "default";
}

ParaviewWriter::StateVecs output_states;
for (const auto& s : states) {
output_states.push_back(std::make_shared<smith::FiniteElementState>(s->space(), s->name()));
}

auto non_const_mesh = const_cast<mfem::ParMesh*>(&mesh);
auto paraview_dc = std::make_unique<mfem::ParaViewDataCollection>(output_name, non_const_mesh);
int max_order_in_fields = 0;

// Find the maximum polynomial order in the physics module's states
for (const auto& state : output_states) {
paraview_dc->RegisterField(state->name(), &state->gridFunction());
max_order_in_fields = std::max(max_order_in_fields, state->space().GetOrder(0));
}

// Set the options for the paraview output files
paraview_dc->SetLevelsOfDetail(max_order_in_fields);
paraview_dc->SetHighOrderOutput(true);
paraview_dc->SetDataFormat(mfem::VTKFormat::BINARY);
paraview_dc->SetCompression(true);

return ParaviewWriter(std::move(paraview_dc), output_states, {});
}

int main(int argc, char* argv[])
{
// Initialize and automatically finalize MPI and other libraries
Expand Down Expand Up @@ -227,7 +162,12 @@ int main(int argc, char* argv[])
SolidMaterial mat;
mat.K = 1.0;
mat.G = 0.5;
solid_mechanics_weak_form->setMaterial(smith::DependsOn<0>{}, mesh->entireBodyName(), mat);
solid_mechanics_weak_form->addBodyIntegral(
mesh->entireBodyName(), [mat](auto /*t_info*/, auto /*X*/, auto u, auto /*v*/, auto a, auto density_param) {
typename SolidMaterial::State state;
auto pk_stress = mat.pkStress(state, smith::get<smith::DERIVATIVE>(u), density_param);
return smith::tuple{smith::get<smith::VALUE>(a) * mat.density(density_param), pk_stress};
});

// constant body force
smith::tensor<double, dim> constant_force{};
Expand All @@ -236,9 +176,10 @@ int main(int argc, char* argv[])
}
constant_force[dim - 1] = -1.e-4;

solid_mechanics_weak_form->addBodyIntegral(mesh->entireBodyName(), [constant_force](double /* t */, auto x) {
return smith::tuple{constant_force, 0.0 * smith::get<smith::DERIVATIVE>(x)};
});
solid_mechanics_weak_form->addBodyIntegral(
mesh->entireBodyName(), [constant_force](auto /*t_info*/, auto X, auto... /*inputs*/) {
return smith::tuple{constant_force, 0.0 * smith::get<smith::DERIVATIVE>(X)};
});

auto residual_state_ptrs = smith::getFieldPointers(states, params);
auto contact_state_ptrs = smith::getFieldPointers(contact_states);
Expand Down Expand Up @@ -291,8 +232,8 @@ int main(int argc, char* argv[])
SLIC_WARNING_ROOT_IF(!converged, "Homotopy solver did not converge");

// visualize
auto writer =
createParaviewOutput(mesh->mfemParMesh(), smith::getConstFieldPointers(states), "two_block_tiedcontact_plot");
auto writer = smith::createParaviewWriter(mesh->mfemParMesh(), smith::getConstFieldPointers(states),
"two_block_tiedcontact_plot");
if (visualize) {
mfem::Vector u(states[FIELD::DISP].space().GetTrueVSize());
u = problem.GetDisplacement(X0);
Expand All @@ -307,7 +248,7 @@ int main(int argc, char* argv[])
for (int i = 0; i < iterates.Size(); i++) {
u = problem.GetDisplacement(*iterates[i]);
states[FIELD::DISP].Set(1.0, u);
writer.write((i + 1), static_cast<double>(i + 1), smith::getConstFieldPointers(states));
writer.write(static_cast<size_t>(i + 1), static_cast<double>(i + 1), smith::getConstFieldPointers(states));
}
}
}
Expand Down
73 changes: 25 additions & 48 deletions examples/inertia_relief/inertia_relief_example.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// Copyright (c) Lawrence Livermore National Security, LLC and
// other Smith Project Developers. See the top-level LICENSE file for
// details.
Expand All @@ -16,6 +17,7 @@
#include <format>

#include "smith/smith.hpp"
#include "smith/differentiable_numerics/paraview_writer.hpp"

#include "mfem.hpp"

Expand All @@ -35,51 +37,17 @@ using VectorSpace = smith::H1<disp_order, dim>;
using DensitySpace = smith::L2<disp_order - 1>;

using SolidMaterial = smith::solid_mechanics::NeoHookeanWithFieldDensity;
using SolidWeakFormT = smith::SolidWeakForm<disp_order, dim, smith::Parameters<DensitySpace>>;
using SolidWeakFormT =
smith::FunctionalWeakForm<dim, smith::H1<disp_order, dim>,
smith::Parameters<smith::H1<disp_order, dim>, smith::H1<disp_order, dim>,
smith::H1<disp_order, dim>, DensitySpace>>;

enum FIELD
{
DISP = SolidWeakFormT::DISPLACEMENT,
VELO = SolidWeakFormT::VELOCITY,
ACCEL = SolidWeakFormT::ACCELERATION,
DENSITY = SolidWeakFormT::NUM_STATES
};

class ParaviewWriter {
public:
using StateVecs = std::vector<std::shared_ptr<smith::FiniteElementState>>;
using DualVecs = std::vector<std::shared_ptr<smith::FiniteElementDual>>;

ParaviewWriter(std::unique_ptr<mfem::ParaViewDataCollection> pv_, const StateVecs& states_)
: pv(std::move(pv_)), states(states_)
{
}

ParaviewWriter(std::unique_ptr<mfem::ParaViewDataCollection> pv_, const StateVecs& states_, const StateVecs& duals_)
: pv(std::move(pv_)), states(states_), dual_states(duals_)
{
}

void write(int step, double time, const std::vector<smith::FiniteElementState const*>& current_states)
{
SMITH_MARK_FUNCTION;
SLIC_ERROR_ROOT_IF(current_states.size() != states.size(), "wrong number of output states to write");

for (size_t n = 0; n < states.size(); ++n) {
auto& state = states[n];
*state = *current_states[n];
state->gridFunction();
}

pv->SetCycle(step);
pv->SetTime(time);
pv->Save();
}

private:
std::unique_ptr<mfem::ParaViewDataCollection> pv;
StateVecs states;
StateVecs dual_states;
DISP = 0,
VELO = 1,
ACCEL = 2,
DENSITY = 3
};

/* Nonlinear problem of the form
Expand Down Expand Up @@ -202,21 +170,30 @@ int main(int argc, char* argv[])
SolidMaterial mat;
mat.K = 1.0;
mat.G = 0.5;
solid_mechanics_weak_form->setMaterial(smith::DependsOn<0>{}, mesh->entireBodyName(), mat);
solid_mechanics_weak_form->addBodyIntegral(
mesh->entireBodyName(), [mat](auto /*t_info*/, auto /*X*/, auto u, auto /*v*/, auto a, auto rho) {
typename SolidMaterial::State state;
auto pk_stress = mat.pkStress(state, smith::get<smith::DERIVATIVE>(u), rho);
return smith::tuple{smith::get<smith::VALUE>(a) * mat.density(rho), pk_stress};
});

// apply some traction boundary conditions
std::string surface_name = "side";
mesh->addDomainOfBoundaryElements(surface_name, smith::by_attr<dim>(1));
solid_mechanics_weak_form->addBoundaryFlux(surface_name, [](auto /*x*/, auto n, auto /*t*/) { return 1.0 * n; });
solid_mechanics_weak_form->addBoundaryFlux(
surface_name, [](auto /*t_info*/, auto /*X*/, auto n, auto /*u*/, auto /*v*/, auto /*a*/, auto /*density*/) {
return 1.0 * n;
});

smith::tensor<double, dim> constant_force{};
for (int i = 0; i < dim; i++) {
constant_force[i] = 1.e0;
}

solid_mechanics_weak_form->addBodyIntegral(mesh->entireBodyName(), [constant_force](double /* t */, auto x) {
return smith::tuple{constant_force, 0.0 * smith::get<smith::DERIVATIVE>(x)};
});
solid_mechanics_weak_form->addBodyIntegral(
mesh->entireBodyName(), [constant_force](auto /*t_info*/, auto X, auto... /*inputs*/) {
return smith::tuple{constant_force, 0.0 * smith::get<smith::DERIVATIVE>(X)};
});

// construct constraints
params[0] = 1.;
Expand Down Expand Up @@ -274,7 +251,7 @@ int main(int argc, char* argv[])
return u;
});

auto writer = createParaviewWriter(mesh->mfemParMesh(), objective_states, "inertia_relief");
auto writer = smith::createParaviewWriter(mesh->mfemParMesh(), objective_states, "inertia_relief");
if (visualize) {
writer.write(0, 0.0, objective_states);
}
Expand Down
24 changes: 24 additions & 0 deletions examples/solid_mechanics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Lawrence Livermore National Security, LLC and
# other Smith Project Developers. See the top-level LICENSE file for
# details.
#
# SPDX-License-Identifier: (BSD-3-Clause)

smith_add_executable( NAME composable_solid_mechanics
SOURCES composable_solid_mechanics.cpp
OUTPUT_DIR ${EXAMPLE_OUTPUT_DIRECTORY}
DEPENDS_ON smith
)

install(
FILES
composable_solid_mechanics.cpp
DESTINATION
examples/smith/solid_mechanics
)

if(SMITH_ENABLE_TESTS)
blt_add_test(NAME composable_solid_mechanics
COMMAND composable_solid_mechanics
NUM_MPI_TASKS 1 )
endif()
Loading
Loading