Skip to content

Commit

Permalink
fix master
Browse files Browse the repository at this point in the history
  • Loading branch information
thelfer committed Nov 30, 2023
2 parents 187db86 + 8cf72e2 commit 55b7894
Show file tree
Hide file tree
Showing 22 changed files with 667 additions and 78 deletions.
38 changes: 38 additions & 0 deletions bindings/c/include/MGIS/Behaviour/MaterialStateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,44 @@ MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_get_non_uniform_material_property(
mgis_real** const, mgis_bv_MaterialStateManager* const, const char* const);

/*!
* \brief set the value of an uniform scalar mass density
* \param[in] s: state manager
* \param[in] v: value of the mass density
*/
MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_set_uniform_scalar_mass_density(
mgis_bv_MaterialStateManager* const, const mgis_real);
/*!
* \brief set the value of an uniform mass density
* \param[in] s: state manager
* \param[in] v: values of the mass density
* \param[in] sm: storage mode
*/
MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_set_non_uniform_mass_density(
mgis_bv_MaterialStateManager* const,
mgis_real* const,
const mgis_bv_MaterialStateManagerStorageMode);

MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_is_mass_density_defined(
int* const, const mgis_bv_MaterialStateManager* const);

MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_is_mass_density_uniform(
int* const, const mgis_bv_MaterialStateManager* const);

MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_get_uniform_mass_density(
mgis_real* const, mgis_bv_MaterialStateManager* const);

MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_get_non_uniform_mass_density(
mgis_real** const, mgis_bv_MaterialStateManager* const);

//

MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_set_uniform_scalar_external_state_variable(
mgis_bv_MaterialStateManager* const, const char* const, const mgis_real);
Expand Down
7 changes: 7 additions & 0 deletions bindings/c/include/MGIS/Behaviour/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ using mgis_bv_State = mgis::behaviour::State;
typedef struct mgis_bv_State mgis_bv_State;
#endif /* __cplusplus */

