Skip to content

Commit

Permalink
[GeoMechanicsApplication] Add missing fix dof statement (#12468)
Browse files Browse the repository at this point in the history
* Added test to check whether fixed variables, spatially varying are actually kept fixed (test fails without any code changes)
* Actually fix spatially varying variables
* Added a README.md for the test
* Added Dofs for DT_WATER_PRESSURE, since for the prescribed derivatives, we should be able to fix the DT_WATER_PRESSURE on the nodes
  • Loading branch information
rfaasse authored Jun 19, 2024
1 parent 8c9bf25 commit 1fcc8b5
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ class ApplyComponentTableProcess : public Process
rNode.FastGetSolutionStepValue(var) = mInitialValue;
});
} else if (variable_name_1 == "X") {
block_for_each(mrModelPart.Nodes(), [&var, this](auto& node) {
node.FastGetSolutionStepValue(var) = mpTable->GetValue(node.X());
block_for_each(mrModelPart.Nodes(), [&var, this](auto& rNode) {
if (mIsFixed) rNode.Fix(var);
else if (mIsFixedProvided) rNode.Free(var);
rNode.FastGetSolutionStepValue(var) = mpTable->GetValue(rNode.X());
});
} else {
KRATOS_ERROR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def PrepareModelPart(self):
def AddDofs(self):
## Fluid dofs
KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.WATER_PRESSURE, KratosMultiphysics.REACTION_WATER_PRESSURE,self.main_model_part)
KratosMultiphysics.VariableUtils().AddDof(KratosGeo.DT_WATER_PRESSURE, self.main_model_part)

KratosMultiphysics.Logger.PrintInfo("GeoMechanics_Pw_Solver", "DOFs added correctly.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def AddDofs(self):

## Fluid dofs
KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.WATER_PRESSURE, KratosMultiphysics.REACTION_WATER_PRESSURE,self.main_model_part)
KratosMultiphysics.VariableUtils().AddDof(KratosGeo.DT_WATER_PRESSURE, self.main_model_part)

if self.settings["rotation_dofs"].GetBool():
KratosMultiphysics.VariableUtils().AddDof(KratosMultiphysics.ROTATION_X, KratosMultiphysics.REACTION_MOMENT_X,self.main_model_part)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os

import KratosMultiphysics.KratosUnittest as KratosUnittest
import test_helper


class KratosGeoMechanicsFixedSpatialVariationTests(KratosUnittest.TestCase):

def setUp(self):
# Code here will be placed BEFORE every test in this TestCase.
pass

def tearDown(self):
# Code here will be placed AFTER every test in this TestCase.
pass

def test_fixed_spatial_variation(self):
test_name = 'fixed_spatial_variation'
file_path = test_helper.get_file_path(test_name)
test_helper.run_kratos(file_path)
result_file_name = os.path.join(file_path, test_name + '.post.res')
reader = test_helper.GiDOutputFileReader()
actual_data = reader.read_output_from(result_file_name)

top_nodes = [3, 4, 7]
actual_top_nodal_pressures = reader.nodal_values_at_time("WATER_PRESSURE", 1.0, actual_data, top_nodes)
expected_top_pressures = [-5000, 0.0, -2500]
for actual_pressure, expected_pressure in zip(actual_top_nodal_pressures, expected_top_pressures):
self.assertAlmostEqual(actual_pressure, expected_pressure, 3)

bottom_nodes = [1, 2, 5]
actual_bottom_nodal_pressures = reader.nodal_values_at_time("WATER_PRESSURE", 1.0, actual_data, bottom_nodes)
expected_bottom_pressures = [-40000, -30000, -35000]
for actual_pressure, expected_pressure in zip(actual_bottom_nodal_pressures, expected_bottom_pressures):
self.assertAlmostEqual(actual_pressure, expected_pressure, 3)


if __name__ == '__main__':
KratosUnittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"properties": [{
"model_part_name": "PorousDomain.soil",
"properties_id": 1,
"Material": {
"constitutive_law": {
"name" : "GeoLinearElasticPlaneStrain2DLaw"
},
"Variables": {
"IGNORE_UNDRAINED" : false,
"YOUNG_MODULUS" : 10000,
"POISSON_RATIO" : 0.2,
"DENSITY_SOLID" : 2650,
"DENSITY_WATER" : 1000,
"POROSITY" : 0.35,
"BULK_MODULUS_SOLID" : 1.0e9,
"BULK_MODULUS_FLUID" : 2.0e6,
"PERMEABILITY_XX" : 1.157e-12,
"PERMEABILITY_YY" : 1.157e-12,
"PERMEABILITY_XY" : 0.0,
"DYNAMIC_VISCOSITY" : 1e-3,
"BIOT_COEFFICIENT" : 1.0,
"RETENTION_LAW" : "SaturatedLaw",
"SATURATED_SATURATION" : 1.0
},
"Tables": {}
}
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
{
"problem_data": {
"problem_name": "simple_mesh",
"start_time": 0.0,
"end_time": 1.0,
"echo_level": 1,
"parallel_type": "OpenMP",
"number_of_threads": 1
},
"solver_settings": {
"solver_type": "geomechanics_U_Pw_solver",
"model_part_name": "PorousDomain",
"domain_size": 2,
"model_import_settings": {
"input_type": "mdpa",
"input_filename": "simple_mesh"
},
"material_import_settings": {
"materials_filename": "MaterialParameters.json"
},
"time_stepping": {
"time_step": 1.0,
"max_delta_time_factor": 1000
},
"buffer_size": 2,
"echo_level": 1,
"clear_storage": false,
"compute_reactions": false,
"move_mesh_flag": false,
"reform_dofs_at_each_step": false,
"nodal_smoothing": false,
"block_builder": true,
"solution_type": "Quasi-static",
"scheme_type": "Backward_Euler",
"reset_displacements": true,
"newmark_beta": 0.25,
"newmark_gamma": 0.5,
"newmark_theta": 0.5,
"rayleigh_m": 0.0,
"rayleigh_k": 0.0,
"strategy_type": "newton_raphson",
"convergence_criterion": "residual_criterion",
"residual_relative_tolerance": 1.0E-4,
"residual_absolute_tolerance": 1.0E-9,
"min_iterations": 6,
"max_iterations": 15,
"number_cycles": 1,
"reduction_factor": 0.5,
"increase_factor": 2.0,
"desired_iterations": 4,
"max_radius_factor": 10.0,
"min_radius_factor": 0.1,
"calculate_reactions": false,
"first_alpha_value": 0.5,
"second_alpha_value": 1.0,
"min_alpha": 0.1,
"max_alpha": 2.0,
"rotation_dofs": false,
"linear_solver_settings": {
"solver_type": "cg",
"scaling": true
},
"problem_domain_sub_model_part_list": ["soil"],
"processes_sub_model_part_list": ["Body_Acceleration-auto-1","Top","Base", "soil"],
"body_domain_sub_model_part_list": ["soil"]
},
"output_processes": {
"gid_output": [{
"python_module": "gid_output_process",
"kratos_module": "KratosMultiphysics",
"process_name": "GiDOutputProcess",
"Parameters": {
"model_part_name": "PorousDomain.porous_computational_model_part",
"output_name": "fixed_spatial_variation",
"postprocess_parameters": {
"result_file_configuration": {
"gidpost_flags": {
"WriteDeformedMeshFlag": "WriteUndeformed",
"WriteConditionsFlag": "WriteElementsOnly",
"GiDPostMode": "GiD_PostAscii",
"MultiFileFlag": "SingleFile"
},
"file_label": "step",
"output_control_type": "step",
"output_interval": 1,
"body_output": true,
"node_output": true,
"skin_output": false,
"plane_output": [],
"nodal_results": ["WATER_PRESSURE"],
"gauss_point_results": []
},
"point_data_configuration": []
}
}
}]
},
"processes": {
"constraints_process_list": [{
"python_module": "apply_vector_constraint_table_process",
"kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
"process_name": "ApplyVectorConstraintTableProcess",
"Parameters": {
"model_part_name": "PorousDomain.Base",
"variable_name": "DISPLACEMENT",
"active": [true,true,true],
"is_fixed": [true,true,true],
"value": [0.0,0.0,0.0],
"table": [0,0,0]
}
},{
"python_module": "apply_vector_constraint_table_process",
"kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
"process_name": "ApplyVectorConstraintTableProcess",
"Parameters": {
"model_part_name": "PorousDomain.soil",
"variable_name": "DISPLACEMENT",
"active": [true,false,true],
"is_fixed": [true,false,true],
"value": [0.0,0.0,0.0],
"table": [0,0,0]
}
},{
"python_module": "apply_scalar_constraint_table_process",
"kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
"process_name": "ApplyScalarConstraintTableProcess",
"Parameters": {
"model_part_name": "PorousDomain.Top",
"variable_name": "WATER_PRESSURE",
"is_fixed": true,
"fluid_pressure_type": "Uniform",
"value": 0,
"table": 1
}
},{
"python_module": "apply_scalar_constraint_table_process",
"kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
"process_name": "ApplyScalarConstraintTableProcess",
"Parameters": {
"model_part_name": "PorousDomain.Base",
"variable_name": "WATER_PRESSURE",
"is_fixed": true,
"fluid_pressure_type": "Uniform",
"value": 0,
"table": 2
}
}],
"loads_process_list": [{
"python_module": "apply_vector_constraint_table_process",
"kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
"process_name": "ApplyVectorConstraintTableProcess",
"Parameters": {
"model_part_name": "PorousDomain.Body_Acceleration-auto-1",
"variable_name": "VOLUME_ACCELERATION",
"active": [false,true,false],
"value": [0.0,-10,0.0],
"table": [0,0,0]
}
}],
"auxiliar_process_list": []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Prescribed spatially varying fixed water pressure

This test is a water pressure tests of a single UPwSmallStrainElement2D8N element.
It checks whether fixed water pressure conditions stay fixed when using a spatially varying fixed water pressure. In this case, it means we use the `ApplyScalarConstraintTableProcess` with the following tables (x, water_pressure pairs) for the top and bottom sides of the element respectively:
```
Begin Table 1 X WATER_PRESSURE
0.0000000000 0.0000000000
1.0000000000 -5000
End Table
Begin Table 2 X WATER_PRESSURE
0.0000000000 -40000
1.0000000000 -30000
End Table
```

## Setup
- Constraints:
- Displacements on the bottom are fixed in all directions.
- Displacements on the sides are fixed in the X direction.
- Water pressures on the top are varying from 0 to -5000, and on the bottom from -40000 to -30000. These are constant in time.

- Material:
- The material is elastic according to the GeoLinearElasticPlaneStrain2DLaw.

A VOLUME_ACCELERATION is also set, to make sure that if the water pressure is not fixed, the water pressure would get different values.

## Assertions
The assertion is very simple: the water pressure should be constant in time and space for the top and bottom nodes, and equal to the prescribed values.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Begin Table 1 X WATER_PRESSURE
0.0000000000 0.0000000000
1.0000000000 -5000
End Table

Begin Table 2 X WATER_PRESSURE
0.0000000000 -40000
1.0000000000 -30000
End Table

Begin Properties 1
End Properties


Begin Nodes
1 0.0000000000 -2.0000000000 0.0000000000
2 1.0000000000 -2.0000000000 0.0000000000
3 1.0000000000 0.0000000000 0.0000000000
4 0.0000000000 0.0000000000 0.0000000000
5 0.5000000000 -2.0000000000 0.0000000000
6 1.0000000000 -1.0000000000 0.0000000000
7 0.5000000000 0.0000000000 0.0000000000
8 0.0000000000 -1.0000000000 0.0000000000
End Nodes


Begin Elements UPwSmallStrainElement2D8N
1 1 1 2 3 4 5 6 7 8
End Elements



Begin SubModelPart soil
Begin SubModelPartNodes
1
2
3
4
5
6
7
8
End SubModelPartNodes
Begin SubModelPartElements
1
End SubModelPartElements
End SubModelPart

Begin SubModelPart Body_Acceleration-auto-1
Begin SubModelPartNodes
1
2
3
4
5
6
7
8
End SubModelPartNodes
Begin SubModelPartElements
1
End SubModelPartElements
End SubModelPart

Begin SubModelPart Top
Begin SubModelPartTables
1
End SubModelPartTables
Begin SubModelPartNodes
3
4
7
End SubModelPartNodes
End SubModelPart

Begin SubModelPart Base
Begin SubModelPartTables
2
End SubModelPartTables
Begin SubModelPartNodes
1
2
5
End SubModelPartNodes
End SubModelPart



Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from test_pressure_point_flux import KratosGeoMechanicsTransientPressurePointFluxTests
from settlement_workflow import KratosGeoMechanicsSettlementWorkflow
from test_compressibility import KratosGeoMechanicsCompressibilityTests
from fixed_spatial_variation import KratosGeoMechanicsFixedSpatialVariationTests

def AssembleTestSuites():
''' Populates the test suites to run.
Expand Down Expand Up @@ -93,7 +94,8 @@ def AssembleTestSuites():
KratosGeoMechanicsPrescribedDerivatives,
KratosGeoMechanicsDirichletUTests,
KratosGeoMechanicsNormalLoadHexaTests,
KratosGeoMechanicsCompressibilityTests
KratosGeoMechanicsCompressibilityTests,
KratosGeoMechanicsFixedSpatialVariationTests
]

# Create an array with the selected tests
Expand Down

0 comments on commit 1fcc8b5

Please sign in to comment.