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

Refactor engineering material models to use History and Tensor objects #136

Draft
wants to merge 33 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5128f80
Initial step in project, moving over to populating history with names
reverendbedford May 19, 2022
d87873e
Rewrote enough to get the wrappers to compile
reverendbedford May 26, 2022
5173012
Updated tests for new structure
reverendbedford Aug 23, 2022
3e16456
Updated to current dev, but need to fix superimposed issue
reverendbedford Aug 23, 2022
8bbd97e
Added an internal variable prefix system to avoid conflicting names
reverendbedford Aug 24, 2022
13b0740
Fixed long-term bug in some of the interface code
reverendbedford Aug 24, 2022
ce03b78
Attempt at fixing mac import error
reverendbedford Aug 24, 2022
cec89c8
Very slow but valid way to refactor
reverendbedford Aug 24, 2022
d344fb5
Models transitioned over fully to use actual history object
reverendbedford Aug 25, 2022
ff59757
Interfaces are all updated, now just moving down the call tree
reverendbedford Aug 25, 2022
7872333
WIP1
reverendbedford Aug 26, 2022
fbae3e4
WIP2
reverendbedford Aug 26, 2022
8f82824
WIP3
reverendbedford Aug 26, 2022
d3acf1f
Completed SmallStrainCreepPlasticity
reverendbedford Aug 26, 2022
6d97e02
KMRegimeModel done
reverendbedford Aug 26, 2022
9aef8b7
Damage WIP
reverendbedford Aug 26, 2022
6261e79
Return by value works...
reverendbedford Aug 26, 2022
b263dcb
WIP:damage
reverendbedford Aug 26, 2022
b333efa
High level damage model done
reverendbedford Aug 26, 2022
5a0eefc
Substep model WIP 1
reverendbedford Aug 29, 2022
3774282
Substep model WIP 2
reverendbedford Aug 29, 2022
fb42d50
WIP3: thank god, trial states moved over
reverendbedford Aug 29, 2022
ef57868
Substep model done
reverendbedford Aug 29, 2022
b2fc800
Perfect plasticity done
reverendbedford Aug 29, 2022
4cb812b
RI plasticity done
reverendbedford Aug 29, 2022
d88cb00
Viscplastic done, basically all done
reverendbedford Aug 29, 2022
8980352
Just cleaning up around the edges
reverendbedford Aug 29, 2022
387f766
Done with interfaces
reverendbedford Aug 29, 2022
4b07191
Very important fix
reverendbedford Aug 29, 2022
9ca7d76
Creep top level done
reverendbedford Aug 29, 2022
183379d
Most of creep interface moved
reverendbedford Aug 29, 2022
b5cd433
Creep models done
reverendbedford Aug 29, 2022
2c57cfa
GeneralFlow done
reverendbedford Aug 30, 2022
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ set(NEML_version 1.4.1)
### Setup modules ###
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

### Need c++ 11 ###
set(CMAKE_CXX_STANDARD 11)
### Need c++ 17 ###
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

### Default to shared libs ###
Expand Down
10 changes: 5 additions & 5 deletions include/cp/crystaldamage.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SlipPlaneDamage;
class TransformationFunction;

