Skip to content

Commit

Permalink
Breaking change: reorder model templates to assume fracture (but not …
Browse files Browse the repository at this point in the history
…mechanics model)
  • Loading branch information
streeve committed Oct 31, 2024
1 parent ea7e69f commit fcd8ecf
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 102 deletions.
3 changes: 1 addition & 2 deletions examples/mechanics/compact_tension_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ void crackBranchingExample( const std::string filename )
// ====================================================
// Force model
// ====================================================
using model_type = CabanaPD::ForceModel<CabanaPD::PMB, CabanaPD::Fracture,
CabanaPD::Plastic>;
using model_type = CabanaPD::ForceModel<CabanaPD::PMB, CabanaPD::Plastic>;
model_type force_model( delta, K, G0 );

// ====================================================
Expand Down
2 changes: 1 addition & 1 deletion examples/mechanics/crack_branching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void crackBranchingExample( const std::string filename )
// ====================================================
// Force model
// ====================================================
using model_type = CabanaPD::ForceModel<CabanaPD::PMB, CabanaPD::Fracture>;
using model_type = CabanaPD::ForceModel<CabanaPD::PMB>;
model_type force_model( delta, K, G0 );

// ====================================================
Expand Down
3 changes: 2 additions & 1 deletion examples/mechanics/elastic_wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ void elasticWaveExample( const std::string filename )
// Force model
// ====================================================
using model_type =
CabanaPD::ForceModel<CabanaPD::LinearLPS, CabanaPD::NoFracture>;
CabanaPD::ForceModel<CabanaPD::LinearLPS, CabanaPD::Elastic,
CabanaPD::NoFracture>;
model_type force_model( delta, K, G );

// ====================================================
Expand Down
2 changes: 1 addition & 1 deletion examples/mechanics/fragmenting_cylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void fragmentingCylinderExample( const std::string filename )
// ====================================================
// Force model
// ====================================================
using model_type = CabanaPD::ForceModel<CabanaPD::PMB, CabanaPD::Fracture>;
using model_type = CabanaPD::ForceModel<CabanaPD::PMB>;
model_type force_model( delta, K, G0 );
// using model_type =
// CabanaPD::ForceModel<CabanaPD::LPS, CabanaPD::Fracture>;
Expand Down
4 changes: 2 additions & 2 deletions examples/mechanics/kalthoff_winkler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ void kalthoffWinklerExample( const std::string filename )
// ====================================================
// Force model
// ====================================================
using model_type = CabanaPD::ForceModel<CabanaPD::PMB, CabanaPD::Fracture>;
using model_type = CabanaPD::ForceModel<CabanaPD::PMB>;
model_type force_model( delta, K, G0 );
// using model_type =
// CabanaPD::ForceModel<CabanaPD::LPS, CabanaPD::Fracture>;
// CabanaPD::ForceModel<CabanaPD::LPS>;
// model_type force_model( delta, K, G, G0 );

// ====================================================
Expand Down
4 changes: 2 additions & 2 deletions src/CabanaPD_ForceModels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ struct BaseTemperatureModel
}
};

template <typename ModelType, typename DamageType,
typename PlasticityType = Elastic,
template <typename ModelType, typename PlasticityType = Elastic,
typename DamageType = Fracture,
typename ThermalType = TemperatureIndependent, typename... DataTypes>
struct ForceModel;

