8#ifndef model_PolyhedronInclusion_cpp_
9#define model_PolyhedronInclusion_cpp_
48 const std::map<
size_t,std::vector<size_t>>& faceIDs,
52 const double& _mobilityReduction,
56 ,
delta(MatrixDim::Identity())
62 for(
const auto& face :
faces)
64 VectorDim C(VectorDim::Zero());
65 for(
const auto& nodePair : face.second)
78 C/=face.second.size();
80 VectorDim nA(VectorDim::Zero());
82 const VectorDim P0(face.second.front().second);
83 for(
size_t k=0;
k<face.second.size();++
k)
85 const size_t k1(
k<face.second.size()-1?
k+1 : 0);
88 const VectorDim Pk(face.second[
k].second);
89 const VectorDim Pk1(face.second[k1].second);
90 nA+= 0.5*(Pk-P0).cross(Pk1-Pk);
94 for(
const auto& nodePair : face.second)
99 if(!plane.contains(nodePair.second))
101 throw std::runtime_error(
"PolyhedronInclusion: face plane does not include face vertex.");
105 this->emplace(face.first,plane);
118 bool contained(
true);
119 for(
const auto& plane : this->
planes())
121 contained=(contained && plane.second.isAbove(
x));
128 const std::map<
size_t,std::vector<size_t>>& faceIDs)
130 std::map<size_t,std::vector<std::pair<size_t,VectorDim>>>
temp;
131 for(
const auto& fID : faceIDs)
133 std::vector<std::pair<size_t,VectorDim>> tempV;
134 for(
const auto& nID : fID.second)
136 const auto nodeIter(nodesMap.find(nID));
137 if(nodeIter!=nodesMap.end())
139 tempV.emplace_back(nID,nodeIter->second.P);
143 throw std::runtime_error(
"PolyhedronInclusion node not found.");
146 temp.emplace(fID.first,tempV);
154 if (
a != 0 &&
b != 0 && le != 0) {
155 return -
a / abs(
a) * atan(le /
b) + asin(
a * le * abs(
b) / (
b * sqrt((
a *
a +
b *
b) * (
b *
b + le * le))));
172 double dis = sqrt(
a *
a +
b *
b + le * le);
173 if (
a != 0 &&
b != 0 && le != 0) {
174 return (1.0 / (
b *
b + le * le)) * (
175 -le * dis + le * abs(
a) + (
b *
b + le * le) * atanh(le / dis));
179 return -le / dis + atanh(le / dis);
186 if (
b != 0 && le == 0) {
189 else if (
b == 0 && le == 0) {
192 else if (
b == 0 && le != 0) {
193 return (-dis + abs(
a)) / le + atanh(le / dis);
204 if (
a != 0 &&
b != 0 && le != 0) {
205 return b * (
a *
a +
b *
b + le * le - sqrt(
a *
a +
b *
b + le * le) * abs(
a)) / ((
b *
b + le * le) * sqrt(
a *
a +
b *
b + le * le));
208 if (
b != 0 || le != 0) {
209 return b / sqrt(
b *
b + le * le);
216 if (
b != 0 && le == 0) {
217 return (sqrt(
a *
a +
b *
b) - abs(
a)) /
b;
219 else if (
b == 0 && le != 0) {
222 else if (
b == 0 && le == 0) {
268 double dis = sqrt(
a *
a +
b *
b + le * le);
269 if (
a < 0 &&
b != 0 && le != 0) {
270 return a *
b * le / ((
a *
a +
b *
b) * dis) + 2.0 * atan(le /
b) + 2.0 * atan(
a * le / (
b * dis));
272 else if (
a > 0 &&
b != 0 && le != 0) {
273 return a *
b * le / ((
a *
a +
b *
b) * dis) - 2.0 * atan(le /
b) + 2.0 * atan(
a * le / (
b * dis));
282 double dis = sqrt(
a *
a +
b *
b + le * le);
283 if (
a < 0 &&
b != 0 && le != 0) {
284 return -le * (2.0 *
a *
a +
b *
b +
a *
b *
b / dis) / ((
a *
a +
b *
b) * (dis -
a)) + atanh(le / dis);
286 else if (
a > 0 &&
b != 0 && le != 0) {
287 return 2.0 *
a * le / (
b *
b + le * le) + (le / dis) * (-2.0 +
b *
b / (
a *
a +
b *
b) - 2.0 *
a *
a / (
b *
b + le * le)) + atanh(le / dis);
291 return -le / dis + atanh(le / dis);
298 if (
b != 0 && le == 0) {
301 else if (
b == 0 && le != 0) {
302 return 2.0 * (abs(
a) - dis) / le + atanh(le / dis);
304 else if (
b == 0 && le == 0) {
315 double dis = sqrt(
a *
a +
b *
b + le * le);
316 if (
a != 0 &&
b != 0 && le != 0) {
317 return (
b / (
b *
b + le * le)) * (-2.0 * abs(
a) + dis + (
a *
a) / dis);
328 if (
b != 0 && le == 0) {
329 return ((2.0 *
a *
a +
b *
b) / dis - 2.0 * abs(
a)) /
b;
331 else if (
b == 0 && le != 0) {
334 else if (
b == 0 && le == 0) {
345 double dis = sqrt(
a *
a +
b *
b + le * le);
346 if (
a != 0 &&
b != 0 && le != 0) {
347 return (
a *
b * le / ((
a *
a +
b *
b) * pow(
b *
b + le * le, 2.0) * dis)) * (
348 2.0 * pow(
a, 4.0) - le * le * (
b *
b + le * le) +
a *
a * (3.0 *
b *
b + le * le) - 2.0 * (
a *
a +
b *
b) * dis * abs(
a)
359 double dis = sqrt(
a *
a +
b *
b + le * le);
360 if (
a != 0 &&
b != 0 && le != 0) {
361 return (
a / (pow(
b *
b + le * le, 2.0) * dis)) * (
362 -pow(
a *
b, 2.0) + (
a *
a +
b *
b) * le * le + pow(le, 4.0) + (
b *
b - le * le) * dis * abs(
a)
369 if (
b != 0 && le == 0) {
370 return a * (-
a *
a / dis + abs(
a)) / (
b *
b);
372 else if (
b == 0 && le != 0) {
373 return a * (dis - abs(
a)) / (le * le);
375 else if (
b == 0 && le == 0) {
376 return 0.5 *
a / abs(
a);
386 double dis = sqrt(
a *
a +
b *
b + le * le);
387 if (
a != 0 &&
b != 0 && le != 0) {
388 return -
a *
b * le * (
389 a *
a + dis * dis - 2.0 * dis * abs(
a)
390 ) / (pow(
b *
b + le * le, 2.0) * dis);
399 double dis = sqrt(
a *
a +
b *
b + le * le);
400 if (
a != 0 &&
b != 0 && le != 0) {
401 return (1.0 / (3.0 * (
a *
a +
b *
b) * pow(
b *
b + le * le, 3.0) * dis)) * (
402 2.0 * pow(
a, 6.0) * le * (-3.0 *
b *
b + le * le) -
b *
b * le * pow(
b *
b + le * le, 2.0) * (3.0 *
b *
b + 4.0 * le * le)
403 -
a *
a * le * (
b *
b + le * le) * (3.0 * pow(
b, 4.0) + pow(le, 4.0)) + pow(
a, 4.0) * (-9.0 * pow(
b, 4.0) * le + pow(le, 5.0))
405 - 2.0 * le * (-3.0 *
b *
b + le * le) * pow(abs(
a), 3.0) / (3.0 * pow(
b *
b + le * le, 3.0))
410 return -le * (3.0 *
b *
b + 4.0 * le * le) / (3.0 * dis * dis * dis) + atanh(le / dis);
417 if (
b != 0 && le == 0) {
420 else if (
b == 0 && le != 0) {
421 return (1.0 / (3.0 * pow(le, 3.0) * dis)) * (2.0 * pow(
a, 4.0) +
a *
a * le * le - pow(le, 4.0)) - 2.0 * pow(abs(
a), 3.0) / (3.0 * le * le * le) + atanh(le / dis);
423 else if (
b == 0 && le == 0) {
434 double dis = sqrt(
a *
a +
b *
b + le * le);
435 if (
a != 0 &&
b != 0 && le != 0) {
436 return (
b / (3.0 * pow(
b *
b + le * le, 3.0) * dis)) * (
437 2.0 * pow(
a, 4.0) * (
b *
b - 3.0 * le * le) +
a *
a * (
b *
b - 3.0 * le * le) * (
b *
b + le * le)
438 + pow(
b *
b + le * le, 2.0) * (2.0 *
b *
b + 3.0 * le * le) - 2.0 * (
b *
b - 3.0 * le * le) * dis * pow(abs(
a), 3.0)
443 return b * (2.0 *
b *
b + 3.0 * le * le) / (3.0 * dis * dis * dis);
450 if (
b != 0 && le == 0) {
451 return (2.0 * pow(
a, 4.0) + pow(
a *
b, 2.0) + 2.0 * pow(
b, 4.0) - 2.0 * dis * pow(abs(
a), 3.0)) / (3.0 * pow(
b, 3.0) * dis);
453 else if (
b == 0 && le != 0) {
456 else if (
b == 0 && le == 0) {
467 double dis = sqrt(
a *
a +
b *
b + le * le);
468 if (
a != 0 &&
b != 0 && le != 0) {
469 return (le / (3.0 * pow(
b *
b + le * le, 3.0) * dis)) * (
470 pow(
a, 4.0) * (6.0 *
b *
b - 2.0 * le * le) +
a *
a * (3.0 *
b *
b - le * le) * (
b *
b + le * le)
471 + le * le * pow(
b *
b + le * le, 2.0) + 2.0 * (-3.0 *
b *
b + le * le) * dis * pow(abs(
a), 3.0)
476 return pow(le, 3.0) / (3.0 * dis * dis * dis);
486 if (
b != 0 && le == 0) {
489 else if (
b == 0 && le != 0) {
490 return (-2.0 * pow(
a, 4.0) - pow(
a * le, 2.0) + pow(le, 4.0) + 2.0 * dis * pow(abs(
a), 3.0)) / (3.0 * dis * pow(le, 3.0));
492 else if (
b == 0 && le == 0) {
503 double dis = sqrt(
a *
a +
b *
b + le * le);
504 if (
a != 0 &&
b != 0 && le != 0) {
505 return (
b / (3.0 * pow(
b *
b + le * le, 3.0) * dis)) * (
506 -2.0 * pow(
a, 4.0) * (
b *
b - 3.0 * le * le) -
a *
a * (
b *
b - 3.0 * le * le) * (
b *
b + le * le)
507 +
b *
b * pow(
b *
b + le * le, 2.0) + 2.0 * (
b *
b - 3.0 * le * le) * dis * pow(abs(
a), 3.0)
512 return pow(
b, 3.0) / (3.0 * dis * dis * dis);
519 if (
b != 0 && le == 0) {
520 return (-2.0 * pow(
a, 4.0) - pow(
a *
b, 2.0) + pow(
b, 4.0) + 2.0 * dis * pow(abs(
a), 3.0)) / (3.0 * dis * pow(
b, 3.0));
522 else if (
b == 0 && le != 0) {
525 else if (
b == 0 && le == 0) {
596 const double psi_val= (-psi.
I1_a_a_a * Svnorm[
i] * Svnorm[
j] * Svnorm[
k] - psi.
I1_b_b_b * Vnorm[
i] * Vnorm[
j] * Vnorm[
k]
597 - psi.
I1_le_le_le * Vdir[
i] * Vdir[
j] * Vdir[
k] - psi.
I1_a_a_b * (Svnorm[
i] * Svnorm[
j] * Vnorm[
k] + Svnorm[
i] * Vnorm[
j] * Svnorm[
k] + Vnorm[
i] * Svnorm[
j] * Svnorm[
k])
598 - psi.
I1_a_a_le * (Svnorm[
i] * Svnorm[
j] * Vdir[
k] + Svnorm[
i] * Vdir[
j] * Svnorm[
k] + Vdir[
i] * Svnorm[
j] * Svnorm[
k]) - psi.
I1_a_b_b * (Svnorm[
i] * Vnorm[
j] * Vnorm[
k] + Svnorm[
j] * Vnorm[
i] * Vnorm[
k] + Svnorm[
k] * Vnorm[
j] * Vnorm[
i])
599 - psi.
I1_b_b_le * (Vdir[
i] * Vnorm[
j] * Vnorm[
k] + Vdir[
j] * Vnorm[
i] * Vnorm[
k] + Vdir[
k] * Vnorm[
i] * Vnorm[
j]) - psi.
I1_a_le_le * (Svnorm[
i] * Vdir[
j] * Vdir[
k] + Svnorm[
j] * Vdir[
i] * Vdir[
k] + Svnorm[
k] * Vdir[
i] * Vdir[
j])
600 - psi.
I1_b_le_le * (Vnorm[
i] * Vdir[
j] * Vdir[
k] + Vnorm[
j] * Vdir[
i] * Vdir[
k] + Vnorm[
k] * Vdir[
i] * Vdir[
j])
601 - psi.
I1_a_b_le * (Svnorm[
i] * Vnorm[
j] * Vdir[
k] + Svnorm[
i] * Vnorm[
k] * Vdir[
j] + Svnorm[
j] * Vnorm[
i] * Vdir[
k] + Svnorm[
k] * Vnorm[
i] * Vdir[
j] + Svnorm[
j] * Vnorm[
k] * Vdir[
i] + Svnorm[
k] * Vnorm[
j] * Vdir[
i])) * (-Svnorm[l]);
604 return 0.125/(std::numbers::pi*(1.0-this->
nu))*(psi_val
615 Eigen::Matrix<double,voigtSize,voigtSize>
temp(Eigen::Matrix<double,voigtSize,voigtSize>::Zero());
618 for(
const auto& face :
faces)
620 const auto& P0(face.second[0].second);
621 const auto& P1(face.second[1].second);
622 const auto& P2(face.second[2].second);
623 const VectorDim Svnorm((P1-P0).cross(P2-P1).normalized());
624 const double a(Svnorm.dot(P0-
x));
625 for(
size_t e=0;
e<face.second.size();++
e)
627 const size_t e1(
e<face.second.size()-1?
e+1 : 0);
628 const VectorDim& vm(face.second[
e].second);
629 const VectorDim& vp(face.second[e1].second);
630 const VectorDim Vdir((vp-vm).normalized());
631 const VectorDim Vnorm(Vdir.cross(Svnorm));
632 const double b((vp-
x).dot(Vnorm));
633 const double lm((vm-
x).dot(Vdir));
634 const double lp((vp-
x).dot(Vdir));
650 const MatrixDim PHI(-Svnorm*PHI_j.transpose());
662 temp(iV,jV)+=
eshelbyTensorComponent(
i,
j,
k,l,PHI,
delta,psi,Svnorm,Vnorm,Vdir);
746 return this->
lambda*elStrain.trace()*MatrixDim::Identity()+2.0*this->
mu*elStrain;
750 const SymmetricVoigtTraits<dim> PolyhedronInclusion<dim>::voigtTraits=
SymmetricVoigtTraits<dim>((
typename SymmetricVoigtTraits<dim>::VoigtSizeMatrixType()<<0,0,1,1,2,2,1,2,0,2,0,1).finished());
EshelbyInclusionBase(const MatrixDim &_eT, const double &_nu, const double &_mu, const double &_mobilityReduction, const int &_phaseID, const std::shared_ptr< SecondPhase< dim > > &sph)
MatrixDim stress(const VectorDim &x) const override
const std::map< size_t, std::vector< std::pair< size_t, VectorDim > > > faces
const std::map< size_t, PolyhedronInclusionNodeIO< dim > > & nodes
static double Psi_I1_a_a_b(double a, double b, double le)
static double Psi_I1_b_le_le(double a, double b, double le)
static double Psi_I1_b_b_le(double a, double b, double le)
static std::map< size_t, std::vector< std::pair< size_t, VectorDim > > > getFaces(const std::map< size_t, PolyhedronInclusionNodeIO< dim > > &nodesMap, const std::map< size_t, std::vector< size_t > > &faceIDs)
static double Psi_I1_a_b_b(double a, double b, double le)
MatrixDim strain(const VectorDim &x) const
static double Phi_u_II_le(double a, double b, double le)
static const SymmetricVoigtTraits< dim > voigtTraits
const std::map< size_t, Plane< dim > > & planes() const
static double Phi_u_II_a(double a, double b, double le)
MatrixDim elasticStrain(const VectorDim &x) const
static double Psi_I1_b_b_b(double a, double b, double le)
static double Psi_I1_a_a_a(double a, double b, double le)
PolyhedronInclusion(const std::map< size_t, PolyhedronInclusionNodeIO< dim > > &nodesMap, const std::map< size_t, std::vector< size_t > > &faceIDs, const MatrixDim &_eT, const double &_nu, const double &_mu, const double &_mobilityReduction, const int &_phaseID, const std::shared_ptr< SecondPhase< dim > > &sph)
static double Psi_I1_a_le_le(double a, double b, double le)
static double Psi_I1_a_b_le(double a, double b, double le)
MatrixVoigtSize eshelbyTensorVoigt(const VectorDim &x) const
double eshelbyTensorComponent(const int &i, const int &j, const int &k, const int &l, const MatrixDim &PHI, const MatrixDim &delta, const Psi_I1 &psi, const VectorDim &Svnorm, const VectorDim &Vnorm, const VectorDim &Vdir) const
static double Psi_I1_a_a_le(double a, double b, double le)
bool contains(const VectorDim &x) const override
static double Psi_I1_le_le_le(double a, double b, double le)
static double Phi_u_II_b(double a, double b, double le)
Eigen::Matrix< size_t, voigtSize, 2 > VoigtSizeMatrixType