From 9a32385a9cc3472fd0c6eaa86673753b4302c3fd Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Fri, 2 Feb 2024 22:49:29 +0100 Subject: [PATCH] add expected output --- .../Expressions/General/Working_with_Numpy.md | 46 +++++++++++++ .../Expressions/IOs/C_Array_Expression_IO.md | 44 +++++++++++++ .../IOs/Domain_Size_Expression_IO.md | 28 ++++++++ .../IOs/Literal_Expression_Input.md | 65 ++++++++++++++++++- .../IOs/Nodal_Position_Expression_IO.md | 41 +++++++++++- .../Expressions/IOs/Variable_Expression_IO.md | 58 +++++++++++++++++ .../pages/Kratos/Expressions/Utilities/Abs.md | 32 +++++++++ .../Kratos/Expressions/Utilities/Collapse.md | 16 ++++- .../Kratos/Expressions/Utilities/Comb.md | 17 ++++- .../Kratos/Expressions/Utilities/EntityMax.md | 17 ++++- .../Kratos/Expressions/Utilities/EntityMin.md | 17 ++++- .../Kratos/Expressions/Utilities/EntitySum.md | 17 ++++- .../Expressions/Utilities/InnerProduct.md | 15 ++++- .../Kratos/Expressions/Utilities/NormInf.md | 14 ++++ .../Kratos/Expressions/Utilities/NormL2.md | 15 ++++- .../Kratos/Expressions/Utilities/NormP.md | 15 ++++- .../pages/Kratos/Expressions/Utilities/Pow.md | 32 +++++++++ .../Kratos/Expressions/Utilities/Reshape.md | 21 ++++++ .../Kratos/Expressions/Utilities/Scale.md | 17 ++++- .../Kratos/Expressions/Utilities/Slice.md | 16 +++++ 20 files changed, 530 insertions(+), 13 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index a727d7ee61ba..0ef77f1d1af0 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -38,6 +38,20 @@ numpy_nodal_expression = nodal_expression.Evaluate() print("Shape of the numpy array = ", numpy_nodal_expression.shape) ``` +Expected output: +```bash +Shape of the numpy array = (2, 3) + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Reading from numpy arrays First create the numpy array independent from Kratos if the number of local entities are known (i.e. number of nodes/conditions/elements in the local mesh). The following numpy data types are supported when reading numpy arrays: 1. ```numpy.int32``` @@ -76,6 +90,21 @@ for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") ``` + +Expected output: +```bash +node id: 1, velocity: [1.0, 2.0, 3.0] +node id: 2, velocity: [3.0, 4.0, 5.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` ## Moving from numpy arrays This is similar to [reading from numpy arrays](#reading-from-numpy-arraystest) with the difference that this does not create a copy for the expression. @@ -124,3 +153,20 @@ for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") ``` + +Expected output: +```bash +node id: 1, velocity: [1.0, 2.0, 3.0] +node id: 2, velocity: [3.0, 4.0, 5.0] +node id: 1, velocity: [1.0, 2.0, 3.0] +node id: 2, velocity: [3.0, 10.0, 5.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md index 281ddc17cb77..ac30ce13277c 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -42,6 +42,21 @@ Kratos.Expression.CArrayExpressionIO.Write(nodal_expression, numpy_array) print("numpy array = ", numpy_array) ``` +Expected output: +```bash +numpy array = [[1. 2. 3.] + [3. 4. 5.]] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Reading and writing to `Kratos::Vector` ```CArrayExpressionIO``` also allows reading and writing from ```Kratos::Vector``` containers. In this case, the size of the ```Kratos::Vector``` should be the flattened size of the shape of interest which the user will be working on. @@ -74,6 +89,21 @@ for node in model_part.Nodes: print(f"node_id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") ``` +Expected output: +```bash +node_id: 1, velocity: [1.0, 2.0, 3.0] +node_id: 2, velocity: [4.0, 5.0, 6.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + Writing to a ```Kratos::Vector``` is illustarted by the following code snippet. If the passed vector (to where the expression values are written) is not with the correct size, it will be resized. This will also only write the data values of the local entities in the LocalMesh. ```python import KratosMultiphysics as Kratos @@ -96,3 +126,17 @@ Kratos.Expression.CArrayExpressionIO.Write(nodal_expression, vector) print(vector) ``` +Expected output: +```bash +[6](1,2,3,3,4,5) + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + diff --git a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md index 5dc9baef068b..c5ca441dd94d 100644 --- a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -39,6 +39,20 @@ shape = element_expression.Evaluate().shape print(shape) ``` +Expected output: +```bash +(1,) + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Using expressions without the model parts The ```ConditionExpression``` and ```ElementExpression``` has an expression which can be directly used if required. The advantage of working with the ```Expression``` directely is, then it is not bound to a model part of a ```DataValueContainer```. Hence, these expressions can be interchanged if required in @@ -62,3 +76,17 @@ exp *= 2.0 print(exp) ``` + +Expected output: +```bash +(DoubleVec[]*2) + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index e24ce5e8caf3..2ff9cd3026f9 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -45,6 +45,21 @@ for node in model_part.Nodes: print(f"node_id: {node.Id}, velocity = [{velocity[0]}, {velocity[1]}, {velocity[2]}]") ``` +Expected output: +```bash +node_id: 1, velocity = [1.0, 2.0, 3.0] +node_id: 2, velocity = [1.0, 2.0, 3.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Setting literal expression to zero The ```LiteralExpressionIO``` also can be used to set entity data to zero for a given variable. **In the case of dynamically sized types, it will create empty instances [Such as Vector with size 0, Matrix with shape (0,0)**. The passed variable is only used to determine the entity shape. Example: @@ -77,6 +92,23 @@ for node in model_part.Nodes: print(f"node_id: {node.Id}, pressure = {node.GetValue(Kratos.PRESSURE)}, temperature = {node.GetValue(Kratos.TEMPERATURE)}") ``` +Expected output: +```bash +PRESSURE before resetting: + [10. 20.] +node_id: 1, pressure = 10.0, temperature = 0.0 +node_id: 2, pressure = 20.0, temperature = 0.0 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Use cases Lets assume you want to get inverse of a scalar expressions such as PRESSURE. In that case you can easily use ```LiteralExpressionIO``` to compute it. @@ -108,10 +140,26 @@ Kratos.Expression.VariableExpressionIO.Write(inverse_expression, Kratos.TEMPERAT # now check for node in model_part.Nodes: - velocity = node.GetValue(Kratos.VELOCITY) print(f"node_id: {node.Id}, pressure = {node.GetValue(Kratos.PRESSURE)}, temperature = {node.GetValue(Kratos.TEMPERATURE)}") ``` +Expected output: +```bash +PRESSURE before resetting: + [10. 20.] +node_id: 1, pressure = 10.0, temperature = 0.1 +node_id: 2, pressure = 20.0, temperature = 0.05 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Using expressions without the model parts The ```NodalExpression```, ```ConditionExpression``` and ```ElementExpression``` has an expression which can be directly used if required. The advantage of working with the ```Expression``` directely is, then it is not bound to a model part of a ```DataValueContainer```. Hence, these expressions can be interchanged if required in @@ -137,3 +185,18 @@ for node in model_part.Nodes: acceleration = node.GetValue(Kratos.ACCELERATION) print(f"node_id: {node.Id}, acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") ``` + +Expected output: +```bash +node_id: 1, acceleration: [2.0,4.0,6.0] +node_id: 2, acceleration: [2.0,4.0,6.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md index 873820a35cf1..2029d1e465ea 100644 --- a/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md @@ -39,7 +39,7 @@ Kratos.Expression.NodalPositionExpressionIO.Read(current_nodal_expression,Kratos print("initial:\n", initial_nodal_expression.Evaluate()) print("current:\n", current_nodal_expression.Evaluate()) -# now do some arithmatics with the exps +# now do some arithmetics with the exps initial_nodal_expression *= 2 current_nodal_expression *= 2 @@ -52,9 +52,30 @@ for node in model_part.Nodes: print(f"node_id: {node.Id}, initial: [{node.X0}, {node.Y0}, {node.Z0}], current: [{node.X}, {node.Y}, {node.Z}]") ``` +Expected output: +```bash +initial: + [[0. 0. 0.] + [0. 1. 0.]] +current: + [[10. 10. 0.] + [ 0. 1. 0.]] +node_id: 1, initial: [0.0, 0.0, 0.0], current: [20.0, 20.0, 0.0] +node_id: 2, initial: [0.0, 2.0, 0.0], current: [0.0, 2.0, 0.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Using expressions without the model parts The ```NodalExpression```, ```ConditionExpression``` and ```ElementExpression``` has an expression which can be directly used if required. The advantage of working -with the ```Expression``` directely is, then it is not bound to a model part of a ```DataValueContainer```. Hence, these expressions can be interchanged if required in +with the ```Expression``` directly is, then it is not bound to a model part of a ```DataValueContainer```. Hence, these expressions can be interchanged if required in advanced use cases. Following code snippet shows how to use bare ```Expressions```. ```python import KratosMultiphysics as Kratos @@ -75,4 +96,18 @@ Kratos.Expression.NodalPositionExpressionIO.Output(model_part, Kratos.Configurat # now read nodal positions for node in model_part.Nodes: print(f"node_id: {node.Id}, initial: [{node.X0}, {node.Y0}, {node.Z0}], current: [{node.X}, {node.Y}, {node.Z}]") -``` \ No newline at end of file +``` +Expected output: +```bash +node_id: 1, initial: [0.0, 0.0, 0.0], current: [0.0, 0.0, 0.0] +node_id: 2, initial: [0.0, 1.0, 0.0], current: [0.0, 2.0, 0.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index 3f054c551c8a..e94a6f9d5cdd 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -57,6 +57,21 @@ for node in model_part.Nodes: print(f"node_id: {node.Id}, velocity: [{velocity[0]},{velocity[1]},{velocity[2]}], acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") ``` +Expected output: +```bash +node_id: 1, velocity: [1.0,2.0,3.0], acceleration: [2.0,4.0,6.0] +node_id: 2, velocity: [3.0,4.0,5.0], acceleration: [6.0,8.0,10.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Reading/Writing condition values ```python import KratosMultiphysics as Kratos @@ -88,6 +103,20 @@ for condition in model_part.Conditions: print(f"condition_id: {condition.Id}, velocity: [{velocity[0]},{velocity[1]},{velocity[2]}], acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") ``` +Expected output: +```bash +condition_id: 1, velocity: [1.0,2.0,3.0], acceleration: [2.0,4.0,6.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Reading/Writing element values ```python import KratosMultiphysics as Kratos @@ -120,6 +149,20 @@ for element in model_part.Elements: print(f"element_id: {element.Id}, velocity: [{velocity[0]},{velocity[1]},{velocity[2]}], acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") ``` +Expected output: +```bash +element_id: 1, velocity: [1.0,2.0,3.0], acceleration: [2.0,4.0,6.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ## Using expressions without the model parts The ```NodalExpression```, ```ConditionExpression``` and ```ElementExpression``` has an expression which can be directly used if required. The advantage of working with the ```Expression``` directely is, then it is not bound to a model part of a ```DataValueContainer```. Hence, these expressions can be interchanged if required in @@ -148,3 +191,18 @@ for node in model_part.Nodes: acceleration = node.GetValue(Kratos.ACCELERATION) print(f"node_id: {node.Id}, velocity: [{velocity[0]},{velocity[1]},{velocity[2]}], acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") ``` + +Expected output: +```bash +node_id: 1, velocity: [1.0,2.0,3.0], acceleration: [2.0,4.0,6.0] +node_id: 2, velocity: [3.0,4.0,5.0], acceleration: [6.0,8.0,10.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/Abs.md b/docs/pages/Kratos/Expressions/Utilities/Abs.md index 8a30d2fef70c..9797335d27ba 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Abs.md +++ b/docs/pages/Kratos/Expressions/Utilities/Abs.md @@ -49,6 +49,22 @@ for node in model_part.Nodes: print(f"node_id: {node.Id}, velocity=[{velocity[0]}, {velocity[1]}, {velocity[2]}], acceleration = [{acceleration[0]}, {acceleration[1]}, {acceleration[2]}]") ``` +Expected output: +```bash +node_id: 1, velocity=[-1.0, -2.0, -3.0], acceleration = [1.0, 2.0, 3.0] +node_id: 2, velocity=[-4.0, -5.0, -6.0], acceleration = [4.0, 5.0, 6.0] +node_id: 3, velocity=[-7.0, -8.0, -9.0], acceleration = [7.0, 8.0, 9.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ### Using to compute entity wise inf-norm Following code snippet illustrates how to use ```Abs``` to compute the entity wise inf-norm. ```python @@ -82,3 +98,19 @@ for node in model_part.Nodes: pressure = node.GetValue(Kratos.PRESSURE) print(f"node_id: {node.Id}, velocity=[{velocity[0]}, {velocity[1]}, {velocity[2]}], pressure = {pressure}") ``` + +Expected output: +```bash +node_id: 1, velocity=[-1.0, -2.0, -3.0], pressure = 3.0 +node_id: 2, velocity=[-4.0, -5.0, -6.0], pressure = 6.0 +node_id: 3, velocity=[-7.0, -8.0, -9.0], pressure = 9.0 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/Collapse.md b/docs/pages/Kratos/Expressions/Utilities/Collapse.md index a02a61aff0ec..afd53237a202 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Collapse.md +++ b/docs/pages/Kratos/Expressions/Utilities/Collapse.md @@ -41,4 +41,18 @@ print(nodal_expression.GetMaxDepth()) collapsed_exp = Kratos.Expression.Utils.Collapse(nodal_expression) print(collapsed_exp.GetMaxDepth()) -``` \ No newline at end of file +``` +Expected output: +```bash +3 +1 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/Comb.md b/docs/pages/Kratos/Expressions/Utilities/Comb.md index 84f89685c664..2a8def76f439 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Comb.md +++ b/docs/pages/Kratos/Expressions/Utilities/Comb.md @@ -54,4 +54,19 @@ Kratos.Expression.VariableExpressionIO.Read(p_exp, Kratos.PRESSURE, False) combined_exp = Kratos.Expression.Utils.Comb([p_exp, u_exp]) print(combined_exp.Evaluate()) -``` \ No newline at end of file +``` +Expected output: +```bash +[[ 1. 4. 5. -1.] + [ 2. 6. 7. -1.] + [ 3. 8. 9. -1.]] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md index a362d0fc728b..4536c76b5347 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md @@ -44,4 +44,19 @@ for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) pressure = node.GetValue(Kratos.PRESSURE) print(f"node_id: {node.Id}, velocity=[{velocity[0]}, {velocity[1]}, {velocity[2]}], pressure = {pressure}") -``` \ No newline at end of file +``` +Expected output: +```bash +node_id: 1, velocity=[-1.0, -2.0, -3.0], pressure = -1.0 +node_id: 2, velocity=[-4.0, -5.0, -6.0], pressure = -4.0 +node_id: 3, velocity=[-7.0, -8.0, -9.0], pressure = -7.0 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md index cdb4c6a02190..11319a07cabc 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md @@ -43,4 +43,19 @@ for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) pressure = node.GetValue(Kratos.PRESSURE) print(f"node_id: {node.Id}, velocity=[{velocity[0]}, {velocity[1]}, {velocity[2]}], pressure = {pressure}") -``` \ No newline at end of file +``` +Expected output: +```bash +node_id: 1, velocity=[-1.0, -2.0, -3.0], pressure = -3.0 +node_id: 2, velocity=[-4.0, -5.0, -6.0], pressure = -6.0 +node_id: 3, velocity=[-7.0, -8.0, -9.0], pressure = -9.0 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md index de7142b34aa5..1c73ad4f4cf5 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md @@ -43,4 +43,19 @@ for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) pressure = node.GetValue(Kratos.PRESSURE) print(f"node_id: {node.Id}, velocity=[{velocity[0]}, {velocity[1]}, {velocity[2]}], pressure = {pressure}") -``` \ No newline at end of file +``` +Expected output: +```bash +node_id: 1, velocity=[-1.0, -2.0, -3.0], pressure = -6.0 +node_id: 2, velocity=[-4.0, -5.0, -6.0], pressure = -15.0 +node_id: 3, velocity=[-7.0, -8.0, -9.0], pressure = -24.0 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md index 120b791334f8..0b44ee410dcb 100644 --- a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md +++ b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md @@ -36,4 +36,17 @@ nodal_expression = Kratos.Expression.NodalExpression(model_part) Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) print(Kratos.Expression.Utils.InnerProduct(nodal_expression, nodal_expression)) -``` \ No newline at end of file +``` +Expected output: +```bash +285.0 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/NormInf.md b/docs/pages/Kratos/Expressions/Utilities/NormInf.md index dcbf7a889cbf..91859d7e4adc 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormInf.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormInf.md @@ -34,3 +34,17 @@ Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, F print(Kratos.Expression.Utils.NormInf(nodal_expression)) ``` + +Expected output: +```bash +9.0 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/NormL2.md b/docs/pages/Kratos/Expressions/Utilities/NormL2.md index 0c639be21c7b..66cd91ce32ba 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormL2.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormL2.md @@ -33,4 +33,17 @@ nodal_expression = Kratos.Expression.NodalExpression(model_part) Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) print(Kratos.Expression.Utils.NormL2(nodal_expression)) -``` \ No newline at end of file +``` +Expected output: +```bash +16.881943016134134 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/NormP.md b/docs/pages/Kratos/Expressions/Utilities/NormP.md index 64990b475e87..de2ecc0daab9 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormP.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormP.md @@ -33,4 +33,17 @@ nodal_expression = Kratos.Expression.NodalExpression(model_part) Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) print(Kratos.Expression.Utils.NormP(nodal_expression, 3)) -``` \ No newline at end of file +``` +Expected output: +```bash +12.651489979526238 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/Pow.md b/docs/pages/Kratos/Expressions/Utilities/Pow.md index 9c83c474a208..4f87d7890f94 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Pow.md +++ b/docs/pages/Kratos/Expressions/Utilities/Pow.md @@ -64,6 +64,22 @@ for node in model_part.Nodes: print(f"node_id: {node.Id}, velocity=[{velocity[0]}, {velocity[1]}, {velocity[2]}], acceleration = [{acceleration[0]}, {acceleration[1]}, {acceleration[2]}]") ``` +Expected output: +```bash +node_id: 1, velocity=[-1.0, -2.0, -3.0], acceleration = [-1.0, -8.0, -27.0] +node_id: 2, velocity=[-4.0, -5.0, -6.0], acceleration = [-64.0, -125.0, -216.0] +node_id: 3, velocity=[-7.0, -8.0, -9.0], acceleration = [-343.0, -512.0, -729.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` + ### Using to compute entity wise L2 norm Following code snippet illustrates how to use ```Pow``` to compute the entity wise L2 norm. ```python @@ -97,3 +113,19 @@ for node in model_part.Nodes: pressure = node.GetValue(Kratos.PRESSURE) print(f"node_id: {node.Id}, velocity=[{velocity[0]}, {velocity[1]}, {velocity[2]}], pressure = {pressure}") ``` + +Expected output: +```bash +node_id: 1, velocity=[-1.0, -2.0, -3.0], pressure = 3.7416573867739413 +node_id: 2, velocity=[-4.0, -5.0, -6.0], pressure = 8.774964387392123 +node_id: 3, velocity=[-7.0, -8.0, -9.0], pressure = 13.92838827718412 + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/Reshape.md b/docs/pages/Kratos/Expressions/Utilities/Reshape.md index ef4e0a4cec00..e75573832609 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Reshape.md +++ b/docs/pages/Kratos/Expressions/Utilities/Reshape.md @@ -44,3 +44,24 @@ reshaped_exp = Kratos.Expression.Utils.Reshape(combined_exp, [2, 2]) print(reshaped_exp.Evaluate()) ``` + +Expected output: +```bash +[[[ 1. 4.] + [ 5. -1.]] + + [[ 2. 6.] + [ 7. -1.]] + + [[ 3. 8.] + [ 9. -1.]]] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/Scale.md b/docs/pages/Kratos/Expressions/Utilities/Scale.md index 273b94fec174..e37f79267be1 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Scale.md +++ b/docs/pages/Kratos/Expressions/Utilities/Scale.md @@ -60,4 +60,19 @@ for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) acceleration = node.GetValue(Kratos.ACCELERATION) print(f"node_id: {node.Id}, velocity=[{velocity[0]}, {velocity[1]}, {velocity[2]}], acceleration = [{acceleration[0]}, {acceleration[1]}, {acceleration[2]}]") -``` \ No newline at end of file +``` +Expected output: +```bash +node_id: 1, velocity=[-1.0, -2.0, -3.0], acceleration = [-3.0, -6.0, -9.0] +node_id: 2, velocity=[-4.0, -5.0, -6.0], acceleration = [-12.0, -15.0, -18.0] +node_id: 3, velocity=[-7.0, -8.0, -9.0], acceleration = [-21.0, -24.0, -27.0] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/Slice.md b/docs/pages/Kratos/Expressions/Utilities/Slice.md index 1d481d2c14ba..9182342f4421 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Slice.md +++ b/docs/pages/Kratos/Expressions/Utilities/Slice.md @@ -50,3 +50,19 @@ sliced_exp = Kratos.Expression.Utils.Slice(nodal_expression, 1, 2) print(sliced_exp.Evaluate()) ``` + +Expected output: +```bash +[[2. 3.] + [5. 6.] + [8. 9.]] + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Compiled for GNU/Linux and Python3.11 with GCC-13.2 +Compiled with threading and MPI support. +Maximum number of threads: 30. +Running without MPI. +```