forked from SimVascular/svMultiPhysics
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--------- Co-authored-by: Yuecheng Yu <[email protected]> Co-authored-by: Yuecheng Yu <[email protected]> Co-authored-by: Yuecheng Yu <[email protected]> Co-authored-by: Yuecheng Yu <[email protected]> Co-authored-by: Yuecheng Yu <[email protected]> Co-authored-by: Yuecheng Yu <[email protected]>
- Loading branch information
1 parent
29a94c3
commit b28958c
Showing
5 changed files
with
264 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* Copyright (c) Stanford University, The Regents of the University of California, and others. | ||
* | ||
* All Rights Reserved. | ||
* | ||
* See Copyright-SimVascular.txt for additional details. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject | ||
* to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | ||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "test.h" | ||
|
||
using namespace mat_fun; | ||
using namespace std; | ||
|
||
|
||
TEST(UnitTestIso_1, nHK) { | ||
// Step 1: define parameters | ||
auto matType = consts::ConstitutiveModelType::stIso_nHook; // Material_model: options refer to consts.h | ||
auto volType = consts::ConstitutiveModelType::stVol_ST91; // Dilational_penalty_model | ||
double E = 1e6; // Elasticity_modulus | ||
double nu = 0.5; // Poisson_ratio | ||
double pen = 4e9; // Penalty_parameter | ||
double C01; // additional parameter to C10 (optional) | ||
|
||
// Step 2: construct test object | ||
UnitTestIso nHK(matType, E, nu, volType, pen, C01); | ||
|
||
// Step 3: define the input | ||
double F[3][3] = {}; | ||
F[0][0] = 1.0; F[1][1] = 1.0; F[2][2] = 1.0; // set to Identity | ||
|
||
// Step 4: define the reference output | ||
double S_ref[3][3] = {}; | ||
double Dm_ref[6][6] = {}; | ||
|
||
// Step 5: run unit test | ||
nHK.runUnitTest(F, S_ref, Dm_ref); | ||
|
||
} | ||
|
||
TEST(UnitTestIso_2, MR) { | ||
// Step 1: define parameters | ||
auto matType = consts::ConstitutiveModelType::stIso_MR; // Material_model: options refer to consts.h | ||
auto volType = consts::ConstitutiveModelType::stVol_ST91; // Dilational_penalty_model | ||
double E = 1e6; // Elasticity_modulus | ||
double nu = 0.495; // Poisson_ratio | ||
double pen = 4e9; // Penalty_parameter | ||
double C01 = 0.1; // additional parameter to C10 (optional) | ||
|
||
// Step 2: construct test object | ||
UnitTestIso MR(matType, E, nu, volType, pen, C01); | ||
|
||
// Step 3: define the input | ||
double F[3][3] = {}; | ||
F[0][0] = 1.0; F[1][1] = 1.0; F[2][2] = 1.0; // set to Identity | ||
|
||
// Step 4: define the reference output | ||
double S_ref[3][3] = {}; | ||
double Dm_ref[6][6] = {}; | ||
|
||
// Step 5: run unit test | ||
MR.runUnitTest(F, S_ref, Dm_ref); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* Copyright (c) Stanford University, The Regents of the University of California, and others. | ||
* | ||
* All Rights Reserved. | ||
* | ||
* See Copyright-SimVascular.txt for additional details. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject | ||
* to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | ||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <iostream> | ||
#include "gtest/gtest.h" // include GoogleTest | ||
#include "mat_fun.h" | ||
#include "mat_fun_carray.h" | ||
#include "mat_models.h" | ||
#include "mat_models_carray.h" | ||
|
||
class MockCepMod : public CepMod { | ||
public: | ||
MockCepMod() { | ||
// initialize if needed | ||
} | ||
// Mock methods if needed | ||
}; | ||
class MockdmnType : public dmnType { | ||
public: | ||
MockdmnType() { | ||
// initialize if needed | ||
} | ||
// MockstModelType mockStM; | ||
// Mock methods if needed | ||
}; | ||
class MockmshType : public mshType { | ||
public: | ||
MockmshType() { | ||
// initialize if needed | ||
} | ||
// Mock methods if needed | ||
}; | ||
class MockeqType : public eqType { | ||
public: | ||
MockeqType() { | ||
// initialize if needed | ||
} | ||
MockdmnType mockDmn; | ||
// Mock methods if needed | ||
}; | ||
class MockComMod : public ComMod { | ||
public: | ||
MockComMod() { | ||
// initialize if needed | ||
nsd = 3; | ||
} | ||
MockeqType mockEq; | ||
MockmshType mockMsh; | ||
// Mock methods if needed | ||
}; | ||
|
||
// Class for unit test of isotropic material model (currently only introduced two | ||
// parameters C10 and C01) | ||
class UnitTestIso { | ||
public: | ||
MockComMod com_mod; | ||
MockCepMod cep_mod; | ||
|
||
UnitTestIso(consts::ConstitutiveModelType matType, double E, double nu, | ||
consts::ConstitutiveModelType penType, double pen, double C01 = 0.0) { | ||
int nsd = com_mod.nsd; | ||
auto &dmn = com_mod.mockEq.mockDmn; | ||
mat_fun_carray::ten_init(nsd); // initialize tensor index pointer | ||
dmn.stM.isoType = matType; // Mat_model | ||
double mu = 0.5 * E / (1.0 + nu); // Shear_modulus | ||
dmn.stM.C10 = 0.5 * mu - C01; // set_material_props.h | ||
dmn.stM.C01 = C01; | ||
dmn.stM.volType = penType; // Dilational_penalty_model | ||
dmn.stM.Kpen = pen; // Penalty_parameter | ||
} | ||
|
||
void runUnitTest(double F[3][3], double S_ref[3][3], double Dm_ref[6][6]) { | ||
int nsd = com_mod.nsd; | ||
auto &dmn = com_mod.mockEq.mockDmn; | ||
// hard code for nHK | ||
int nFn = 1; | ||
Array<double> fN(nsd, nFn); | ||
double ya_g = 0.0; | ||
double S[3][3], Dm[6][6]; | ||
|
||
mat_models_carray::get_pk2cc(com_mod, cep_mod, dmn, F, nFn, fN, ya_g, S, Dm); | ||
double tol = 1e-12; // tolerance | ||
|
||
// Compare with reference solution | ||
for (int i = 0; i < 3; i++){ | ||
for (int j = 0; j < 3; j++){ | ||
EXPECT_NEAR(S[i][j], S_ref[i][j], tol); | ||
} | ||
} | ||
} | ||
}; |