Skip to content

Commit

Permalink
Minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
TLCFEM committed Dec 2, 2024
1 parent a7fcb05 commit 05a5ede
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 57 deletions.
28 changes: 10 additions & 18 deletions Include/whereami/whereami.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,36 +89,30 @@ static int WAI_PREFIX(getModulePath_)(HMODULE module, char* out, int capacity, i

size = GetModuleFileNameW(module, buffer1, sizeof(buffer1) / sizeof(buffer1[0]));

if(size == 0)
break;
if(size == 0) break;
else if(size == (DWORD)(sizeof(buffer1) / sizeof(buffer1[0]))) {
DWORD size_ = size;
do {
wchar_t* path_;

path_ = (wchar_t*)WAI_REALLOC(path, sizeof(wchar_t) * size_ * 2);
if(!path_)
break;
if(!path_) break;
size_ *= 2;
path = path_;
size = GetModuleFileNameW(module, path, size_);
} while(size == size_);
}
while(size == size_);

if(size == size_)
break;
if(size == size_) break;
}
else
path = buffer1;
else path = buffer1;

if(!_wfullpath(buffer2, path, MAX_PATH))
break;
if(!_wfullpath(buffer2, path, MAX_PATH)) break;
length_ = (int)wcslen(buffer2);
length__ = WideCharToMultiByte(CP_UTF8, 0, buffer2, length_, out, capacity, NULL, NULL);

if(length__ == 0)
length__ = WideCharToMultiByte(CP_UTF8, 0, buffer2, length_, NULL, 0, NULL, NULL);
if(length__ == 0)
break;
if(length__ == 0) length__ = WideCharToMultiByte(CP_UTF8, 0, buffer2, length_, NULL, 0, NULL, NULL);
if(length__ == 0) break;

if(length__ <= capacity && dirname_length) {
int i;
Expand All @@ -140,9 +134,7 @@ static int WAI_PREFIX(getModulePath_)(HMODULE module, char* out, int capacity, i
return ok ? length : -1;
}

WAI_NOINLINE WAI_FUNCSPEC int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length) {
return WAI_PREFIX(getModulePath_)(NULL, out, capacity, dirname_length);
}
WAI_NOINLINE WAI_FUNCSPEC int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length) { return WAI_PREFIX(getModulePath_)(NULL, out, capacity, dirname_length); }

