Skip to content

Commit f4445d2

Browse files
divyaadil23aabrown100-gitmrp089dcodoniktbolt
authored
Adding CANN material model framework (SimVascular#406)
* Moving changes from my CANN branch to this updated branch with eigen etc - modified a few files * Fix bug with coupled BCs in FSI simulation (SimVascular#333) * add fsi/pipe_RCR_3d. With multiprocs, fails at end of timestep 13 with [set_bc_cpl] Follow pressure load ... error * In set_bc_cpl, use eq.phys instead of eq.dmn[cDmn].phys. For FSI sims, eq.phys = phys_FSI, while eq.dmn[:].phys = [phys_fluid, phys_struct]. Using eq.dmn[:].phys causes issues when cDmn suddenly changes due to likely undefined behavior related to MPI. * Add pipe_RCR_3d test to pytest suite, update test parameters and solution * v3 -> v4 (SimVascular#335) * v3 -> v4 * actions/upload-artifact v4 -> v3, codecov/codecov-action v4 -> v5 * run coverage only on ubuntu22 * Added a check on the flux profile type name. If a match is not found, a runtime error is given. (SimVascular#325) Co-authored-by: Dave Parker <[email protected]> Co-authored-by: Martin R. Pfaller <[email protected]> * Update precomputed dye ad readme (SimVascular#331) * Update test LV Guccione active (SimVascular#337) Reduce momentum and continuity stabilization coefficients, update reference solution, and add README.md and animations. * Check spatial dimension (SimVascular#339) * Change file name. * Add setting the mesh element type from vtk cell type and a check for spatial dimension consistent with mesh element type. * Change to check using element dimension. * Add check for fiber mesh. * Add setting mesh element type for vtp files, reorganize checks. * Only test ubuntu-latest (SimVascular#344) * only test ubuntu-latest * run ubuntu-latest on ubuntu-22.04 container * fix container name * Fixed spatial dimension bug in bw_fluid_3d and index error in set_bc_dir_wl (SimVascular#342) Co-authored-by: Martin Pfaller <[email protected]> * Some more changes * still working on converting CANN func in mat_models to eigen * Copied everything except integrated tests from old branch to here. Still need to resolve some compilation errors * changes migrated from old branch and build is successful * Unit tests for S pass, but CC fail * All unit tests pass * v3 -> v4 (SimVascular#335) * v3 -> v4 * actions/upload-artifact v4 -> v3, codecov/codecov-action v4 -> v5 * run coverage only on ubuntu22 * Only test ubuntu-latest (SimVascular#344) * only test ubuntu-latest * run ubuntu-latest on ubuntu-22.04 container * fix container name * Cleaning up the code * Changing how the xml elements are structured for CANN. Made changes to parameters cpp and h - still need to update set_values function for CANNParameters. Need to modify set_material_props and ComMod. * v3 -> v4 (SimVascular#335) * v3 -> v4 * actions/upload-artifact v4 -> v3, codecov/codecov-action v4 -> v5 * run coverage only on ubuntu22 * Only test ubuntu-latest (SimVascular#344) * only test ubuntu-latest * run ubuntu-latest on ubuntu-22.04 container * fix container name * Fixed set_values. Modified set_material_props and ComMod, but now CANNTable uses CANNRow, so need to change uaniso_hyper functions to accomodate it * Made changes to uaniso_hyper function to accomodate CANNRow type. Need to make similar changes to test.h and cpp * Made changes to test.h and cpp. Code builds but unit tests fail. * Unit tests now pass. Need to remove all the debugging comments * The integrated tests are running but the xml file values are being appended to the 1 row CANN table. Not sure if it happens in set_material_props or ComMod. The value of psi is also wrong - goes to nan and other garbage values * The problem is in set_values in Parameters.cpp. It appends to the vectors instead of rewriting them. particularly, set_parameter_value function - write a new one for CANN perhaps in Parameters.h * changed the reference config for 2 invariants, was wrong before * Integrated test passes for CANN NH now * Cleaned up extra comments * Added unit tests for CANN HO. Fixed an issue with printing activation functions. * fiber directions are read correctly now but the S and CC values are still wrong * The only reason some unit tests are failing is that S_ref = sym(S). Figure out why this is * CC values are wrong, All S and convergence unit tests pass * All unit tests pass now! * Integration LV test cases added for HO with k=0. All tests pass. * Added licence lines to new code files * Fixed parameter value in block compression CANN test * Corrected parameters in struct LV HO test case * Cleaning up the code * Cleaning up the code * ran multiplle proc tests * Replaced the result file that tests check against to be the same as the result from 1 proc test for CANN integrated struct tests * Changed CANNTable to new class in ComMod and tests. Distributed new class among procs. Unit tests pass. Integrated tests with multiple procs fail because no output produced (check mpi on local machine) * Integration tests pass! Just need to clena up the code now * Cleaned up code. Still need to change names of UAnisoHyper just to be consistent with what this model is called * Added citation * Made changes suggested by Dave to ComMod.h and cpp (and the downstream files) * Made changes suggested to UAnisoHyper and consts - renamed all AnisoHyper for consistency * Made code more readable in mat_models.cpp * set_material_props - added for loop * Moved class definition from ComMod and put all external functions in class. Still need to move calc from compute_pk2cc to class for CANN * Moved the calculation to the class. It compiles but the anisotropic unit tests don't pass. * Fixed bug. All tests pass. Just need to clean up code * Cleaned up code * Move svzerodinterface file into solver xml (SimVascular#396) * Change file name. * Add the svZeroDSolver_interface XML element to set the information used to interface to the svZeroDSolver. * Add checking for new and old formats. * Remove processing svZeroD_interface.dat file. * Change giving an integer surface ID in the Block_to_surface_map to a surface name. * Add the svZeroDSolver_block parameter under Add_BC. * Convert missed tests using svZeroDSolver. * Change parameter name to conform. * Stability convergence issue restarting simulation (SimVascular#398) * Change file name. * Remove reading Dn array twice. * Fix yaml ignore md (SimVascular#400) * Change file name. * Update test_macos.yml * Update test_ubuntu.yml * Updating yml files to run test actions only when files in Code and tests are modified. (SimVascular#394) Co-authored-by: Aaron Brown <[email protected]> Co-authored-by: Dave Parker <[email protected]> * Remove checked on the first gmres iteration (SimVascular#405) check on the absolute tolerance for the first gmres iteration is removed. At least one linear iteration is allowed to be completed. * Changed some names * Add check to make sure paramTable is initialized before distributing * If CANN is not used (paramTable is empty) don't broadcast it * Put it inside the if condition instead of having a return * added if statement for material model becasue nrows is also not defined for other materials --------- Co-authored-by: Aaron Brown <[email protected]> Co-authored-by: Martin R. Pfaller <[email protected]> Co-authored-by: dcodoni <[email protected]> Co-authored-by: Dave Parker <[email protected]> Co-authored-by: Han Zhao <[email protected]>
1 parent bf76a32 commit f4445d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2458
-3
lines changed
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
/* Copyright (c) Stanford University, The Regents of the University of California, and others.
2+
*
3+
* All Rights Reserved.
4+
*
5+
* See Copyright-SimVascular.txt for additional details.
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining
8+
* a copy of this software and associated documentation files (the
9+
* "Software"), to deal in the Software without restriction, including
10+
* without limitation the rights to use, copy, modify, merge, publish,
11+
* distribute, sublicense, and/or sell copies of the Software, and to
12+
* permit persons to whom the Software is furnished to do so, subject
13+
* to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included
16+
* in all copies or substantial portions of the Software.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/* This material model implementation is based on the following paper:
32+
Peirlinck, M., Hurtado, J.A., Rausch, M.K. et al. A universal material model subroutine
33+
for soft matter systems. Engineering with Computers 41, 905–927 (2025).
34+
https://doi.org/10.1007/s00366-024-02031-w */
35+
36+
// The functions required for CANN material model implementations are defined here
37+
38+
#include "ArtificialNeuralNetMaterial.h"
39+
#include "ComMod.h"
40+
#include "mat_fun.h"
41+
using namespace mat_fun;
42+
43+
/// @brief 0th layer output of CANN for activation func kf, input x
44+
void ArtificialNeuralNetMaterial::uCANN_h0(const double x, const int kf, double &f, double &df, double &ddf) const {
45+
if (kf == 1) {
46+
f = x;
47+
df = 1;
48+
ddf = 0;
49+
} else if (kf == 2) {
50+
f = (std::abs(x) + x) / 2;
51+
df = 0.5 * (std::abs(x) / x + 1);
52+
ddf = 0;
53+
} else if (kf == 3) {
54+
f = std::abs(x);
55+
df = std::abs(x) / x;
56+
ddf = 0;
57+
}
58+
}
59+
60+
/// @brief 1st layer output of CANN for activation func kf, input x, weight W
61+
void ArtificialNeuralNetMaterial::uCANN_h1(const double x, const int kf, const double W, double &f, double &df, double &ddf) const {
62+
if (kf == 1) {
63+
f = W * x;
64+
df = W;
65+
ddf = 0;
66+
} else if (kf == 2) {
67+
f = W * W * x * x;
68+
df = 2 * W * W * x;
69+
ddf = 2 * W * W;
70+
}
71+
}
72+
73+
/// @brief 2nd layer output of CANN for activation func kf, input x, weight W
74+
void ArtificialNeuralNetMaterial::uCANN_h2(const double x, const int kf, const double W, double &f, double &df, double &ddf) const {
75+
if (kf == 1) {
76+
f = W * x;
77+
df = W;
78+
ddf = 0;
79+
} else if (kf == 2) {
80+
f = std::exp(W * x) - 1;
81+
df = W * std::exp(W * x);
82+
ddf = W * W * std::exp(W * x);
83+
} else if (kf == 3) {
84+
f = -std::log(1 - W * x);
85+
df = W / (1 - W * x);
86+
ddf = -W * W / ((1 - W * x) * (1 - W * x));
87+
}
88+
}
89+
90+
/// @brief Updates psi and its derivatives
91+
void ArtificialNeuralNetMaterial::uCANN(
92+
const double xInv, const int kInv,
93+
const int kf0, const int kf1, const int kf2,
94+
const double W0, const double W1, const double W2,
95+
double &psi, double (&dpsi)[9], double (&ddpsi)[9]
96+
) const {
97+
double f0, df0, ddf0;
98+
uCANN_h0(xInv, kf0, f0, df0, ddf0);
99+
double f1, df1, ddf1;
100+
uCANN_h1(f0, kf1, W0, f1, df1, ddf1);
101+
double f2, df2, ddf2;
102+
uCANN_h2(f1, kf2, W1, f2, df2, ddf2);
103+
104+
psi += W2 * f2;
105+
dpsi[kInv - 1] += W2 * df2 * df1 * df0;
106+
ddpsi[kInv - 1] += W2 * ((ddf2 * df1 * df1 + df2 * ddf1) * df0 * df0 + df2 * df1 * ddf0);
107+
}
108+
109+
/// @brief function to build psi and dpsidI1 to 9
110+
void ArtificialNeuralNetMaterial::evaluate(const double aInv[9], double &psi, double (&dpsi)[9], double (&ddpsi)[9]) const {
111+
// Initializing
112+
psi = 0;
113+
for (int i = 0; i < 9; ++i) {
114+
dpsi[i] = 0;
115+
ddpsi[i] = 0;
116+
}
117+
118+
double ref[9] = {3, 3, 1, 1, 1, 0, 0, 1, 1};
119+
120+
for (int i = 0; i < num_rows; ++i) {
121+
int kInv = this->invariant_indices(i);
122+
int kf0 = this->activation_functions(i, 0);
123+
int kf1 = this->activation_functions(i, 1);
124+
int kf2 = this->activation_functions(i, 2);
125+
double W0 = this->weights(i, 0);
126+
double W1 = this->weights(i, 1);
127+
double W2 = this->weights(i, 2);
128+
129+
double xInv = aInv[kInv - 1] - ref[kInv - 1];
130+
uCANN(xInv, kInv, kf0, kf1, kf2, W0, W1, W2, psi, dpsi, ddpsi);
131+
}
132+
}
133+
134+
template<size_t nsd>
135+
void ArtificialNeuralNetMaterial::computeInvariantsAndDerivatives(
136+
const Matrix<nsd>& C, const Matrix<nsd>& fl, int nfd, double J2d, double J4d, const Matrix<nsd>& Ci,
137+
const Matrix<nsd>& Idm, const double Tfa, Matrix<nsd>& N1, double& psi, double (&Inv)[9],std::array<Matrix<nsd>,9>& dInv,
138+
std::array<Tensor<nsd>,9>& ddInv) const {
139+
140+
// double Inv[9] = {0};
141+
Matrix<nsd> C2 = C * C;
142+
143+
Inv[0] = J2d * C.trace();
144+
Inv[1] = 0.50 * (Inv[0]*Inv[0] - J4d * (C*C).trace());
145+
Inv[2] = C.determinant();
146+
Inv[3] = J2d * (fl.col(0).dot(C * fl.col(0)));
147+
Inv[4] = J4d * (fl.col(0).dot(C2 * fl.col(0)));
148+
149+
Matrix<nsd> dInv1 = -Inv[0]/3 * Ci + J2d * Idm;
150+
Matrix<nsd> dInv2 = (C2.trace()/3)*Ci + Inv[0]*dInv1 + J4d*C;
151+
Matrix<nsd> dInv3 = Inv[2]*Ci;
152+
N1 = fl.col(0)*fl.col(0).transpose();
153+
Matrix<nsd> dInv4 = -Inv[3]/3*Ci + J2d*N1;
154+
Matrix<nsd> dInv5 = J4d*(N1*C + C*N1) - Inv[4]/3*Ci;
155+
156+
Matrix<nsd> dInv6, dInv7, dInv8, dInv9;
157+
Tensor<nsd> ddInv6, ddInv7, ddInv8, ddInv9;
158+
// initialize to 0
159+
dInv6.setZero();
160+
dInv7.setZero();
161+
dInv8.setZero();
162+
dInv9.setZero();
163+
ddInv6.setZero();
164+
ddInv7.setZero();
165+
ddInv8.setZero();
166+
ddInv9.setZero();
167+
168+
Tensor<nsd> dCidC = -symmetric_dyadic_product<nsd>(Ci, Ci);
169+
Matrix<nsd> dJ4ddC = -2.0/3.0 * J4d * Ci;
170+
171+
Tensor<nsd> ddInv1 = (-1.0/3.0)*(dyadic_product<nsd>(dInv1,Ci) + Inv[0]*dCidC + J2d*dyadic_product(Ci,Idm));
172+
Tensor<nsd> ddInv2 = dyadic_product<nsd>(dInv1,dInv1) + Inv[0]*ddInv1 + (1.0/3.0)*C2.trace()*dCidC
173+
+ (1.0/3.0)*dyadic_product<nsd>((C2.trace()*dJ4ddC + 2*J4d*C),Ci)
174+
+ dyadic_product<nsd>(dJ4ddC,C) - J4d*fourth_order_identity<nsd>();
175+
Tensor<nsd> ddInv3 = dyadic_product<nsd>(dInv3,Ci) + Inv[2]*dCidC;
176+
Tensor<nsd> ddInv4 = (-1.0/3.0)*(dyadic_product<nsd>(dInv4,Ci) + J2d*dyadic_product<nsd>(Ci,N1) + Inv[3]*dCidC);
177+
Matrix<nsd> sum1 = (N1*C + C*N1);
178+
Tensor<nsd> ddInv5 = (-1.0/3.0)*(dyadic_product<nsd>(dInv5,Ci) + Inv[4]*dCidC + 2*J4d*dyadic_product(Ci,sum1))
179+
+ J4d*(2*symmetric_dyadic_product(N1,Idm) - dyadic_product(N1,Idm)
180+
+ 2*symmetric_dyadic_product(Idm,N1) - dyadic_product(Idm,N1));
181+
182+
if (nfd == 2) {
183+
Inv[5] = J2d * (fl.col(0).dot(C * fl.col(1)));
184+
Inv[6] = J4d * (fl.col(0).dot(C2 * fl.col(1)));
185+
Inv[7] = J2d * (fl.col(1).dot(C * fl.col(1)));
186+
Inv[8] = J4d * (fl.col(1).dot(C2 * fl.col(1)));
187+
188+
Matrix<nsd> N2 = fl.col(1)*fl.col(1).transpose();
189+
Matrix<nsd> N12 = 0.5*(fl.col(0)*fl.col(1).transpose() + fl.col(1)*fl.col(0).transpose());
190+
191+
192+
dInv6 = -Inv[5]/3*Ci + J2d*N12;
193+
dInv7 = J4d*(N12*C + C*N12) - Inv[6]/3*Ci;
194+
dInv8 = -Inv[7]/3*Ci + J2d*N2;
195+
dInv9 = J4d*(N2*C + C*N2) - Inv[8]/3*Ci;
196+
197+
ddInv6 = -1.0/3.0*(dyadic_product(dInv6,Ci) + J2d*dyadic_product(Ci,N12) + Inv[5]*dCidC);
198+
Matrix<nsd> sum12 = (N12*C + C*N12);
199+
ddInv7 = -1.0/3.0*(dyadic_product(dInv7,Ci) + Inv[6]*dCidC + 2*J4d*dyadic_product(Ci,sum12))
200+
+ J4d*(2*symmetric_dyadic_product(N12,Idm) - dyadic_product(N12,Idm)
201+
+ 2*symmetric_dyadic_product(Idm,N12) - dyadic_product(Idm,N12));
202+
ddInv8 = -1.0/3.0*(dyadic_product(dInv8,Ci) + J2d*dyadic_product(Ci,N2) + Inv[7]*dCidC);
203+
Matrix<nsd> sum2 = (N2*C + C*N2);
204+
ddInv9 = -1.0/3.0*(dyadic_product(dInv9,Ci) + Inv[8]*dCidC + 2*J4d*dyadic_product(Ci,sum2))
205+
+ J4d*(2*symmetric_dyadic_product(N2,Idm) - dyadic_product(N2,Idm)
206+
+ 2*symmetric_dyadic_product(Idm,N2) - dyadic_product(Idm,N2));
207+
}
208+
209+
dInv = {dInv1, dInv2, dInv3, dInv4, dInv5, dInv6, dInv7, dInv8, dInv9};
210+
ddInv = {ddInv1, ddInv2, ddInv3, ddInv4, ddInv5, ddInv6, ddInv7, ddInv8, ddInv9};
211+
}
212+
213+
214+
// Template instantiation
215+
template void ArtificialNeuralNetMaterial::computeInvariantsAndDerivatives<2>(
216+
const Matrix<2>& C, const Matrix<2>& fl, int nfd, double J2d, double J4d, const Matrix<2>& Ci,
217+
const Matrix<2>& Idm, const double Tfa, Matrix<2>& N1, double& psi, double (&Inv)[9], std::array<Matrix<2>,9>& dInv,
218+
std::array<Tensor<2>,9>& ddInv) const;
219+
220+
template void ArtificialNeuralNetMaterial::computeInvariantsAndDerivatives<3>(
221+
const Matrix<3>& C, const Matrix<3>& fl, int nfd, double J2d, double J4d, const Matrix<3>& Ci,
222+
const Matrix<3>& Idm, const double Tfa, Matrix<3>& N1, double& psi, double (&Inv)[9], std::array<Matrix<3>,9>& dInv,
223+
std::array<Tensor<3>,9>& ddInv) const;
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/* Copyright (c) Stanford University, The Regents of the University of California, and others.
2+
*
3+
* All Rights Reserved.
4+
*
5+
* See Copyright-SimVascular.txt for additional details.
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining
8+
* a copy of this software and associated documentation files (the
9+
* "Software"), to deal in the Software without restriction, including
10+
* without limitation the rights to use, copy, modify, merge, publish,
11+
* distribute, sublicense, and/or sell copies of the Software, and to
12+
* permit persons to whom the Software is furnished to do so, subject
13+
* to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included
16+
* in all copies or substantial portions of the Software.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/* This material model implementation is based on the following paper:
32+
Peirlinck, M., Hurtado, J.A., Rausch, M.K. et al. A universal material model subroutine
33+
for soft matter systems. Engineering with Computers 41, 905–927 (2025).
34+
https://doi.org/10.1007/s00366-024-02031-w */
35+
36+
#ifndef ArtificialNeuralNet_model_H
37+
#define ArtificialNeuralNet_model_H
38+
39+
#include "mat_fun.h"
40+
#include "utils.h"
41+
#include "Parameters.h"
42+
#include <vector>
43+
#include "eigen3/Eigen/Core"
44+
#include "eigen3/Eigen/Dense"
45+
#include "eigen3/unsupported/Eigen/CXX11/Tensor"
46+
47+
using namespace mat_fun;
48+
49+
// Class for parameter table for material models discovered by constitutive artificial neural network (CANN)
50+
51+
/* This material model implementation is based on the following paper:
52+
Peirlinck, M., Hurtado, J.A., Rausch, M.K. et al. A universal material model subroutine
53+
for soft matter systems. Engineering with Computers 41, 905–927 (2025).
54+
https://doi.org/10.1007/s00366-024-02031-w */
55+
56+
class ArtificialNeuralNetMaterial
57+
{
58+
public:
59+
60+
// Invariant indices
61+
Vector<int> invariant_indices;
62+
63+
// Activation functions
64+
Array<int> activation_functions;
65+
66+
// Weights
67+
Array<double> weights;
68+
69+
// Number of rows in parameter table
70+
int num_rows;
71+
72+
// Outputs from each layer
73+
void uCANN_h0(const double x, const int kf, double &f, double &df, double &ddf) const;
74+
void uCANN_h1(const double x, const int kf, const double W, double &f, double &df, double &ddf) const;
75+
void uCANN_h2(const double x, const int kf, const double W, double &f, double &df, double &ddf) const;
76+
77+
// Strain energy and derivatives
78+
void uCANN(const double xInv, const int kInv,
79+
const int kf0, const int kf1, const int kf2,
80+
const double W0, const double W1, const double W2,
81+
double &psi, double (&dpsi)[9], double (&ddpsi)[9]) const;
82+
83+
84+
void evaluate(const double aInv[9], double &psi, double (&dpsi)[9], double (&ddpsi)[9]) const;
85+
86+
// Helper for compute_pk2cc
87+
template<size_t nsd>
88+
void computeInvariantsAndDerivatives(
89+
const Matrix<nsd>& C, const Matrix<nsd>& fl, int nfd, double J2d, double J4d, const Matrix<nsd>& Ci,
90+
const Matrix<nsd>& Idm, const double Tfa, Matrix<nsd>& N1, double& psi, double (&Inv)[9], std::array<Matrix<nsd>,9>& dInv,
91+
std::array<Tensor<nsd>,9>& ddInv) const;
92+
93+
};
94+
95+
#endif // ArtificialNeuralNet_model_H

Code/Source/solver/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ set(CSRCS
217217
CmMod.h CmMod.cpp
218218
ComMod.h ComMod.cpp
219219
Timer.h
220-
220+
ArtificialNeuralNetMaterial.h ArtificialNeuralNetMaterial.cpp
221+
221222
SPLIT.c
222223

223224
svZeroD_interface/LPNSolverInterface.h svZeroD_interface/LPNSolverInterface.cpp

Code/Source/solver/CmMod.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,14 @@ void cmType::bcast(const CmMod& cm_mod, int* data) const
153153
MPI_Bcast(data, 1, cm_mod::mpint, cm_mod.master, com());
154154
}
155155

156-
/// @brief bcast int array
156+
/// @brief bcast int Vector
157157
void cmType::bcast(const CmMod& cm_mod, Vector<int>& data) const
158158
{
159159
MPI_Bcast(data.data(), data.size(), cm_mod::mpint, cm_mod.master, com());
160160
}
161161

162+
/// @brief bcast int array
163+
void cmType::bcast(const CmMod& cm_mod, Array<int>& data, const std::string& name) const
164+
{
165+
MPI_Bcast(data.data(), data.size(), cm_mod::mpint, cm_mod.master, com());
166+
}

Code/Source/solver/CmMod.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class cmType {
110110
void bcast(const CmMod& cm_mod, int* data) const;
111111
void bcast(const CmMod& cm_mod, Vector<int>& data) const;
112112

113+
void bcast(const CmMod& cm_mod, Array<int>& data, const std::string& name="") const;
114+
113115
//------------
114116
// bcast_enum
115117
//------------

Code/Source/solver/ComMod.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ eqType::~eqType()
119119
{
120120
}
121121

122+
////////////////////////////
123+
// s t m o d e l T y p e //
124+
////////////////////////////
125+
126+
stModelType::stModelType()
127+
{
128+
}
129+
122130
//////////////////////
123131
// f a c e T y p e //
124132
//////////////////////

0 commit comments

Comments
 (0)