Skip to content

Commit c6f54ed

Browse files
committed
fix compile errors and test fails
1 parent 91daaeb commit c6f54ed

File tree

11 files changed

+48
-18
lines changed

11 files changed

+48
-18
lines changed

examples/degeus_mechanics/mech.i

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
[TensorComputes]
1313
[Initialize]
14+
[Finit]
15+
type = RankTwoIdentity
16+
buffer = F
17+
[]
18+
1419
[phase]
1520
type = PhaseMechanicsTest
1621
buffer = phase
@@ -76,6 +81,16 @@
7681
[]
7782
[]
7883

84+
[TensorSolver]
85+
# no variables are integrated by this solver (FFTMechanics performs a steady state mechanics solve)
86+
type = ForwardEulerSolver
87+
root_compute = root
88+
# deformation tensor is just forwarded Fnew -> F
89+
forward_buffer = F
90+
forward_buffer_new = Fnew
91+
substeps = 10
92+
[]
93+
7994
[TensorOutputs]
8095
[deformation_tensor]
8196
type = XDMFTensorOutput

include/base/SwiftApp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SwiftApp : public MooseApp
2424
public:
2525
static InputParameters validParams();
2626

27-
SwiftApp(InputParameters parameters);
27+
SwiftApp(const InputParameters & parameters);
2828
virtual ~SwiftApp();
2929

3030
static void registerApps();

include/problems/TensorProblem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace Swift
4141
{
4242
struct ConstantBase
4343
{
44+
virtual ~ConstantBase() = default;
4445
virtual std::string getType() = 0;
4546
};
4647

@@ -185,6 +186,7 @@ class TensorProblem : public FEProblem, public DomainInterface
185186
/// substepping timestep
186187
Real _sub_dt;
187188
Real _sub_time;
189+
unsigned int _substep;
188190

189191
/// simulation time for the currently running output thread
190192
Real _output_time;

include/tensor_computes/FFTMechanics.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class FFTMechanics : public TensorOperator<>
6969
const torch::Tensor * const _applied_macroscopic_strain;
7070

7171
const bool _verbose;
72+
const bool _accept_nonconverged;
7273

7374
using TensorOperatorBase::_dim;
7475
using TensorOperatorBase::_domain;

include/tensor_computes/HyperElasticIsotropic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#pragma once
1010

1111
#include "TensorOperator.h"
12-
#include "neml2/tensors/Vec.h"
1312

1413
/**
1514
* Hyperelastic isotropic material model

include/tensor_computes/NEML2TensorCompute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class NEML2TensorCompute : public TensorOperatorBase
3030

3131
protected:
3232
#ifdef NEML2_ENABLED
33-
neml2::Model & _model;
33+
std::shared_ptr<neml2::Model> _model;
3434

3535
std::vector<std::pair<const torch::Tensor *, neml2::LabeledAxisAccessor>> _input_mapping;
3636
std::vector<std::pair<neml2::LabeledAxisAccessor, torch::Tensor *>> _output_mapping;

moose

Submodule moose updated 1325 files

src/base/SwiftApp.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ SwiftApp::validParams()
4747
return params;
4848
}
4949

50-
SwiftApp::SwiftApp(InputParameters parameters) : MooseApp(parameters)
50+
SwiftApp::SwiftApp(const InputParameters & parameters) : MooseApp(parameters)
5151
{
5252
SwiftApp::registerAll(_factory, _action_factory, _syntax);
5353
MooseTensor::swift_global_settings._torch_device =

src/tensor_computes/FFTMechanics.C

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ FFTMechanics::validParams()
4444
"Applied macroscopic strain");
4545
params.addParam<TensorInputBufferName>("F", "F", "Deformation gradient tensor.");
4646
params.addParam<bool>("verbose", false, "Print non-linear residuals.");
47+
params.addParam<bool>("accept_nonconverged", false, "Accept a non-converged solution");
4748
return params;
4849
}
4950

@@ -71,7 +72,8 @@ FFTMechanics::FFTMechanics(const InputParameters & parameters)
7172
_applied_macroscopic_strain(isParamValid("applied_macroscopic_strain")
7273
? &getInputBuffer("applied_macroscopic_strain")
7374
: nullptr),
74-
_verbose(getParam<bool>("verbose"))
75+
_verbose(getParam<bool>("verbose")),
76+
_accept_nonconverged(getParam<bool>("accept_nonconverged"))
7577
{
7678
// Build projection tensor once
7779
const auto & q = _domain.getKGrid();
@@ -150,7 +152,7 @@ FFTMechanics::computeBuffer()
150152

151153
// print nonlinear residual to the screen
152154
if (_verbose)
153-
_console << "|R|=" << anorm << "\t|R/R0|=" << rnorm << '\n';
155+
_console << "|R|=" << anorm << "\t|R/R0|=" << rnorm << std::endl;
154156

155157
// check convergence
156158
if ((rnorm < _nl_rel_tol || anorm < _nl_abs_tol) && iiter > 0)
@@ -159,8 +161,18 @@ FFTMechanics::computeBuffer()
159161
iiter++;
160162

161163
if (iiter > _nl_max_its)
162-
paramError("nl_max_its",
163-
"Exceeded the maximum number of nonlinear iterations without converging.");
164+
{
165+
if (_accept_nonconverged)
166+
paramWarning(
167+
"nl_max_its", "Accepting non-converged solution |R|=", anorm, "\t|R/R0|=", rnorm);
168+
else
169+
paramError(
170+
"nl_max_its",
171+
"Exceeded the maximum number of nonlinear iterations without converging with |R|=",
172+
anorm,
173+
"\t|R/R0|=",
174+
rnorm);
175+
}
164176
}
165177
}
166178

src/tensor_computes/HyperElasticIsotropic.C

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ HyperElasticIsotropic::HyperElasticIsotropic(const InputParameters & parameters)
3333
_tI4s((_tI4 + _tI4rt) / 2.0),
3434
_tII(MooseTensor::dyad22(_tI, _tI)),
3535
_tF(getInputBuffer("F")),
36-
_pFstar(isParamValid("Fstar") ? &getInputBuffer("F") : nullptr),
36+
_pFstar(isParamValid("Fstar") ? &getInputBuffer("Fstar") : nullptr),
3737
_tmu(getInputBuffer("mu")),
3838
_tK(getInputBuffer("K")),
3939
_tK4(getOutputBuffer("tangent_operator"))
@@ -60,8 +60,10 @@ HyperElasticIsotropic::computeBuffer()
6060
// First Piola-Kirchhoff stress: P = F_e * S
6161
_u = dot22(F_e, S);
6262

63+
_tK4 = dot24(S, _tI4) + ddot44(ddot44(_tI4rt, dot42(dot24(F_e, C4), trans2(F_e))), _tI4rt);
64+
6365
// Consistent tangent: K_ijkl = F^e_{im} C_{jlmn} F^e_{kn} + delta_{ik} S_{jl}
64-
const auto K_geo = torch::einsum("...im,...jlmn,...kn->...ijkl", F_e, C4, F_e);
65-
const auto K_stress = torch::einsum("ik,jl,...jl->...ijkl", _ti, _ti, S);
66-
_tK4 = K_geo + K_stress;
66+
// const auto K_geo = torch::einsum("...im,...jlmn,...kn->...ijkl", {F_e, C4, F_e});
67+
// const auto K_stress = torch::einsum("ik,jl,...jl->...ijkl", {_ti, _ti, S});
68+
// _tK4 = K_geo + K_stress;
6769
}

0 commit comments

Comments
 (0)