Skip to content

Commit

Permalink
Merge pull request #4473 from KratosMultiphysics/release7/cherrypick-…
Browse files Browse the repository at this point in the history
…4350

[Release] Cherrypick #4350 and #4462 into Release branch
  • Loading branch information
loumalouomega authored Mar 19, 2019
2 parents 7091f49 + 663e3f1 commit df4a914
Show file tree
Hide file tree
Showing 17 changed files with 215 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ script:
- make runkratos
- make install/fast
- cd ../kratos/python_scripts
- python3 run_tests.py -l small -c python3
- python3 run_tests.py -l small -c python3 -v2
- ccache -s
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace Kratos
const std::size_t NumberNeighbours
)
{
Properties::Pointer p_elem_prop = ThisModelPart.pGetProperties(0);
Properties::Pointer p_elem_prop = ThisModelPart.CreateNewProperties(0);

// First we create the nodes
NodeType::Pointer p_node_1 = ThisModelPart.CreateNewNode( 1, 0.0 , 0.0 , 0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Kratos

void ShellToSolidShellProcessCreateModelPart(ModelPart& ThisModelPart)
{
Properties::Pointer p_elem_prop = ThisModelPart.pGetProperties(0);
Properties::Pointer p_elem_prop = ThisModelPart.CreateNewProperties(0);

p_elem_prop->SetValue(THICKNESS, 0.2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Kratos

void SolidShellProcessCreateModelPart(ModelPart& ThisModelPart)
{
Properties::Pointer p_elem_prop = ThisModelPart.pGetProperties(0);
Properties::Pointer p_elem_prop = ThisModelPart.CreateNewProperties(0);

// First we create the nodes
NodeType::Pointer p_node_1 = ThisModelPart.CreateNewNode(1, 0.0 , 0.0 , 0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ KRATOS_TEST_CASE_IN_SUITE(TotalLagrangian2D3_StaticSensitivity, KratosStructural
smtsss::PrimalTestSolver solver{&primal_model_part, response_node_id};
const double delta = 1e-7;
const double response_value0 = solver.CalculateResponseValue();
ModelPart& adjoint_model_part =
CreateStructuralMechanicsAdjointTestModelPart(&primal_model_part);
ModelPart& adjoint_model_part = CreateStructuralMechanicsAdjointTestModelPart(&primal_model_part);
smtsss::AdjointTestSolver adjoint_solver{&adjoint_model_part, response_node_id};
for (unsigned i_node : {1, 2, 3})
{
Expand Down Expand Up @@ -205,4 +204,4 @@ SolvingStrategyType::Pointer AdjointTestSolver::CreateAdjointSolvingStrategy(

} // namespace smtsss
} // namespace
} // namespace Kratos
} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ SolvingStrategyType::Pointer CreatePrimalSolvingStrategy(ModelPart* pModelPart)
SchemeType::Pointer p_scheme =
Kratos::make_shared<ResidualBasedBossakDisplacementScheme<SparseSpaceType, LocalSpaceType>>(0.0);
ConvergenceCriteriaType::Pointer p_conv_criteria =
Kratos::make_shared<ResidualCriteria<SparseSpaceType, LocalSpaceType>>(1e-24, 1e-25);
Kratos::make_shared<ResidualCriteria<SparseSpaceType, LocalSpaceType>>(1e-12, 1e-14);
return Kratos::make_shared<ResidualBasedNewtonRaphsonStrategy<SparseSpaceType, LocalSpaceType, LinearSolverType>>(
*pModelPart, p_scheme, p_linear_solver, p_conv_criteria, 30, true, false, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Kratos

void Create2DGeometry(ModelPart& ThisModelPart, const std::string& ElementName)
{
Properties::Pointer p_elem_prop = ThisModelPart.pGetProperties(0);
Properties::Pointer p_elem_prop = ThisModelPart.CreateNewProperties(0);

// First we create the nodes
NodeType::Pointer p_node_1 = ThisModelPart.CreateNewNode(1, 0.0 , 0.0 , 0.0);
Expand Down Expand Up @@ -76,7 +76,7 @@ namespace Kratos

void Create3DGeometry(ModelPart& ThisModelPart, const std::string& ElementName)
{
Properties::Pointer p_elem_prop = ThisModelPart.pGetProperties(0);
Properties::Pointer p_elem_prop = ThisModelPart.CreateNewProperties(0);

// First we create the nodes
NodeType::Pointer p_node_1 = ThisModelPart.CreateNewNode(1 , 0.0 , 1.0 , 1.0);
Expand Down Expand Up @@ -209,6 +209,8 @@ namespace Kratos
process_info[STEP] = 1;
process_info[NL_ITERATION_NUMBER] = 1;

Testing::Create2DGeometry(this_model_part, "SmallDisplacementElement2D3N");

// In case the StructuralMechanicsApplciation is not compiled we skip the test
Properties::Pointer p_elem_prop = this_model_part.pGetProperties(0);
if (!KratosComponents<ConstitutiveLaw>::Has("LinearElasticPlaneStrain2DLaw"))
Expand All @@ -219,8 +221,6 @@ namespace Kratos
p_elem_prop->SetValue(YOUNG_MODULUS, 1.0);
p_elem_prop->SetValue(POISSON_RATIO, 0.0);

Testing::Create2DGeometry(this_model_part, "SmallDisplacementElement2D3N");

for (auto& node : this_model_part.Nodes()) {
if (node.X() > 0.9) {
node.FastGetSolutionStepValue(DISPLACEMENT_X) += 0.1;
Expand Down Expand Up @@ -257,7 +257,9 @@ namespace Kratos
auto& process_info = this_model_part.GetProcessInfo();
process_info[STEP] = 1;
process_info[NL_ITERATION_NUMBER] = 1;


Testing::Create3DGeometry(this_model_part, "SmallDisplacementElement3D4N");

// In case the StructuralMechanicsApplciation is not compiled we skip the test
Properties::Pointer p_elem_prop = this_model_part.pGetProperties(0);
if (!KratosComponents<ConstitutiveLaw>::Has("LinearElastic3DLaw"))
Expand All @@ -268,8 +270,6 @@ namespace Kratos
p_elem_prop->SetValue(YOUNG_MODULUS, 1.0);
p_elem_prop->SetValue(POISSON_RATIO, 0.0);

Testing::Create3DGeometry(this_model_part, "SmallDisplacementElement3D4N");

for (auto& node : this_model_part.Nodes()) {
if (node.X() > 0.9) {
node.FastGetSolutionStepValue(DISPLACEMENT_X) += 0.1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,11 @@ KRATOS_TEST_CASE_IN_SUITE(LinearElasticCasePertubationTensorUtility, KratosStruc
ModelPart& r_model_part = this_model.CreateModelPart("Main");

ConstitutiveLaw::Parameters cl_configuration_values;
Properties material_properties = r_model_part.GetProperties(1);
Properties::Pointer p_material_properties = r_model_part.CreateNewProperties(1);
Vector stress_vector, strain_vector;
Matrix tangent_moduli, deformation_gradient_F;
double det_deformation_gradient_F;
SettingBasicCase(r_model_part, cl_configuration_values, material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F);
SettingBasicCase(r_model_part, cl_configuration_values, *p_material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F);

auto p_constitutive_law = KratosComponents<ConstitutiveLaw>().Get("LinearElastic3DLaw").Clone();
p_constitutive_law->CalculateMaterialResponse(cl_configuration_values, ConstitutiveLaw::StressMeasure::StressMeasure_Cauchy);
Expand Down Expand Up @@ -449,11 +449,11 @@ KRATOS_TEST_CASE_IN_SUITE(HyperElasticCasePertubationTensorUtility, KratosStruct
ModelPart& r_model_part = this_model.CreateModelPart("Main");

ConstitutiveLaw::Parameters cl_configuration_values;
Properties material_properties = r_model_part.GetProperties(1);
Properties::Pointer p_material_properties = r_model_part.CreateNewProperties(1);
Vector stress_vector, strain_vector;
Matrix tangent_moduli, deformation_gradient_F;
double det_deformation_gradient_F;
SettingBasicCase(r_model_part, cl_configuration_values, material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F, false);
SettingBasicCase(r_model_part, cl_configuration_values, *p_material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F, false);

auto p_constitutive_law = KratosComponents<ConstitutiveLaw>().Get("KirchhoffSaintVenant3DLaw").Clone();
p_constitutive_law->CalculateMaterialResponse(cl_configuration_values, ConstitutiveLaw::StressMeasure::StressMeasure_PK2);
Expand Down Expand Up @@ -484,11 +484,11 @@ KRATOS_TEST_CASE_IN_SUITE(QuadraticLinearElasticCasePertubationTensorUtility, Kr
ModelPart& r_model_part = this_model.CreateModelPart("Main");

ConstitutiveLaw::Parameters cl_configuration_values;
Properties material_properties = r_model_part.GetProperties(1);
Properties::Pointer p_material_properties = r_model_part.CreateNewProperties(1);
Vector stress_vector, strain_vector;
Matrix tangent_moduli, deformation_gradient_F;
double det_deformation_gradient_F;
SettingBasicCase(r_model_part, cl_configuration_values, material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F);
SettingBasicCase(r_model_part, cl_configuration_values, *p_material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F);

auto p_constitutive_law = KratosComponents<ConstitutiveLaw>().Get("LinearElastic3DLaw").Clone();
p_constitutive_law->CalculateMaterialResponse(cl_configuration_values, ConstitutiveLaw::StressMeasure::StressMeasure_PK2);
Expand All @@ -505,11 +505,11 @@ KRATOS_TEST_CASE_IN_SUITE(QuadraticKirchhoffHyperElasticCasePertubationTensorUti
ModelPart& r_model_part = this_model.CreateModelPart("Main");

ConstitutiveLaw::Parameters cl_configuration_values;
Properties material_properties = r_model_part.GetProperties(1);
Properties::Pointer p_material_properties = r_model_part.CreateNewProperties(1);
Vector stress_vector, strain_vector;
Matrix tangent_moduli, deformation_gradient_F;
double det_deformation_gradient_F;
SettingBasicCase(r_model_part, cl_configuration_values, material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F, false);
SettingBasicCase(r_model_part, cl_configuration_values, *p_material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F, false);

auto p_constitutive_law = KratosComponents<ConstitutiveLaw>().Get("KirchhoffSaintVenant3DLaw").Clone();
p_constitutive_law->CalculateMaterialResponse(cl_configuration_values, ConstitutiveLaw::StressMeasure::StressMeasure_PK2);
Expand All @@ -528,15 +528,15 @@ KRATOS_TEST_CASE_IN_SUITE(QuadraticSmallStrainIsotropicPlasticity3DVonMisesVonMi
r_model_part.AddNodalSolutionStepVariable(DISPLACEMENT);

ConstitutiveLaw::Parameters cl_configuration_values;
Properties& r_material_properties = r_model_part.GetProperties(1);
Properties::Pointer p_material_properties = r_model_part.CreateNewProperties(1);
Vector stress_vector, strain_vector;
Matrix tangent_moduli, deformation_gradient_F;
double det_deformation_gradient_F;
SettingBasicCase(r_model_part, cl_configuration_values, r_material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F, true, 2);
SettingBasicCase(r_model_part, cl_configuration_values, *p_material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F, true, 2);

// Creating constitutive law
auto p_constitutive_law = KratosComponents<ConstitutiveLaw>().Get("SmallStrainIsotropicPlasticity3DVonMisesVonMises").Clone();
r_material_properties.SetValue(CONSTITUTIVE_LAW, p_constitutive_law);
p_material_properties->SetValue(CONSTITUTIVE_LAW, p_constitutive_law);

// Creating geometry
Create3DGeometryHexahedra(r_model_part);
Expand Down Expand Up @@ -564,15 +564,15 @@ KRATOS_TEST_CASE_IN_SUITE(QuadraticSmallStrainIsotropicPlasticity3DVonMisesVonMi
r_model_part.AddNodalSolutionStepVariable(DISPLACEMENT);

ConstitutiveLaw::Parameters cl_configuration_values;
Properties& r_material_properties = r_model_part.GetProperties(1);
Properties::Pointer p_material_properties = r_model_part.CreateNewProperties(1);
Vector stress_vector, strain_vector;
Matrix tangent_moduli, deformation_gradient_F;
double det_deformation_gradient_F;
SettingBasicCase(r_model_part, cl_configuration_values, r_material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F, true, 2);
SettingBasicCase(r_model_part, cl_configuration_values, *p_material_properties, stress_vector, strain_vector, tangent_moduli, deformation_gradient_F, det_deformation_gradient_F, true, 2);

// Creating constitutive law
auto p_constitutive_law = KratosComponents<ConstitutiveLaw>().Get("SmallStrainIsotropicPlasticity3DVonMisesVonMises").Clone();
r_material_properties.SetValue(CONSTITUTIVE_LAW, p_constitutive_law);
p_material_properties->SetValue(CONSTITUTIVE_LAW, p_constitutive_law);

// Creating geometry
Create3DGeometryHexahedra(r_model_part);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void CreateTotalLagrangianTestModelPart(std::string const& rElementName, ModelPa
std::vector<ModelPart::IndexType> node_ids(r_elem.GetGeometry().PointsNumber());
for (std::size_t i = 0; i < r_elem.GetGeometry().PointsNumber(); ++i)
node_ids.at(i) = i + 1;
auto p_prop = rModelPart.pGetProperties(1);
auto p_prop = rModelPart.CreateNewProperties(1);
rModelPart.CreateNewElement(rElementName, 1, node_ids, p_prop);
rModelPart.SetBufferSize(2);
for (auto& r_node : rModelPart.Nodes())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
from test_patch_test_shells_stress import TestPatchTestShellsStressRec as TTestPatchTestShellsStressRec
from test_patch_test_shells_orthotropic import TestPatchTestShellsOrthotropic as TTestPatchTestShellsOrthotropic
from test_patch_test_formfinding import TestPatchTestFormfinding as TTestPatchTestFormfinding
from test_patch_test_membrane import TestPatchTestMembrane as TTestPatchTestMembrane
from test_patch_test_membrane import StaticPatchTestMembrane as TStaticPatchTestMembrane
from test_patch_test_membrane import DynamicPatchTestMembrane as TDynamicPatchTestMembrane
# Test loading conditions
from test_loading_conditions_point import TestLoadingConditionsPoint as TTestLoadingConditionsPoint
from test_loading_conditions_line import TestLoadingConditionsLine as TTestLoadingConditionsLine
Expand Down Expand Up @@ -232,7 +233,7 @@ def AssembleTestSuites():
### Adding the self-contained tests
# Constitutive Law tests
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestConstitutiveLaw]))
smallSuite.addTest(TSimpleSmallDeformationPlasticityMCTest('test_execution'))
nightSuite.addTest(TSimpleSmallDeformationPlasticityMCTest('test_execution'))
smallSuite.addTest(TSimpleSmallDeformationPlasticityVMTest('test_execution'))
smallSuite.addTest(TSimpleSmallDeformationPlasticityDPTest('test_execution'))
smallSuite.addTest(TSimpleSmallDeformationPlasticityTTest('test_execution'))
Expand All @@ -256,11 +257,12 @@ def AssembleTestSuites():
nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestPatchTestShellsOrthotropic])) # TODO should be in smallSuite but is too slow
# Membranes
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestPatchTestFormfinding]))
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestPatchTestMembrane]))
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TStaticPatchTestMembrane]))
nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TDynamicPatchTestMembrane]))
# Trusses
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestTruss3D2N]))
# Beams
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestCrBeam3D2N]))
nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestCrBeam3D2N]))
nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestCrBeam2D2N])) # TODO should be in smallSuite but is too slow
# Loading Conditions
smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([TTestLoadingConditionsPoint]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import KratosMultiphysics.StructuralMechanicsApplication as StructuralMechanicsApplication
import KratosMultiphysics.KratosUnittest as KratosUnittest

class TestPatchTestMembrane(KratosUnittest.TestCase):
class BasePatchTestMembrane(KratosUnittest.TestCase):

def _add_variables(self,mp):
mp.AddNodalSolutionStepVariable(KratosMultiphysics.DISPLACEMENT)
Expand Down Expand Up @@ -292,6 +292,35 @@ def _set_up_system_3d4n(self,current_model):

return mp

def __post_process(self, main_model_part):
from gid_output_process import GiDOutputProcess
self.gid_output = GiDOutputProcess(main_model_part,
"gid_output",
KratosMultiphysics.Parameters("""
{
"result_file_configuration" : {
"gidpost_flags": {
"GiDPostMode": "GiD_PostBinary",
"WriteDeformedMeshFlag": "WriteUndeformed",
"WriteConditionsFlag": "WriteConditions",
"MultiFileFlag": "SingleFile"
},
"nodal_results" : ["DISPLACEMENT"],
"gauss_point_results" : []
}
}
""")
)

self.gid_output.ExecuteInitialize()
self.gid_output.ExecuteBeforeSolutionLoop()
self.gid_output.ExecuteInitializeSolutionStep()
self.gid_output.PrintOutput()
self.gid_output.ExecuteFinalizeSolutionStep()
self.gid_output.ExecuteFinalize()


class StaticPatchTestMembrane(BasePatchTestMembrane):

def test_membrane_3d3n_static(self):
displacement_results = [-4.628753e-12 , -0.04937043 , -6.483677e-12]
Expand Down Expand Up @@ -319,6 +348,7 @@ def test_membrane_3d4n_static(self):

#self.__post_process(mp)

class DynamicPatchTestMembrane(BasePatchTestMembrane):

def test_membrane_3d3n_dynamic(self):

Expand Down Expand Up @@ -378,33 +408,5 @@ def test_membrane_3d4n_dynamic(self):

#self.__post_process(mp)


def __post_process(self, main_model_part):
from gid_output_process import GiDOutputProcess
self.gid_output = GiDOutputProcess(main_model_part,
"gid_output",
KratosMultiphysics.Parameters("""
{
"result_file_configuration" : {
"gidpost_flags": {
"GiDPostMode": "GiD_PostBinary",
"WriteDeformedMeshFlag": "WriteUndeformed",
"WriteConditionsFlag": "WriteConditions",
"MultiFileFlag": "SingleFile"
},
"nodal_results" : ["DISPLACEMENT"],
"gauss_point_results" : []
}
}
""")
)

self.gid_output.ExecuteInitialize()
self.gid_output.ExecuteBeforeSolutionLoop()
self.gid_output.ExecuteInitializeSolutionStep()
self.gid_output.PrintOutput()
self.gid_output.ExecuteFinalizeSolutionStep()
self.gid_output.ExecuteFinalize()

if __name__ == '__main__':
KratosUnittest.main()
Loading

0 comments on commit df4a914

Please sign in to comment.