WAI_NOINLINE WAI_FUNCSPEC int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) {
HMODULE module;
Expand Down
8 changes: 4 additions & 4 deletions Material/Material3D/Concrete/CDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "CDP.h"

podarray<double> CDP::compute_tension_backbone(const double kappa) const {
podarray<double> out(6);
vec6 CDP::compute_tension_backbone(const double kappa) const {
vec6 out;

const auto s_phi = sqrt(1. + a_t * (a_t + 2.) * kappa);
const auto t_phi = (1. + .5 * a_t) / s_phi;
Expand All @@ -35,8 +35,8 @@ podarray<double> CDP::compute_tension_backbone(const double kappa) const {
return out;
}

podarray<double> CDP::compute_compression_backbone(const double kappa) const {
podarray<double> out(6);
vec6 CDP::compute_compression_backbone(const double kappa) const {
vec6 out;

const auto s_phi = sqrt(1. + a_c * (a_c + 2.) * kappa);
const auto t_phi = (1. + .5 * a_c) / s_phi;
Expand Down
4 changes: 2 additions & 2 deletions Material/Material3D/Concrete/CDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class CDP final : public NonlinearCDP {
const double a_t, cb_t, f_t;
const double a_c, cb_c, f_c;

[[nodiscard]] podarray<double> compute_tension_backbone(double) const override;
[[nodiscard]] podarray<double> compute_compression_backbone(double) const override;
[[nodiscard]] vec6 compute_tension_backbone(double) const override;
[[nodiscard]] vec6 compute_compression_backbone(double) const override;

public:
explicit CDP(
Expand Down
8 changes: 4 additions & 4 deletions Material/Material3D/Concrete/CustomCDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <Domain/DomainBase.h>
#include <Toolbox/utility.h>

podarray<double> CustomCDP::compute_tension_backbone(const double kappa) const {
auto response = podarray<double>(6);
vec6 CustomCDP::compute_tension_backbone(const double kappa) const {
vec6 response;
const auto t_response = t_expression->evaluate(kappa);
for(auto I = 0llu; I < t_response.n_elem; ++I) response(I) = t_response(I);

Expand All @@ -35,8 +35,8 @@ podarray<double> CustomCDP::compute_tension_backbone(const double kappa) const {
return response;
}

podarray<double> CustomCDP::compute_compression_backbone(const double kappa) const {
auto response = podarray<double>(6);
vec6 CustomCDP::compute_compression_backbone(const double kappa) const {
vec6 response;
const auto c_response = c_expression->evaluate(kappa);
for(auto I = 0llu; I < c_response.n_elem; ++I) response(I) = c_response(I);

Expand Down
4 changes: 2 additions & 2 deletions Material/Material3D/Concrete/CustomCDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class CustomCDP final : public NonlinearCDP {

ResourceHolder<Expression> t_expression, c_expression;

[[nodiscard]] podarray<double> compute_tension_backbone(double) const override;
[[nodiscard]] podarray<double> compute_compression_backbone(double) const override;
[[nodiscard]] vec6 compute_tension_backbone(double) const override;
[[nodiscard]] vec6 compute_compression_backbone(double) const override;

public:
CustomCDP(
Expand Down
32 changes: 16 additions & 16 deletions Material/Material3D/Concrete/NonlinearCDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
const double NonlinearCDP::root_three_two = sqrt(1.5);
const mat NonlinearCDP::unit_dev_tensor = tensor::unit_deviatoric_tensor4();

double NonlinearCDP::compute_r(const vec& in) {
double NonlinearCDP::compute_r(const vec3& in) {
const auto r = .5 + .5 * accu(in) / accu(abs(in));
return !std::isfinite(r) || r < 0. ? .0 : r > 1. ? 1. : r;
}

vec NonlinearCDP::compute_dr(const vec& in) {
vec3 NonlinearCDP::compute_dr(const vec3& in) {
const auto g = accu(abs(in));

vec out = .5 / g * (ones(3) - accu(in) * sign(in) / g);
vec3 out = .5 / g * (ones(3) - accu(in) * sign(in) / g);

if(!out.is_finite()) out.zeros();

Expand Down Expand Up @@ -70,21 +70,21 @@ int NonlinearCDP::update_trial_status(const vec& t_strain) {

trial_stress = (trial_stiffness = initial_stiffness) * (trial_strain - plastic_strain); // 6

vec principal_stress; // 3
mat principal_direction; // 3x3
vec3 principal_stress; // 3
mat33 principal_direction; // 3x3
if(!eig_sym(principal_stress, principal_direction, tensor::stress::to_tensor(trial_stress), "std")) return SUANPAN_FAIL;

const auto trans = transform::compute_jacobian_nominal_to_principal(principal_direction);

const auto s = tensor::dev(trial_stress); // 6
const auto norm_s = tensor::stress::norm(s); // 1
vec n = s / norm_s; // 6
vec6 n = s / norm_s; // 6
if(!n.is_finite()) n.zeros();

const auto ps = tensor::dev(principal_stress); // 3
const vec pn = normalise(ps); // 3
const vec3 pn = normalise(ps); // 3

const vec dsigmadlambda = -double_shear * pn - three_alpha_p_bulk; // 6
const vec3 dsigmadlambda = -double_shear * pn - three_alpha_p_bulk; // 3

const auto dgdsigma_t = (pn(2) + alpha_p) / g_t;
const auto dgdsigma_c = (pn(0) + alpha_p) / g_c;
Expand All @@ -94,14 +94,14 @@ int NonlinearCDP::update_trial_status(const vec& t_strain) {

const auto const_yield = alpha * accu(principal_stress) + root_three_two * norm_s;

vec residual(3), incre;
mat jacobian(3, 3, fill::zeros);
vec3 residual, incre;
mat33 jacobian(fill::zeros);

podarray<double> t_para, c_para;
vec6 t_para, c_para;

auto lambda = 0., ref_error = 0.;
double r, beta;
vec dr;
vec3 dr;

auto counter = 0u;
while(true) {
Expand Down Expand Up @@ -186,13 +186,13 @@ int NonlinearCDP::update_trial_status(const vec& t_strain) {
// update trial stress
trial_stress = transform::compute_jacobian_principal_to_nominal(principal_direction) * new_stress;

const mat dnde = double_shear / norm_s * (unit_dev_tensor - n * n.t());
const mat66 dnde = double_shear / norm_s * (unit_dev_tensor - n * n.t());

// \dfrac{\partial\bar{\sigma}}{\partial\varepsilon^{tr}}
trial_stiffness -= double_shear * lambda * dnde;

const rowvec drdsigma = dr.t() * trans;
const rowvec prpe = drdsigma * trial_stiffness;
const rowvec6 drdsigma = dr.t() * trans;
const rowvec6 prpe = drdsigma * trial_stiffness;

// compute local derivatives
mat left(3, 6);
Expand All @@ -209,7 +209,7 @@ int NonlinearCDP::update_trial_status(const vec& t_strain) {
// \dfrac{\mathrm{d}\bar{\sigma}}{\mathrm{d}\varepsilon^{tr}}
trial_stiffness -= (double_shear * n + three_alpha_p_bulk * tensor::unit_tensor2) * dlambdade;

trial_stiffness = (damage * eye(6, 6) + scale * d_t * damage_c * (1. - s0) * trial_stress * drdsigma) * trial_stiffness + trial_stress * scale * rowvec{recovery * damage_c * t_para(3), damage_t * c_para(3)} * dkappade;
trial_stiffness = (damage * eye(6, 6) + scale * d_t * damage_c * (1. - s0) * trial_stress * drdsigma) * trial_stiffness + trial_stress * scale * rowvec2{recovery * damage_c * t_para(3), damage_t * c_para(3)} * dkappade;

trial_stress *= damage;

Expand Down
10 changes: 5 additions & 5 deletions Material/Material3D/Concrete/NonlinearCDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class NonlinearCDP : protected DataNonlinearCDP, public Material3D {
const double pfplambda = -3. * alpha * three_alpha_p_bulk - root_three_two * double_shear;
const double one_minus_alpha = 1. - alpha;

const vec unit_alpha_p{alpha_p, alpha_p, alpha_p, 0., 0., 0.};
const vec6 unit_alpha_p{alpha_p, alpha_p, alpha_p, 0., 0., 0.};

static double compute_r(const vec&);
static vec compute_dr(const vec&);
static double compute_r(const vec3&);
static vec3 compute_dr(const vec3&);

[[nodiscard]] inline double compute_s(double) const;

Expand All @@ -83,7 +83,7 @@ class NonlinearCDP : protected DataNonlinearCDP, public Material3D {
*
* \return d f \bar{f} \md{d} \md{f} \md{\bar{f}}
*/
[[nodiscard]] virtual podarray<double> compute_tension_backbone(double) const = 0;
[[nodiscard]] virtual vec6 compute_tension_backbone(double) const = 0;

/**
* \brief compute compression backbone
Expand All @@ -98,7 +98,7 @@ class NonlinearCDP : protected DataNonlinearCDP, public Material3D {
*
* \return d f \bar{f} \md{d} \md{f} \md{\bar{f}}
*/
[[nodiscard]] virtual podarray<double> compute_compression_backbone(double) const = 0;
[[nodiscard]] virtual vec6 compute_compression_backbone(double) const = 0;

public:
NonlinearCDP(
Expand Down
8 changes: 4 additions & 4 deletions Material/Material3D/Concrete/TableCDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "TableCDP.h"

podarray<double> TableCDP::compute_tension_backbone(const double kappa) const {
podarray<double> out(6);
vec6 TableCDP::compute_tension_backbone(const double kappa) const {
vec6 out;

if(kappa < dt_table(0, 0)) {
out(3) = dt_table(0, 1) / dt_table(0, 0); // \md{d}
Expand Down Expand Up @@ -52,8 +52,8 @@ podarray<double> TableCDP::compute_tension_backbone(const double kappa) const {
return out;
}

podarray<double> TableCDP::compute_compression_backbone(const double kappa) const {
podarray<double> out(6);
vec6 TableCDP::compute_compression_backbone(const double kappa) const {
vec6 out;

if(kappa < dc_table(0, 0)) {
out(3) = dc_table(0, 1) / dc_table(0, 0); // \md{d}
Expand Down
4 changes: 2 additions & 2 deletions Material/Material3D/Concrete/TableCDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
class TableCDP final : public NonlinearCDP {
mat t_table, c_table, dt_table, dc_table;

[[nodiscard]] podarray<double> compute_tension_backbone(double) const override;
[[nodiscard]] podarray<double> compute_compression_backbone(double) const override;
[[nodiscard]] vec6 compute_tension_backbone(double) const override;
[[nodiscard]] vec6 compute_compression_backbone(double) const override;

public:
TableCDP(
Expand Down

0 comments on commit 05a5ede

Please sign in to comment.