/// Abstract base class for slip plane damage models
class NEML_EXPORT CrystalDamageModel: public NEMLObject {
class NEML_EXPORT CrystalDamageModel: public HistoryNEMLObject {
public:
CrystalDamageModel(ParameterSet & params,
std::vector<std::string> vars);
Expand All @@ -32,9 +32,9 @@ class NEML_EXPORT CrystalDamageModel: public NEMLObject {
virtual void set_varnames(std::vector<std::string> names);

/// Setup whatever history variables the model requires
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Initialize history
virtual void init_history(History & history) const = 0;
virtual void init_hist(History & history) const = 0;

/// Returns the current projection operator
virtual SymSymR4 projection(
Expand Down Expand Up @@ -85,7 +85,7 @@ class NEML_EXPORT NilDamageModel: public CrystalDamageModel {
static ParameterSet parameters();

/// Initialize history
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Returns the current projection operator
virtual SymSymR4 projection(
Expand Down Expand Up @@ -136,7 +136,7 @@ class NEML_EXPORT PlanarDamageModel: public CrystalDamageModel {
static ParameterSet parameters();

/// Initialize history
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Returns the current projection operator
virtual SymSymR4 projection(
Expand Down
14 changes: 7 additions & 7 deletions include/cp/hucocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace neml {

/// Implementation of a single chemistry <-> size model
// For details see Hu et al. MSE A, 2020
class NEML_EXPORT HuCocksPrecipitationModel: public NEMLObject
class NEML_EXPORT HuCocksPrecipitationModel: public HistoryNEMLObject
{
public:
HuCocksPrecipitationModel(ParameterSet & params);
Expand All @@ -30,9 +30,9 @@ class NEML_EXPORT HuCocksPrecipitationModel: public NEMLObject
virtual void set_varnames(std::vector<std::string> vars);

/// Request whatever history you will need
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Setup history
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Actual (unscaled) f
double f(const History & history) const;
Expand Down Expand Up @@ -207,9 +207,9 @@ class NEML_EXPORT DislocationSpacingHardening: public SlipHardening
virtual void set_varnames(std::vector<std::string> vars);

/// Request whatever history you will need
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Setup history
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Map the set of history variables to the slip system hardening
virtual double hist_to_tau(size_t g, size_t i, const History & history,
Expand Down Expand Up @@ -283,9 +283,9 @@ class NEML_EXPORT HuCocksHardening: public SlipHardening
virtual void set_varnames(std::vector<std::string> vars);

/// Request whatever history you will need
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Setup history
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Map the set of history variables to the slip system hardening
virtual double hist_to_tau(size_t g, size_t i, const History & history,
Expand Down
22 changes: 9 additions & 13 deletions include/cp/inelasticity.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ namespace neml {
/// A inelastic model supplying D_p and W_p
// A complete model for implicit rotations would include the derivatives wrt
// the orientation. Similarly it would include all the w_p derivatives.
class NEML_EXPORT InelasticModel: public NEMLObject {
class NEML_EXPORT InelasticModel: public HistoryNEMLObject {
public:
InelasticModel(ParameterSet & params);
/// Populate a history object with the correct variables
virtual void populate_history(History & history) const = 0;
/// Actually initialize the history object with the starting values
virtual void init_history(History & history) const = 0;

/// Helper for external models that want an average strength
virtual double strength(const History & history, Lattice & L, double T,
Expand Down Expand Up @@ -103,9 +99,9 @@ class NEML_EXPORT NoInelasticity: public InelasticModel {
static ParameterSet parameters();

/// Add history variables (none needed)
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Define initial history (none)
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Helper for external models that want an average strength
virtual double strength(const History & history, Lattice & L, double T,
Expand Down Expand Up @@ -185,9 +181,9 @@ class NEML_EXPORT AsaroInelasticity: public InelasticModel {
static ParameterSet parameters();

/// Populate the history, deferred to the SlipRule
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Initialize the history with the starting values, deferred to the SlipRule
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Helper for external models that want an average strength
virtual double strength(const History & history, Lattice & L, double T,
Expand Down Expand Up @@ -277,9 +273,9 @@ class NEML_EXPORT PowerLawInelasticity: public InelasticModel {
static ParameterSet parameters();

/// Setup history variables (none used in this implementation)
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Initialize the history variables (n/a)
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Helper for external models that want an average strength
virtual double strength(const History & history, Lattice & L, double T,
Expand Down Expand Up @@ -377,9 +373,9 @@ class NEML_EXPORT CombinedInelasticity: public InelasticModel {
const History & fixed) const;

/// Setup all history variables
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Initialize history with actual values
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Sum the symmetric parts of the plastic deformation rates
virtual Symmetric d_p(const Symmetric & stress,
Expand Down
14 changes: 5 additions & 9 deletions include/cp/kinematics.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@
namespace neml {

/// Describes the stress, history, and rotation rates
class NEML_EXPORT KinematicModel: public NEMLObject {
class NEML_EXPORT KinematicModel: public HistoryNEMLObject {
public:
KinematicModel(ParameterSet & params);
/// Populate history with the correct variable names and types
virtual void populate_history(History & history) const = 0;
/// Initialize history with actual starting values
virtual void init_history(History & history) const = 0;

/// Helper for external models that want a strength
virtual double strength(const History & history, Lattice & L, double T,
Expand Down Expand Up @@ -171,9 +167,9 @@ class NEML_EXPORT StandardKinematicModel: public KinematicModel {
static ParameterSet parameters();

/// Populate a history object with the correct variables
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Initialize the history object with the starting values
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Helper for external models that want a strength
virtual double strength(const History & history, Lattice & L, double T,
Expand Down Expand Up @@ -305,9 +301,9 @@ class NEML_EXPORT DamagedStandardKinematicModel: public StandardKinematicModel {
static ParameterSet parameters();

/// Populate a history object with the correct variables
virtual void populate_history(History & history) const;
virtual void populate_hist(History & history) const;
/// Initialize the history object with the starting values
virtual void init_history(History & history) const;
virtual void init_hist(History & history) const;

/// Stress rate
virtual Symmetric stress_rate(
Expand Down
10 changes: 5 additions & 5 deletions include/cp/polycrystal.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ class NEML_EXPORT PolycrystalModel: public NEMLModel_ldi
PolycrystalModel(ParameterSet & params);

size_t n() const;

virtual void populate_hist(History & hist) const;
virtual void init_hist(History & hist) const;

virtual size_t nhist() const;
virtual void init_hist(double * const hist) const;
virtual void populate_state(History & hist) const {};
virtual void init_state(History & hist) const {};

double * history(double * const store, size_t i) const;
double * stress(double * const store, size_t i) const;
Expand Down Expand Up @@ -49,9 +52,6 @@ class NEML_EXPORT TaylorModel: public PolycrystalModel
/// Setup from a ParameterSet
static std::unique_ptr<NEMLObject> initialize(ParameterSet & params);

virtual size_t nstore() const;
virtual void init_store(double * const store) const;

/// Large strain incremental update
virtual void update_ld_inc(
const double * const d_np1, const double * const d_n,
Expand Down
8 changes: 4 additions & 4 deletions include/cp/postprocessors.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class NEML_EXPORT CrystalPostprocessor: public NEMLObject {
public:
CrystalPostprocessor(ParameterSet & params);

virtual void populate_history(const Lattice & L, History & history) const = 0;
virtual void init_history(const Lattice & L, History & history) const = 0;
virtual void populate_hist(const Lattice & L, History & history) const = 0;
virtual void init_hist(const Lattice & L, History & history) const = 0;

virtual void act(SingleCrystalModel & model, const Lattice &,
const double & T, const Symmetric & D,
Expand All @@ -37,8 +37,8 @@ class NEML_EXPORT PTRTwinReorientation: public CrystalPostprocessor {
/// Setup from a ParameterSet
static std::unique_ptr<NEMLObject> initialize(ParameterSet & params);

virtual void populate_history(const Lattice & L, History & history) const;
virtual void init_history(const Lattice & L, History & history) const;
virtual void populate_hist(const Lattice & L, History & history) const;
virtual void init_hist(const Lattice & L, History & history) const;

virtual void act(SingleCrystalModel & model, const Lattice &,
const double & T, const Symmetric & D,
Expand Down
65 changes: 26 additions & 39 deletions include/cp/singlecrystal.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ class NEML_EXPORT SingleCrystalModel: public NEMLModel_ldi, public Solvable
static std::unique_ptr<NEMLObject> initialize(ParameterSet & params);

/// Setup blank history
void populate_history(History & history) const;

void populate_state(History & history) const;
/// Actually initialize history
void init_history(History & history) const;
void init_state(History & history) const;

/// Not changing state
void populate_static(History & history) const;
/// Static stat
void init_static(History & history) const;

/// Useful methods for external models that want an idea of an average
/// strength
Expand All @@ -71,21 +75,16 @@ class NEML_EXPORT SingleCrystalModel: public NEMLModel_ldi, public Solvable
double * Fe) const;

/// Large deformation incremental update
virtual void update_ld_inc(
const double * const d_np1, const double * const d_n,
const double * const w_np1, const double * const w_n,
double T_np1, double T_n,
double t_np1, double t_n,
double * const s_np1, const double * const s_n,
double * const h_np1, const double * const h_n,
double * const A_np1, double * const B_np1,
double & u_np1, double u_n,
double & p_np1, double p_n);

/// Number of stored history variables
virtual size_t nhist() const;
/// Initialize history raw pointer array
virtual void init_hist(double * const hist) const;
virtual void update_ld_inc_interface(
const Symmetric & d_np1, const Symmetric & d_n,
const Skew & w_np1, const Skew & w_n,
double T_np1, double T_n,
double t_np1, double t_n,
Symmetric & s_np1, const Symmetric & s_n,
History & h_np1, const History & h_n,
SymSymR4 & A_np1, SymSkewR4 & B_np1,
double & u_np1, double u_n,
double & p_np1, double p_n);

/// Instantaneous CTE
virtual double alpha(double T) const;
Expand Down Expand Up @@ -129,19 +128,15 @@ class NEML_EXPORT SingleCrystalModel: public NEMLModel_ldi, public Solvable

private:
void attempt_update_ld_inc_(
const double * const d_np1, const double * const d_n,
const double * const w_np1, const double * const w_n,
double T_np1, double T_n,
double t_np1, double t_n,
double * const s_np1, const double * const s_n,
double * const h_np1, const double * const h_n,
double * const A_np1, double * const B_np1,
double & u_np1, double u_n,
double & p_np1, double p_n, int trial_type);

History gather_history_(double * data) const;
History gather_history_(const double * data) const;
History gather_blank_history_() const;
const Symmetric & d_np1, const Symmetric & d_n,
const Skew & w_np1, const Skew & w_n,
double T_np1, double T_n,
double t_np1, double t_n,
Symmetric & s_np1, const Symmetric & s_n,
History & h_np1, const History & h_n,
SymSymR4 & A_np1, SymSkewR4 & B_np1,
double & u_np1, double u_n,
double & p_np1, double p_n, int trial_type);

void calc_tangents_(Symmetric & S, History & H,
SCTrialState * ts, double * const A, double * const B);
Expand All @@ -156,10 +151,6 @@ class NEML_EXPORT SingleCrystalModel: public NEMLModel_ldi, public Solvable

void solve_substep_(SCTrialState * ts, Symmetric & stress, History & hist);

std::vector<std::string> not_updated_() const;

void populate_static_(History & history) const;

private:
std::shared_ptr<KinematicModel> kinematics_;
std::shared_ptr<Lattice> lattice_;
Expand All @@ -171,11 +162,7 @@ class NEML_EXPORT SingleCrystalModel: public NEMLModel_ldi, public Solvable
bool verbose_, linesearch_;
int max_divide_;

History stored_hist_;

std::vector<std::shared_ptr<CrystalPostprocessor>> postprocessors_;
std::vector<std::string> static_names_;
size_t static_size_;

bool elastic_predictor_, fallback_elastic_predictor_;
int force_divide_;
Expand Down
Loading