/*!
* \brief set the mass density
* \param[out] s: state
* \param[in] v: value
*/
MGIS_C_EXPORT mgis_status mgis_bv_state_set_mass_density(mgis_bv_State* const,
const mgis_real);
/*!
* \brief set a gradient' value in a state
* \param[out] s: state
Expand Down
4 changes: 2 additions & 2 deletions bindings/c/src/Integrate.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ mgis_status mgis_bv_integrate_material_data_manager(
const mgis_real dt) {
*r = -1;
try {
*r = mgis::behaviour::integrate(*p, convertIntegrationType(i), *m, dt);
*r = mgis::behaviour::integrate(*p, *m, convertIntegrationType(i), dt);
if ((*r != 1) && (*r != 0)) {
return mgis_report_failure("behaviour integration failed");
}
Expand All @@ -147,7 +147,7 @@ mgis_status mgis_bv_integrate_material_data_manager_with_options(
const mgis_real dt) {
*r = -1;
try {
*r = mgis::behaviour::integrate(*p, *o, *m, dt);
*r = mgis::behaviour::integrate(*p, *m, *o, dt).exit_status;
if ((*r != 1) && (*r != 0)) {
return mgis_report_failure("behaviour integration failed");
}
Expand Down
72 changes: 71 additions & 1 deletion bindings/c/src/MaterialStateManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ mgis_status mgis_bv_material_state_manager_set_non_uniform_material_property(
return mgis_report_failure("null state manager");
}
if (v == nullptr) {
return mgis_report_failure("null state values");
return mgis_report_failure("null material property values");
}
try {
const auto& mp = getVariable(m->b.mps, n);
Expand Down Expand Up @@ -317,6 +317,76 @@ mgis_status mgis_bv_material_state_manager_is_material_property_uniform(
return mgis_report_success();
} // end of mgis_bv_material_state_manager_is_material_property_uniform

MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_set_uniform_scalar_mass_density(
mgis_bv_MaterialStateManager* const m,
const mgis_real v) {
if (m == nullptr) {
return mgis_report_failure("null state manager");
}
try {
setMassDensity(*m, v);
} catch (...) {
return mgis_handle_cxx_exception();
}
return mgis_report_success();
} // end of mgis_bv_material_state_manager_set_uniform_scalar_mass_density

mgis_status mgis_bv_material_state_manager_set_non_uniform_mass_density(
mgis_bv_MaterialStateManager* const m,
mgis_real* const v,
const mgis_bv_MaterialStateManagerStorageMode s) {
using index_type = mgis::span<mgis::real>::index_type;
if (m == nullptr) {
return mgis_report_failure("null state manager");
}
if (v == nullptr) {
return mgis_report_failure("null state values");
}
try {
if (s == MGIS_BV_LOCAL_STORAGE) {
setMassDensity(*m, {v, static_cast<index_type>(m->n)},
mgis::behaviour::MaterialStateManager::LOCAL_STORAGE);
} else {
setMassDensity(*m, {v, static_cast<index_type>(m->n)},
mgis::behaviour::MaterialStateManager::EXTERNAL_STORAGE);
}
} catch (...) {
return mgis_handle_cxx_exception();
}
return mgis_report_success();
} // end of mgis_bv_material_state_manager_set_non_uniform_mass_density

mgis_status mgis_bv_material_state_manager_is_mass_density_defined(
int* const b,
const mgis_bv_MaterialStateManager* const m) {
*b = 0;
if (m == nullptr) {
return mgis_report_failure("null state manager");
}
try {
*b = isMassDensityDefined(*m);
} catch (...) {
return mgis_handle_cxx_exception();
}
return mgis_report_success();
} // end of mgis_bv_material_state_manager_is_mass_density_defined

mgis_status mgis_bv_material_state_manager_is_mass_density_uniform(
int* const b,
const mgis_bv_MaterialStateManager* const m) {
*b = 0;
if (m == nullptr) {
return mgis_report_failure("null state manager");
}
try {
*b = isMassDensityUniform(*m);
} catch (...) {
return mgis_handle_cxx_exception();
}
return mgis_report_success();
} // end of mgis_bv_material_state_manager_is_mass_density_uniform

MGIS_C_EXPORT mgis_status
mgis_bv_material_state_manager_set_uniform_scalar_external_state_variable(
mgis_bv_MaterialStateManager* const m,
Expand Down
9 changes: 9 additions & 0 deletions bindings/c/src/State.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@

extern "C" {

mgis_status mgis_bv_state_set_mass_density(mgis_bv_State* const s,
const mgis_real v) {
if (s == nullptr) {
return mgis_report_failure("invalid argument (null state)");
}
s->mass_density = v;
return mgis_report_success();
} // end of mgis_bv_state_set_mass_density

mgis_status mgis_bv_state_set_gradient_by_name(mgis_bv_State* const s,
const char* const n,
const mgis_real* const v) {
Expand Down
103 changes: 103 additions & 0 deletions bindings/fortran/src/mgis_behaviour.f95
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,28 @@ end function free_behaviour_data_wrapper
end if
end function free_behaviour_data
!
function state_set_mass_density(s, v) result(r)
use mgis_fortran_utilities
use mgis, only: mgis_status
implicit none
interface
function state_set_mass_density_wrapper(s, v) &
bind(c,name = 'mgis_bv_state_set_mass_density') &
result(r)
use, intrinsic :: iso_c_binding, only: c_ptr, c_double
use mgis, only: mgis_status
implicit none
type(c_ptr), intent(in),value :: s
real(c_double), intent(in),value :: v
type(mgis_status) :: r
end function state_set_mass_density_wrapper
end interface
type(State), intent(in) :: s
real(kind=8) :: v
type(mgis_status) :: r
r = state_set_mass_density_wrapper(s%ptr, v)
end function state_set_mass_density
!
function state_set_gradient_by_name(s, n, v) result(r)
use, intrinsic :: iso_c_binding, only: c_loc
use mgis_fortran_utilities
Expand Down Expand Up @@ -3329,6 +3351,87 @@ end function msm_is_material_property_uniform
end if
end function material_state_manager_is_material_property_uniform
!
function material_state_manager_set_uniform_scalar_mass_density(s, v) &
result(r)
use mgis, only: mgis_status
use mgis_fortran_utilities
implicit none
interface
function msm_set_uniform_scalar_mass_density_wrapper(s, v) &
bind(c,name = 'mgis_bv_material_state_manager_set_uniform_scalar_mass_density') &
result(r)
use, intrinsic :: iso_c_binding, only: c_ptr, c_double, c_char
use mgis, only: mgis_status
implicit none
type(c_ptr), intent(in),value :: s
real(kind=c_double), intent(in), value :: v
type(mgis_status) :: r
end function msm_set_uniform_scalar_mass_density_wrapper
end interface
type(MaterialStateManager), intent(in) :: s
real(kind=8), intent(in) :: v
type(mgis_status) :: r
r = msm_set_uniform_scalar_mass_density_wrapper(s %ptr, v)
end function material_state_manager_set_uniform_scalar_mass_density
!
function material_state_manager_is_mass_density_defined(b, s)&
result(r)
use mgis_fortran_utilities
use mgis, only: mgis_status, MGIS_SUCCESS
implicit none
interface
function msm_is_mass_density_defined(b, s) &
bind(c,name = 'mgis_bv_material_state_manager_is_mass_density_defined') &
result(r)
use, intrinsic :: iso_c_binding, only: c_ptr, c_int, c_char
use mgis, only: mgis_status
implicit none
integer(kind=c_int), intent(out) :: b
type(c_ptr), intent(in),value :: s
type(mgis_status) :: r
end function msm_is_mass_density_defined
end interface
logical, intent(out) :: b
type(MaterialStateManager), intent(in) :: s
type(mgis_status) :: r
integer bc
r = msm_is_mass_density_defined(bc, s%ptr)
if( r % exit_status .eq. MGIS_SUCCESS) then
b = bc .eq. 1
else
b = .false.
end if
end function material_state_manager_is_mass_density_defined
!
function material_state_manager_is_mass_density_uniform(b, s)&
result(r)
use mgis_fortran_utilities
use mgis, only: mgis_status, MGIS_SUCCESS
implicit none
interface
function msm_is_mass_density_uniform(b, s) &
bind(c,name = 'mgis_bv_material_state_manager_is_mass_density_uniform') &
result(r)
use, intrinsic :: iso_c_binding, only: c_ptr, c_int, c_char
use mgis, only: mgis_status
implicit none
integer(kind=c_int), intent(out) :: b
type(c_ptr), intent(in),value :: s
type(mgis_status) :: r
end function msm_is_mass_density_uniform
end interface
logical, intent(out) :: b
type(MaterialStateManager), intent(in) :: s
type(mgis_status) :: r
integer bc
r = msm_is_mass_density_uniform(bc, s%ptr)
if( r % exit_status .eq. MGIS_SUCCESS) then
b = bc .eq. 1
else
b = .false.
end if
end function material_state_manager_is_mass_density_uniform
!
function material_state_manager_get_internal_state_variables_stride(n_isvs, s) &
result(r)
use, intrinsic :: iso_c_binding, only: c_size_t
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/src/Integrate.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ void declareIntegrate() {
int (*integrate_ptr2)(MaterialDataManager&, const IntegrationType,
const mgis::real, const mgis::size_type,
const mgis::size_type) = integrate;
int (*integrate_ptr3)(mgis::ThreadPool&, const IntegrationType,
MaterialDataManager&, const mgis::real) = integrate;
int (*integrate_ptr3)(mgis::ThreadPool&, MaterialDataManager&,
const IntegrationType, const mgis::real) = integrate;
BehaviourIntegrationResult (*integrate_ptr4)(
MaterialDataManager&, const BehaviourIntegrationOptions&,
const mgis::real, const mgis::size_type, const mgis::size_type) =
Expand Down
19 changes: 19 additions & 0 deletions bindings/python/src/MaterialStateManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ static void MaterialStateManager_setMaterialProperty2(
setMaterialProperty(sm, n, mgis::python::mgis_convert_to_span(o), s);
} // end of MaterialStateManager_setMaterialProperty

static void MaterialStateManager_setMassDensity(
mgis::behaviour::MaterialStateManager& s,
const mgis::real v) {
mgis::behaviour::setMassDensity(s, v);
} // end of MaterialStateManager_setMassDensity

static void MaterialStateManager_setMassDensity2(
mgis::behaviour::MaterialStateManager& sm,
const boost::python::object& o,
const mgis::behaviour::MaterialStateManager::StorageMode s) {
setMassDensity(sm, mgis::python::mgis_convert_to_span(o), s);
} // end of MaterialStateManager_setMassDensity

static void MaterialStateManager_setExternalStateVariable(
mgis::behaviour::MaterialStateManager& s,
const std::string& n,
Expand Down Expand Up @@ -174,6 +187,8 @@ void declareMaterialStateManager() {
&MaterialStateManager_getInternalStateVariables)
.def("setMaterialProperty", &MaterialStateManager_setMaterialProperty)
.def("setMaterialProperty", &MaterialStateManager_setMaterialProperty2)
.def("setMassDensity", &MaterialStateManager_setMassDensity)
.def("setMassDensity", &MaterialStateManager_setMassDensity2)
.def("setExternalStateVariable",
&MaterialStateManager_setExternalStateVariable)
.def("setExternalStateVariable",
Expand All @@ -183,6 +198,10 @@ void declareMaterialStateManager() {
&MaterialStateManager_setMaterialProperty);
boost::python::def("setMaterialProperty",
&MaterialStateManager_setMaterialProperty2);
boost::python::def("setMassDensity",
&MaterialStateManager_setMassDensity);
boost::python::def("setMassDensity",
&MaterialStateManager_setMassDensity2);
boost::python::def("setExternalStateVariable",
&MaterialStateManager_setExternalStateVariable);
boost::python::def("setExternalStateVariable",
Expand Down
1 change: 1 addition & 0 deletions bindings/python/src/State.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void declareState() {
using mgis::behaviour::Behaviour;
using mgis::behaviour::State;
boost::python::class_<State>("State", boost::python::no_init)
.add_property("mass_density", &State::mass_density)
.add_property("stored_energy", &State::stored_energy)
.add_property("dissipated_energy", &State::dissipated_energy)
.add_property("gradients", &State_getGradients)
Expand Down
3 changes: 2 additions & 1 deletion docs/web/mgis-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
<li><a>Version 2.0.x</a>
<ul>
<li><a href="release-notes-2.0.html">Version 2.0</a></li>
<li><a href="release-notes-2.0.html">Version 2.1</a></li>
<li><a href="release-notes-2.1.html">Version 2.1</a></li>
<li><a href="release-notes-2.2.html">Version 2.2</a></li>
</ul>
</li>
</ul>
Expand Down
Loading

0 comments on commit 55b7894

Please sign in to comment.