Expand Down
17 changes: 10 additions & 7 deletions src/force/CabanaPD_ForceModels_LPS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace CabanaPD
{
template <>
struct ForceModel<LPS, NoFracture> : public BaseForceModel
struct ForceModel<LPS, Elastic, NoFracture> : public BaseForceModel
{
using base_type = BaseForceModel;
using base_model = LPS;
Expand Down Expand Up @@ -63,9 +63,10 @@ struct ForceModel<LPS, NoFracture> : public BaseForceModel
};

template <>
struct ForceModel<LPS, Fracture> : public ForceModel<LPS, NoFracture>
struct ForceModel<LPS, Elastic, Fracture>
: public ForceModel<LPS, Elastic, NoFracture>
{
using base_type = ForceModel<LPS, NoFracture>;
using base_type = ForceModel<LPS, Elastic, NoFracture>;
using base_model = typename base_type::base_model;
using fracture_type = Fracture;
using thermal_type = base_type::thermal_type;
Expand Down Expand Up @@ -106,9 +107,10 @@ struct ForceModel<LPS, Fracture> : public ForceModel<LPS, NoFracture>
};

template <>
struct ForceModel<LinearLPS, NoFracture> : public ForceModel<LPS, NoFracture>
struct ForceModel<LinearLPS, Elastic, NoFracture>
: public ForceModel<LPS, Elastic, NoFracture>
{
using base_type = ForceModel<LPS, NoFracture>;
using base_type = ForceModel<LPS, Elastic, NoFracture>;
using base_model = typename base_type::base_model;
using fracture_type = typename base_type::fracture_type;
using thermal_type = base_type::thermal_type;
Expand All @@ -124,9 +126,10 @@ struct ForceModel<LinearLPS, NoFracture> : public ForceModel<LPS, NoFracture>
};

template <>
struct ForceModel<LinearLPS, Fracture> : public ForceModel<LPS, Fracture>
struct ForceModel<LinearLPS, Elastic, Fracture>
: public ForceModel<LPS, Elastic, Fracture>
{
using base_type = ForceModel<LPS, Fracture>;
using base_type = ForceModel<LPS, Elastic, Fracture>;
using base_model = typename base_type::base_model;
using fracture_type = typename base_type::fracture_type;
using thermal_type = base_type::thermal_type;
Expand Down
65 changes: 37 additions & 28 deletions src/force/CabanaPD_ForceModels_PMB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace CabanaPD
{
template <>
struct ForceModel<PMB, NoFracture, Elastic, TemperatureIndependent>
struct ForceModel<PMB, Elastic, NoFracture, TemperatureIndependent>
: public BaseForceModel
{
using base_type = BaseForceModel;
Expand Down Expand Up @@ -70,10 +70,10 @@ struct ForceModel<PMB, NoFracture, Elastic, TemperatureIndependent>
};

template <>
struct ForceModel<PMB, NoFracture, Plastic, TemperatureIndependent>
: public ForceModel<PMB, NoFracture, Elastic, TemperatureIndependent>
struct ForceModel<PMB, Plastic, NoFracture, TemperatureIndependent>
: public ForceModel<PMB, Elastic, NoFracture, TemperatureIndependent>
{
using base_type = ForceModel<PMB, NoFracture>;
using base_type = ForceModel<PMB, Elastic, NoFracture>;
using base_model = PMB;
using fracture_type = NoFracture;
using plasticity_type = Plastic;
Expand Down Expand Up @@ -131,10 +131,10 @@ struct ForceModel<PMB, NoFracture, Plastic, TemperatureIndependent>
};

template <>
struct ForceModel<PMB, Fracture, Elastic, TemperatureIndependent>
: public ForceModel<PMB, NoFracture, Elastic, TemperatureIndependent>
struct ForceModel<PMB, Elastic, Fracture, TemperatureIndependent>
: public ForceModel<PMB, Elastic, NoFracture, TemperatureIndependent>
{
using base_type = ForceModel<PMB, NoFracture>;
using base_type = ForceModel<PMB, Elastic, NoFracture>;
using base_model = typename base_type::base_model;
using fracture_type = Fracture;
using plasticity_type = Elastic;
Expand Down Expand Up @@ -179,10 +179,10 @@ struct ForceModel<PMB, Fracture, Elastic, TemperatureIndependent>
};

template <>
struct ForceModel<PMB, Fracture, Plastic, TemperatureIndependent>
: public ForceModel<PMB, Fracture, Elastic, TemperatureIndependent>
struct ForceModel<PMB, Plastic, Fracture, TemperatureIndependent>
: public ForceModel<PMB, Elastic, Fracture, TemperatureIndependent>
{
using base_type = ForceModel<PMB, Fracture>;
using base_type = ForceModel<PMB>;
using base_model = typename base_type::base_model;
using fracture_type = Fracture;
using plasticity_type = Plastic;
Expand Down Expand Up @@ -230,10 +230,10 @@ struct ForceModel<PMB, Fracture, Plastic, TemperatureIndependent>
};

template <>
struct ForceModel<LinearPMB, NoFracture, Elastic, TemperatureIndependent>
: public ForceModel<PMB, NoFracture, Elastic, TemperatureIndependent>
struct ForceModel<LinearPMB, Elastic, NoFracture, TemperatureIndependent>
: public ForceModel<PMB, Elastic, NoFracture, TemperatureIndependent>
{
using base_type = ForceModel<PMB, NoFracture>;
using base_type = ForceModel<PMB, Elastic, NoFracture>;
using base_model = typename base_type::base_model;
using fracture_type = typename base_type::fracture_type;
using plasticity_type = Elastic;
Expand All @@ -247,10 +247,10 @@ struct ForceModel<LinearPMB, NoFracture, Elastic, TemperatureIndependent>
};

template <>
struct ForceModel<LinearPMB, Fracture, Elastic, TemperatureIndependent>
: public ForceModel<PMB, Fracture, Elastic, TemperatureIndependent>
struct ForceModel<LinearPMB, Elastic, Fracture, TemperatureIndependent>
: public ForceModel<PMB, Elastic, Fracture, TemperatureIndependent>
{
using base_type = ForceModel<PMB, Fracture>;
using base_type = ForceModel<PMB>;
using base_model = typename base_type::base_model;
using fracture_type = typename base_type::fracture_type;
using plasticity_type = Elastic;
Expand All @@ -268,13 +268,13 @@ struct ForceModel<LinearPMB, Fracture, Elastic, TemperatureIndependent>
};

template <typename TemperatureType>
struct ForceModel<PMB, NoFracture, Elastic, TemperatureDependent,
struct ForceModel<PMB, Elastic, NoFracture, TemperatureDependent,
TemperatureType>
: public ForceModel<PMB, NoFracture, Elastic, TemperatureIndependent>,
: public ForceModel<PMB, Elastic, NoFracture, TemperatureIndependent>,
BaseTemperatureModel<TemperatureType>
{
using base_type =
ForceModel<PMB, NoFracture, Elastic, TemperatureIndependent>;
ForceModel<PMB, Elastic, NoFracture, TemperatureIndependent>;
using base_temperature_type = BaseTemperatureModel<TemperatureType>;
using base_model = PMB;
using fracture_type = NoFracture;
Expand Down Expand Up @@ -310,24 +310,33 @@ struct ForceModel<PMB, NoFracture, Elastic, TemperatureDependent,
}
};

// Default to Fracture.
template <typename ParticleType>
auto createForceModel( PMB, NoFracture, ParticleType particles,
auto createForceModel( PMB model, ParticleType particles, const double delta,
const double K, const double alpha, const double temp0 )
{
return createForceModel( model, Fracture{}, particles, delta, K, alpha,
temp0 );
}

template <typename FractureType, typename ParticleType>
auto createForceModel( PMB, FractureType, ParticleType particles,
const double delta, const double K, const double alpha,
const double temp0 )
{
auto temp = particles.sliceTemperature();
using temp_type = decltype( temp );
return ForceModel<PMB, NoFracture, Elastic, TemperatureDependent,
return ForceModel<PMB, Elastic, FractureType, TemperatureDependent,
temp_type>( delta, K, temp, alpha, temp0 );
}

template <typename TemperatureType>
struct ForceModel<PMB, Fracture, Elastic, TemperatureDependent, TemperatureType>
: public ForceModel<PMB, Fracture, Elastic, TemperatureIndependent>,
struct ForceModel<PMB, Elastic, Fracture, TemperatureDependent, TemperatureType>
: public ForceModel<PMB, Elastic, Fracture, TemperatureIndependent>,
BaseTemperatureModel<TemperatureType>
{
using base_type =
ForceModel<PMB, Fracture, Elastic, TemperatureIndependent>;
ForceModel<PMB, Elastic, Fracture, TemperatureIndependent>;
using base_temperature_type = BaseTemperatureModel<TemperatureType>;
using base_model = typename base_type::base_model;
using fracture_type = typename base_type::fracture_type;
Expand Down Expand Up @@ -378,15 +387,15 @@ struct ForceModel<PMB, Fracture, Elastic, TemperatureDependent, TemperatureType>
}
};

template <typename ParticleType>
auto createForceModel( PMB, Fracture, ParticleType particles,
template <typename FractureType, typename ParticleType>
auto createForceModel( PMB, FractureType, ParticleType particles,
const double delta, const double K, const double G0,
const double alpha, const double temp0 )
{
auto temp = particles.sliceTemperature();
using temp_type = decltype( temp );
return ForceModel<PMB, Fracture, Elastic, TemperatureDependent, temp_type>(
delta, K, G0, temp, alpha, temp0 );
return ForceModel<PMB, Elastic, FractureType, TemperatureDependent,
temp_type>( delta, K, G0, temp, alpha, temp0 );
}

} // namespace CabanaPD
Expand Down
30 changes: 17 additions & 13 deletions src/force/CabanaPD_Force_LPS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,20 @@
namespace CabanaPD
{
template <class ExecutionSpace>
class Force<ExecutionSpace, ForceModel<LPS, NoFracture>>
class Force<ExecutionSpace, ForceModel<LPS, Elastic, NoFracture>>
{
protected:
bool _half_neigh;
ForceModel<LPS, NoFracture> _model;
ForceModel<LPS, Elastic, NoFracture> _model;

Timer _timer;
Timer _energy_timer;

public:
using exec_space = ExecutionSpace;

Force( const bool half_neigh, const ForceModel<LPS, NoFracture> model )
Force( const bool half_neigh,
const ForceModel<LPS, Elastic, NoFracture> model )
: _half_neigh( half_neigh )
, _model( model )
{
Expand Down Expand Up @@ -253,21 +254,23 @@ class Force<ExecutionSpace, ForceModel<LPS, NoFracture>>
};

template <class ExecutionSpace>
class Force<ExecutionSpace, ForceModel<LPS, Fracture>>
: public Force<ExecutionSpace, ForceModel<LPS, NoFracture>>
class Force<ExecutionSpace, ForceModel<LPS, Elastic, Fracture>>
: public Force<ExecutionSpace, ForceModel<LPS, Elastic, NoFracture>>
{
protected:
using base_type = Force<ExecutionSpace, ForceModel<LPS, NoFracture>>;
using base_type =
Force<ExecutionSpace, ForceModel<LPS, Elastic, NoFracture>>;
using base_type::_half_neigh;
ForceModel<LPS, Fracture> _model;
ForceModel<LPS, Elastic, Fracture> _model;

using base_type::_energy_timer;
using base_type::_timer;

public:
using exec_space = ExecutionSpace;

Force( const bool half_neigh, const ForceModel<LPS, Fracture> model )
Force( const bool half_neigh,
const ForceModel<LPS, Elastic, Fracture> model )
: base_type( half_neigh, model )
, _model( model )
{
Expand Down Expand Up @@ -499,13 +502,14 @@ class Force<ExecutionSpace, ForceModel<LPS, Fracture>>
};

template <class ExecutionSpace>
class Force<ExecutionSpace, ForceModel<LinearLPS, NoFracture>>
: public Force<ExecutionSpace, ForceModel<LPS, NoFracture>>
class Force<ExecutionSpace, ForceModel<LinearLPS, Elastic, NoFracture>>
: public Force<ExecutionSpace, ForceModel<LPS, Elastic, NoFracture>>
{
protected:
using base_type = Force<ExecutionSpace, ForceModel<LPS, NoFracture>>;
using base_type =
Force<ExecutionSpace, ForceModel<LPS, Elastic, NoFracture>>;
using base_type::_half_neigh;
ForceModel<LinearLPS, NoFracture> _model;
ForceModel<LinearLPS, Elastic, NoFracture> _model;

using base_type::_energy_timer;
using base_type::_timer;
Expand All @@ -514,7 +518,7 @@ class Force<ExecutionSpace, ForceModel<LinearLPS, NoFracture>>
using exec_space = ExecutionSpace;

Force( const bool half_neigh,
const ForceModel<LinearLPS, NoFracture> model )
const ForceModel<LinearLPS, Elastic, NoFracture> model )
: base_type( half_neigh, model )
, _model( model )
{
Expand Down
Loading

0 comments on commit fcd8ecf

Please sign in to comment.