From 8ea46bc348193776df7eb2d91897fe3c8345790d Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Wed, 24 Jan 2024 10:57:17 +0100 Subject: [PATCH 01/99] add build script nav menu custom build --- docs/scripts/build_site.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/scripts/build_site.sh b/docs/scripts/build_site.sh index 80bde8859032..db8ca43b97ee 100644 --- a/docs/scripts/build_site.sh +++ b/docs/scripts/build_site.sh @@ -15,13 +15,16 @@ fi cp -r ../pages ../_site/Page_files cp ../_config.yml ../_site/Page_files -if [ ! -d "../_site/Page_files/_data" ]; then +if [ ! -d "../_site/Page_files/_data" ] || [ "$1" == "build_menus" ]; then cd .. python3 process_pages.py -t local cd scripts fi if [ -d "../_data" ]; then + if [ -d ../_site/Page_files/_data ]; then + rm -r ../_site/Page_files/_data + fi mv ../_data ../_site/Page_files/_data fi From 2408cad7201b82ae55b6ef8e1dff57ee13e7077b Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Wed, 24 Jan 2024 10:57:34 +0100 Subject: [PATCH 02/99] add expression util method docs --- docs/pages/Kratos/Expressions/Utilities/Abs.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/Collapse.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/Comb.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/EntityMax.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/EntityMin.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/EntitySum.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/InnerProduct.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/NormInf.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/NormL2.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/NormP.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/Pow.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/Reshape.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/Scale.md | 7 +++++++ docs/pages/Kratos/Expressions/Utilities/Slice.md | 7 +++++++ 14 files changed, 98 insertions(+) create mode 100644 docs/pages/Kratos/Expressions/Utilities/Abs.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/Collapse.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/Comb.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/EntityMax.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/EntityMin.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/EntitySum.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/InnerProduct.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/NormInf.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/NormL2.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/NormP.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/Pow.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/Reshape.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/Scale.md create mode 100644 docs/pages/Kratos/Expressions/Utilities/Slice.md diff --git a/docs/pages/Kratos/Expressions/Utilities/Abs.md b/docs/pages/Kratos/Expressions/Utilities/Abs.md new file mode 100644 index 000000000000..4c80e023ab37 --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/Abs.md @@ -0,0 +1,7 @@ +--- +title: Abs +keywords: +tags: [Abs.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/Collapse.md b/docs/pages/Kratos/Expressions/Utilities/Collapse.md new file mode 100644 index 000000000000..5713395258f3 --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/Collapse.md @@ -0,0 +1,7 @@ +--- +title: Collapse +keywords: +tags: [Collapse.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/Comb.md b/docs/pages/Kratos/Expressions/Utilities/Comb.md new file mode 100644 index 000000000000..5a5e85aedcfd --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/Comb.md @@ -0,0 +1,7 @@ +--- +title: Comb +keywords: +tags: [Comb.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md new file mode 100644 index 000000000000..50cbcae50c34 --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md @@ -0,0 +1,7 @@ +--- +title: EntityMax +keywords: +tags: [EntityMax.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md new file mode 100644 index 000000000000..d7d6a81ee10f --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md @@ -0,0 +1,7 @@ +--- +title: EntityMin +keywords: +tags: [EntityMin.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md new file mode 100644 index 000000000000..59c9f24eb350 --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md @@ -0,0 +1,7 @@ +--- +title: EntitySum +keywords: +tags: [EntitySum.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md new file mode 100644 index 000000000000..ca21f2eafed4 --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md @@ -0,0 +1,7 @@ +--- +title: InnerProduct +keywords: +tags: [InnerProduct.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/NormInf.md b/docs/pages/Kratos/Expressions/Utilities/NormInf.md new file mode 100644 index 000000000000..ec51f0867728 --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/NormInf.md @@ -0,0 +1,7 @@ +--- +title: NormInf +keywords: +tags: [NormInf.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/NormL2.md b/docs/pages/Kratos/Expressions/Utilities/NormL2.md new file mode 100644 index 000000000000..5d2d3015d266 --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/NormL2.md @@ -0,0 +1,7 @@ +--- +title: NormL2 +keywords: +tags: [NormL2.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/NormP.md b/docs/pages/Kratos/Expressions/Utilities/NormP.md new file mode 100644 index 000000000000..3410acd23b3a --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/NormP.md @@ -0,0 +1,7 @@ +--- +title: NormP +keywords: +tags: [NormP.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/Pow.md b/docs/pages/Kratos/Expressions/Utilities/Pow.md new file mode 100644 index 000000000000..712745d9407a --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/Pow.md @@ -0,0 +1,7 @@ +--- +title: Pow +keywords: +tags: [Pow.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/Reshape.md b/docs/pages/Kratos/Expressions/Utilities/Reshape.md new file mode 100644 index 000000000000..39dcd1b37031 --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/Reshape.md @@ -0,0 +1,7 @@ +--- +title: Reshape +keywords: +tags: [Reshape.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/Scale.md b/docs/pages/Kratos/Expressions/Utilities/Scale.md new file mode 100644 index 000000000000..26439caa4bde --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/Scale.md @@ -0,0 +1,7 @@ +--- +title: Scale +keywords: +tags: [Scale.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/Utilities/Slice.md b/docs/pages/Kratos/Expressions/Utilities/Slice.md new file mode 100644 index 000000000000..c62e9c674b46 --- /dev/null +++ b/docs/pages/Kratos/Expressions/Utilities/Slice.md @@ -0,0 +1,7 @@ +--- +title: Slice +keywords: +tags: [Slice.md] +sidebar: kratos_expressions +summary: +--- From fd1d09fec8dcf20a629d0651d376ec19aaab3021 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Wed, 24 Jan 2024 10:57:42 +0100 Subject: [PATCH 03/99] add io docs --- .../Expressions/IOs/C_Array_Expression_IO.md | 94 +++++++++++++ .../IOs/Domain_Size_Expression_IO.md | 7 + .../IOs/Integration_Point_Expression_IO.md | 7 + .../IOs/Literal_Expression_Input.md | 7 + .../IOs/Nodal_Position_Expression_IO.md | 7 + .../Expressions/IOs/Variable_Expression_IO.md | 124 ++++++++++++++++++ 6 files changed, 246 insertions(+) create mode 100644 docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md create mode 100644 docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md create mode 100644 docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md create mode 100644 docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md create mode 100644 docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md create mode 100644 docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md diff --git a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md new file mode 100644 index 000000000000..17bf6d44430f --- /dev/null +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -0,0 +1,94 @@ +--- +title: C Array Expression IO +keywords: +tags: [c array expression io, numpy, scipy, Vector] +sidebar: kratos_expressions +summary: +--- + +## Introduction + +```CArrayExpressionIO``` is used to exchange data between `C` type arrays and expressions. This allows reading from `C` arrays as well as writing to `C` arrays. In the python later, it can be used to exchange data between numpy arrays, ```Kratos::Vectors``` as well. + +## Reading and moving from numpy array + +Please refer to [Working with numpy](../General/Working_with_Numpy.html) section. + +## Writing to numpy array +Writing an expression to a numpy array is super simple. In the case of **shared memory** parallelized runs, this will only write only the data from the +```LocalMesh``` to the numpy array. The size of the numpy array should be compatible with the expression shape. Following code snippet shows an example: +```python +import numpy +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([3,4,5])) + +# now create the expression: +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# now read the VELOCITY from the non-historical container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +# now get the numpy array from the expression +numpy_array = numpy.zeros((2,3), dtype=numpy.float64) +Kratos.Expression.CArrayExpressionIO.Write(nodal_expression, numpy_array) + +# first dimension of the numpy array always represents number of entities in the expression (local mesh entities only) +# rest of the dimensions represent the dimensions of the entity data. In this case, VELOCITY have only three components, +# it shows 3 as the last dimension. +print("numpy array = ", numpy_array) +``` + +## Reading and writing to Kratos::Vector +```CArrayExpressionIO``` also allows reading and writing from ```Kratos::Vector``` data 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. + +The arguments for reading from a ```Kratos::Vector``` are, first the expression should be passed, secondly the ```Kratos::Vector``` should be passed. Finally the shape of the entity data should be passed. Following code snippet illustrates the usage. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +vector = Kratos.Vector([1,2,3,4,5,6]) + +# now create the expression: +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# now read in the Kratos::Vector +Kratos.Expression.CArrayExpressionIO.Read(nodal_expression, vector, [3]) + +# now write the VELOCITY to the non-historical container +Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.VELOCITY, False) + +for node in model_part.Nodes: + velocity = node.GetValue(Kratos.VELOCITY) + print(f"node_id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") +``` + +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 +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([3,4,5])) + +# now create the expression: +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# now read the VELOCITY from the non-historical container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +# now write the VELOCITY to the non-historical container +vector = Kratos.Vector() +Kratos.Expression.CArrayExpressionIO.Write(nodal_expression, vector) +print(vector) +``` + diff --git a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md new file mode 100644 index 000000000000..896189a36906 --- /dev/null +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -0,0 +1,7 @@ +--- +title: Domain Size Expression IO +keywords: +tags: [Domain_Size_Expression_IO.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md new file mode 100644 index 000000000000..2e68d062ed15 --- /dev/null +++ b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md @@ -0,0 +1,7 @@ +--- +title: Integration Point Expression IO +keywords: +tags: [Integration_Point_Expression_IO.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md new file mode 100644 index 000000000000..1c2d485a1c21 --- /dev/null +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -0,0 +1,7 @@ +--- +title: Literal Expression Input +keywords: +tags: [Literal_Expression_Input.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md new file mode 100644 index 000000000000..3e6168cf9e7e --- /dev/null +++ b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md @@ -0,0 +1,7 @@ +--- +title: Nodal Position Expression IO +keywords: +tags: [Nodal_Position_Expression_IO.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md new file mode 100644 index 000000000000..17430039ac75 --- /dev/null +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -0,0 +1,124 @@ +--- +title: Variable Expression IO +keywords: +tags: [variable expression io, expressions] +sidebar: kratos_expressions +summary: +--- + +## Introduction + +```VariableExpressionIO``` is used to read ```Kratos::Variable``` data in a data value container to a expression or write an expression data in to a ```Kratos::Variable``` in a specified data value container. The expression will only read or write to the entities (i.e. nodes/conditions/elements) in the local mesh. In the case of writing expression data to a variable in data value container, if it is used in ***distributed memory** parallelized environment, proper synchronization will be automatically done. Hence, all of these operations are compatible with **shared memory** and **distributed memory** parallelizations. + +### Variable types + +Following variable types are allowed to be read in or write to from an expression. +* ```Kratos::Variable``` +* ```Kratos::Variable``` +* ```Kratos::Variable>``` +* ```Kratos::Variable>``` +* ```Kratos::Variable>``` +* ```Kratos::Variable>``` +* ```Kratos::Variable``` +* ```Kratos::Variable``` + +### Shape of the resulting expression +In the case of static data types given by static data type variables (such as ```Kratos::Variable```, ```Kratos::Variable>```), the shape of the expression will be always have number of local entities in the first dimension, rest will be followed by the static size of the data type. If the variable type being used is of dynamic data type (such as ```Kratos::Variable```, ```Kratos::Variable```), then it will represent still the number of local entities in the first dimension. Rest of the dimensions will represent the dimenions of the first data value found in the respective container. [In the case of **distributed memory** parallelized runs, first data value shape synchronization is done to identify the shape of the expression]. + + +## Reading/Writing nodal values +Reading and writing to nodal values have the same interface within ```VariableExpressionIO```. The first argument shall be a `NodalExpression`, the second argumen shall be a ```Kratos::Variable``` and the last argument shall be a boolean indicating true if it is required to read from historical nodal data value container or false if it is required read from non-historical nodal data value container. In the case of **distributed memory** parallelized runs, a proper synchronization between ghost nodes are done when writing is executed. + +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +model_part.AddNodalSolutionStepVariable(Kratos.ACCELERATION) +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([3,4,5])) + +# now create the expression: +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# now read the VELOCITY from the non-historical container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +# do some arithmetic operations +nodal_expression *= 2.0 + +# now write the expression value to model part as ACCELERATION in the historical container +Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.ACCELERATION, True) + +# now print and see +for node in model_part.Nodes: + velocity = node.GetValue(Kratos.VELOCITY) + acceleration = node.GetSolutionStepValue(Kratos.ACCELERATION) + print(f"node_id: {node.Id}, velocity: [{velocity[0]},{velocity[1]},{velocity[2]}], acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") +``` + +## Reading/Writing condition values +Reading and writing to condition values have the same interface within ```VariableExpressionIO```. The first argument shall be a `ConditionExpression` and the second argumen shall be a ```Kratos::Variable```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +prop = model_part.CreateNewProperties(1) +cond1 = model_part.CreateNewCondition("LineCondition2D2N", 1, [1, 2], prop) +cond1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) + +# now create the expression: +condition_expression = Kratos.Expression.ConditionExpression(model_part) + +# now read the VELOCITY from the non-historical container +Kratos.Expression.VariableExpressionIO.Read(condition_expression, Kratos.VELOCITY) + +# do some arithmetic operations +condition_expression *= 2.0 + +# now write the expression value to model part as ACCELERATION in the historical container +Kratos.Expression.VariableExpressionIO.Write(condition_expression, Kratos.ACCELERATION) + +# now print and see +for condition in model_part.Conditions: + velocity = condition.GetValue(Kratos.VELOCITY) + acceleration = condition.GetValue(Kratos.ACCELERATION) + print(f"condition_id: {condition.Id}, velocity: [{velocity[0]},{velocity[1]},{velocity[2]}], acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") +``` + +## Reading/Writing element values +Reading and writing to element values have the same interface within ```VariableExpressionIO```. The first argument shall be a `ElementExpression` and the second argumen shall be a ```Kratos::Variable```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +model_part.CreateNewNode(3, 1.0, 1.0, 0.0) + +prop = model_part.CreateNewProperties(1) +cond1 = model_part.CreateNewElement("Element2D3N", 1, [1, 2, 3], prop) +cond1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) + +# now create the expression: +element_expression = Kratos.Expression.ElementExpression(model_part) + +# now read the VELOCITY from the non-historical container +Kratos.Expression.VariableExpressionIO.Read(element_expression, Kratos.VELOCITY) + +# do some arithmetic operations +element_expression *= 2.0 + +# now write the expression value to model part as ACCELERATION in the historical container +Kratos.Expression.VariableExpressionIO.Write(element_expression, Kratos.ACCELERATION) + +# now print and see +for element in model_part.Elements: + velocity = element.GetValue(Kratos.VELOCITY) + acceleration = element.GetValue(Kratos.ACCELERATION) + print(f"element_id: {element.Id}, velocity: [{velocity[0]},{velocity[1]},{velocity[2]}], acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") +``` \ No newline at end of file From 47e407213ed28876baf2e120a692272b2b62f176 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Wed, 24 Jan 2024 10:57:53 +0100 Subject: [PATCH 04/99] ad general docs --- .../General/Expression_Arithmetics.md | 7 + .../General/Expression_Interface.md | 9 ++ .../Expressions/General/Expression_Types.md | 79 +++++++++++ .../pages/Kratos/Expressions/General/Notes.md | 7 + .../Kratos/Expressions/General/Overview.md | 50 +++++++ .../Expressions/General/Working_with_Numpy.md | 130 ++++++++++++++++++ 6 files changed, 282 insertions(+) create mode 100644 docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md create mode 100644 docs/pages/Kratos/Expressions/General/Expression_Interface.md create mode 100644 docs/pages/Kratos/Expressions/General/Expression_Types.md create mode 100644 docs/pages/Kratos/Expressions/General/Notes.md create mode 100644 docs/pages/Kratos/Expressions/General/Overview.md create mode 100644 docs/pages/Kratos/Expressions/General/Working_with_Numpy.md diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md new file mode 100644 index 000000000000..e93672bf3e77 --- /dev/null +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -0,0 +1,7 @@ +--- +title: Expression Arithmetics +keywords: +tags: [Expression_Arithmetics.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/General/Expression_Interface.md b/docs/pages/Kratos/Expressions/General/Expression_Interface.md new file mode 100644 index 000000000000..aa32449f875d --- /dev/null +++ b/docs/pages/Kratos/Expressions/General/Expression_Interface.md @@ -0,0 +1,9 @@ +--- +title: Expression Interface +keywords: +tags: [Expression_Interface.md] +sidebar: kratos_expressions +summary: +--- + +## Introduction diff --git a/docs/pages/Kratos/Expressions/General/Expression_Types.md b/docs/pages/Kratos/Expressions/General/Expression_Types.md new file mode 100644 index 000000000000..8adf4661c94f --- /dev/null +++ b/docs/pages/Kratos/Expressions/General/Expression_Types.md @@ -0,0 +1,79 @@ +--- +title: Expression Types +keywords: +tags: [Expression_Types.md] +sidebar: kratos_expressions +summary: +--- + +## Introduction + +There are three types of expressions. +* NodalExpression +* ConditionExpression +* ElementExpression + +## Nodal Expression + +Nodal expressions are used to store data related to nodal quantities. They may be historical or non-historical. Following code snippet illustrtes creating a nodal expression +and reading ```VELOCITY``` from nodal non-historical data value container. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([3,4,5])) + +# now create the expression: +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# now read the VELOCITY from the non-historical container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) +``` + +## Condition Expression + +Condition expressions are used to store data related to condition quantities. Following code snippet illustrtes creating a condition expression +and reading ```VELOCITY``` from condition data value container. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +prop = model_part.CreateNewProperties(1) +cond_1 = model_part.CreateNewCondition("LineCondition2D2N", 1, [1, 2], prop) +cond_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) + +# now create the expression: +condition_expression = Kratos.Expression.ConditionExpression(model_part) + +# now read the VELOCITY from the condition data value container +Kratos.Expression.VariableExpressionIO.Read(condition_expression, Kratos.VELOCITY) +``` + +## Element Expression + +Element expressions are used to store data related to element quantities. Following code snippet illustrtes creating a element expression +and reading ```VELOCITY``` from element data value container. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +node_3 = model_part.CreateNewNode(3, 0.0, 1.0, 0.0) + +prop = model_part.CreateNewProperties(1) +elem_1 = model_part.CreateNewElement("Element2D3N", 1, [1, 2, 3], prop) +elem_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) + +# now create the expression: +element_expression = Kratos.Expression.ElementExpression(model_part) + +# now read the VELOCITY from the condition data value container +Kratos.Expression.VariableExpressionIO.Read(element_expression, Kratos.VELOCITY) +``` diff --git a/docs/pages/Kratos/Expressions/General/Notes.md b/docs/pages/Kratos/Expressions/General/Notes.md new file mode 100644 index 000000000000..f5d296774213 --- /dev/null +++ b/docs/pages/Kratos/Expressions/General/Notes.md @@ -0,0 +1,7 @@ +--- +title: Notes +keywords: +tags: [Notes.md] +sidebar: kratos_expressions +summary: +--- diff --git a/docs/pages/Kratos/Expressions/General/Overview.md b/docs/pages/Kratos/Expressions/General/Overview.md new file mode 100644 index 000000000000..404990689f6e --- /dev/null +++ b/docs/pages/Kratos/Expressions/General/Overview.md @@ -0,0 +1,50 @@ +--- +title: Overview +keywords: +tags: [overview.md] +sidebar: kratos_expressions +summary: +--- +## Introduction + +An expression represents a mechanism where a given mathematical expression is evaluated when actual value of that expression in required. One can relate these +expressions to lazy expressions (expression templates) in [Eigen](https://eigen.tuxfamily.org/dox/TopicLazyEvaluation.html) or in [Boost](https://www.boost.org/doc/libs/1_82_0/doc/html/boost_yap/manual.html). The main difference being, Kratos expressions are lazy expressions which is evaluated at runtime, whereas Eigen anb Boost has lazy expressions which are evaluated at compile-time. Few of the main advantages of these lazy expressions are: +* May reduce memory foot. +* May reduce computational cost. + +Kratos - Multiphysics has various types of data containers to store data. All of those data containers requires a ```Kratos::Variable``` to access its underlying data. This requires defining the variable before hand, and then using it to store and retrieve data. The expressions allows the user and/or developer to use these data containers with minimal to no variable to store/retrieve data from data containers. All the expressions are enabled with **shared memory** and **distributed memory** parallelisms. All of these expressions are implemented in C++, while being exposed to python. + +## Supported data containers + +Following data containers are supported: +* NodalExpression - Nodal data value container (Historical / Non historical). +* ConditionExpression - Condition data value container. +* ElementExpression - Element data value container. + +## Supported data types + +The expressions support almost all the variable types in Kratos, and many more data types as well. The data storage in the expressions can be assumed as a flat ```int``` or ```double``` array. Followings are few supported data types: + +* ```int``` +* ```double``` +* ```array_1d``` +* ```array_1d``` +* ```array_1d``` +* ```array_1d``` +* ```Vector``` +* ```Matrix``` + +## Use cases + +Expressions are usefull in following scenarios: +1. Transferring data back and forth from/to Kratos with another libraries - Library may be developed in another language like Fortran as well. +2. Transferring data back and forth from/to Kratos with numpy/scipy. +3. Transferring data back and forth from/to Kratos with HDF5. +4. If it is required to compute some intermediary value at python level, where a variable usage is not required such as in computing intermediate values with efficiency. +5. Transerring data back and forth within Kratos without variables such as in OptimizationApplication. +6. Prototyping your research code with ease in python level while utilizing **shared memory** and **distributed memory** paralellism. + + + + + diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md new file mode 100644 index 000000000000..dfa929c57489 --- /dev/null +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -0,0 +1,130 @@ +--- +title: Working with Numpy +keywords: +tags: [numpy, scipy, expressions, variable expression io, carray expression io] +sidebar: kratos_expressions +summary: +--- + +## Introduction + +Expressions make working with nump/scipy or any other thrid party library easier. It allows reading numpy arrays to expressions, and then assign them to data value containers using variables and writing expressions to numpy arrays so variable data in data value containers of kratos do some calculation using numpy. + +**In the case of shared memory parallelized runs, these expressions will hold only data of corresponding data value containers of the local mesh**. + +## Writing to numpy arrays + +Writing an expression to a numpy array is super simple. In the case of **shared memory** parallelized runs, this will only generate a numpy array having only the data from the +```LocalMesh```. Following code snippet shows an example: +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([3,4,5])) + +# now create the expression: +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# now read the VELOCITY from the non-historical container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +# now get the numpy array from the expression +numpy_nodal_expression = nodal_expression.Evaluate() + +# first dimension of the numpy array always represents number of entities in the expression (local mesh entities only) +# rest of the dimensions represent the dimensions of the entity data. In this case, VELOCITY have only three components, +# it shows 3 as the last dimension. +print("Shape of the numpy array = ", numpy_nodal_expression.shape) +``` + +## Reading from numpy arrays +Reading from a numpy array is also simple with Expressions. First you can create the numpy array independent from Kratos if you are aware of the number of local entities (i.e. number of nodes/conditions/elements in the local mesh). Followings are supported numpy data types for the conversion: +1. ```numpy.int32``` +2. ```numpy.float64``` + +Thereafter, you can make a **copy** of the values to an expression. Following code snippet shows an example: + +```python +import numpy +# create the numpy expression. This does not need Kratos as long as you know correctly +# the number of local entities (i.e. nodes/conditions/elements) in the model part. +# it is a good practice to specify the "dtype" in here. +# here also, first dimension represent the number of local entities, rest of the +# dimensions represent the dimensionality of the entity data. +numpy_array = numpy.array([ + [1,2,3], + [3,4,5]], dtype=numpy.float64) + + +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +# now create the expression: +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# now read in the data from numpy array to expression +Kratos.Expression.CArrayExpressionIO.Read(nodal_expression, numpy_array) + +# now write the expression data to VELOCITY variable +Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.VELOCITY, False) + +for node in model_part.Nodes: + velocity = node.GetValue(Kratos.VELOCITY) + print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") +``` + +## Moving from numpy arrays + +This is similar to the [reading from numpy arrays](#reading-from-numpy-arraystest). The difference is, this does not create a copy within the expression. +It uses the memory location of the original numpy array with in the expression, hence it is of ```O(1)``` cost. No new meory allocation will be done +within the expression. So, if someone uses the moving of numpy array to an expression, **they need to make sure that the numpy array is not destroyed untill the expression or any of the dependent expressions are used up**. Otherwise, there will be a **Segmentation fault** error. + +Following code snippet illustrates how to move numpy arrays to expressions: +```python +import numpy +# create the numpy expression. This does not need Kratos as long as you know correctly +# the number of local entities (i.e. nodes/conditions/elements) in the model part. +# it is a good practice to specify the "dtype" in here. +# here also, first dimension represent the number of local entities, rest of the +# dimensions represent the dimensionality of the entity data. +numpy_array = numpy.array([ + [1,2,3], + [3,4,5]], dtype=numpy.float64) + + +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +# now create the expression: +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# now move in the data from numpy array to expression (linking nodal expression with numpy array) +Kratos.Expression.CArrayExpressionIO.Move(nodal_expression, numpy_array) + +# now write the expression data to VELOCITY variable +Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.VELOCITY, False) + +# now it will print the value in the numpy array +for node in model_part.Nodes: + velocity = node.GetValue(Kratos.VELOCITY) + print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") + +# now change some values in the numpy array +numpy_array[1, 1] = 10.0 + +# now write the expression data to VELOCITY variable to update the nodal data value container. +Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.VELOCITY, False) +# now it will print the modified value in the numpy array +for node in model_part.Nodes: + velocity = node.GetValue(Kratos.VELOCITY) + print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") +``` \ No newline at end of file From 51d281aae34ddf94d1ee07d4aea4c4365907717a Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Wed, 24 Jan 2024 10:57:59 +0100 Subject: [PATCH 05/99] add menu infos --- .../pages/Kratos/Expressions/General/menu_info.json | 6 ++++++ docs/pages/Kratos/Expressions/menu_info.json | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 docs/pages/Kratos/Expressions/General/menu_info.json create mode 100644 docs/pages/Kratos/Expressions/menu_info.json diff --git a/docs/pages/Kratos/Expressions/General/menu_info.json b/docs/pages/Kratos/Expressions/General/menu_info.json new file mode 100644 index 000000000000..36c7a56d5203 --- /dev/null +++ b/docs/pages/Kratos/Expressions/General/menu_info.json @@ -0,0 +1,6 @@ +{ + "custom_entries": [ + "Overview.md", + "Expression_Types.md" + ] +} \ No newline at end of file diff --git a/docs/pages/Kratos/Expressions/menu_info.json b/docs/pages/Kratos/Expressions/menu_info.json new file mode 100644 index 000000000000..7b519796c1d0 --- /dev/null +++ b/docs/pages/Kratos/Expressions/menu_info.json @@ -0,0 +1,13 @@ +{ + "side_bar_name": "kratos_expressions", + "landing_page": "General/Overview.md", + "additional_menu_options": { + "product": "Expressions", + "title": "sidebar" + }, + "custom_entries": [ + "General", + "Utilities", + "IOs" + ] +} \ No newline at end of file From 5a520dfd665cf468f13c4fe6095dc80beac1cbbb Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Thu, 25 Jan 2024 16:43:40 +0100 Subject: [PATCH 06/99] update docs --- .../IOs/Integration_Point_Expression_IO.md | 80 ++++++++++- .../IOs/Literal_Expression_Input.md | 135 +++++++++++++++++- .../IOs/Nodal_Position_Expression_IO.md | 73 +++++++++- .../Expressions/IOs/Variable_Expression_IO.md | 33 ++++- 4 files changed, 315 insertions(+), 6 deletions(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md index 2e68d062ed15..40cf0a633dd7 100644 --- a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md @@ -1,7 +1,83 @@ --- title: Integration Point Expression IO -keywords: +keywords: tags: [Integration_Point_Expression_IO.md] sidebar: kratos_expressions -summary: +summary: --- + +## Introduction + +```IntegrationPointExpressionIO``` is used to set and get the integration point quantities from ```Kratos::Condition``` or ```Kratos::Element``` containers. + +### Variable types +Following data types are supported for integration point quantity calculations. +* ```int``` +* ```double``` +* ```array_1d``` +* ```array_1d``` +* ```array_1d``` +* ```array_1d``` +* ```Vector``` +* ```Matrix``` + +### Shape of resulting expressions +The resulting expressions computed by ```IntegrationPointExpressionIO``` will have two additional dimensionalities apart from the dimensionality of the entity data type. The first dimension will illustrate number of entities in the expression. Second dimension will be number of gauss points computed in each entitiy. Rest of the dimensions will be representing the dimensionality of the entity data. + +## Reading and writing integration point data +Following code snippet shows how to read and write integration point data. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +model_part.CreateNewNode(3, 1.0, 1.0, 0.0) + +prop = model_part.CreateNewProperties(1) +cond1 = model_part.CreateNewElement("Element2D3N", 1, [1, 2, 3], prop) +cond1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) + +# now create the expression: +element_expression = Kratos.Expression.ElementExpression(model_part) + +# now read the VELOCITY from the container +Kratos.Expression.IntegrationPointExpressionIO.Read(element_expression, Kratos.VELOCITY) + +# the shape of the element expression will be [1, 1, 3] where first "1" is number of elements, second "1" is number of gauss points. +shape = element_expression.Evaluate().shape + +# do some arithmetic operations +element_expression *= 2.0 + +# now read the ACCELERATION from the container +Kratos.Expression.IntegrationPointExpressionIO.Write(element_expression, Kratos.ACCELERATION) +``` + +## 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 +advanced use cases. Following code snippet shows how to use bare ```Expressions```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +model_part.CreateNewNode(3, 1.0, 1.0, 0.0) + +prop = model_part.CreateNewProperties(1) +cond1 = model_part.CreateNewElement("Element2D3N", 1, [1, 2, 3], prop) +cond1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) + +# now create the expression by reading non historical velocity: +exp = Kratos.Expression.IntegrationPointExpressionIO.Input(model_part, Kratos.VELOCITY, Kratos.Expression.ContainerType.ElementNonHistorical).Execute() + +# do some arithmetic operations +exp *= 2.0 + +# now write the expression value to model part as ACCELERATION in the historical container +Kratos.Expression.IntegrationPointExpressionIO.Output(model_part, Kratos.ACCELERATION, Kratos.Expression.ContainerType.ElementNonHistorical).Execute(exp) +``` diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index 1c2d485a1c21..b30648c5ad8c 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -1,7 +1,140 @@ --- title: Literal Expression Input keywords: -tags: [Literal_Expression_Input.md] +tags: [literal values, expressions, scalars] sidebar: kratos_expressions summary: --- + +## Introduction + +```LiteralExpressionIO``` is used to represent literal values. Following literal types are supported: +* int +* double +* array_1d +* array_1d +* array_1d +* array_1d +* Vector +* Matrix + +This IO will create an expression with the specified literal for all entities. Since it is going to be constant for all entities, the literal will be stored only once for +all entities making the memory occupation the least. When the expression is evaluated, this stored literal will be read by all entities. + +## Setting literal expressions + +Following code snippet shows how to set literal expressions +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +# create the expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# create the literal expression +Kratos.Expression.LiteralExpressionIO.SetData(nodal_expression, Kratos.Array3([1, 2, 3])) + +# now write the value to non-historical velocity +Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.VELOCITY, False) + +# now check +for node in model_part.Nodes: + velocity = node.GetValue(Kratos.VELOCITY) + print(f"node_id: {node.Id}, velocity = [{velocity[0]}, {velocity[1]}, {velocity[2]}]") +``` + +## 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 dynamic data types, it will create empty data sets [Such as Vector with size 0, Matrix with shape (0,0)**. The passed variable is only used to determine the entity data shape. Following code-snippet shows an example: +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +node_1.SetValue(Kratos.PRESSURE, 10) +node_2.SetValue(Kratos.PRESSURE, 20) + +# create the expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the PRESSURE +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.PRESSURE, False) + +print("PRESSURE before resetting:\n", nodal_expression.Evaluate()) + +# create the literal expression +Kratos.Expression.LiteralExpressionIO.SetDataToZero(nodal_expression, Kratos.PRESSURE) + +# now write the value to non-historical velocity +Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.TEMPERATURE, False) + +# now check +for node in model_part.Nodes: + print(f"node_id: {node.Id}, pressure = {node.GetValue(Kratos.PRESSURE)}, temperature = {node.GetValue(Kratos.TEMPERATURE)}") +``` + +## 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. +Following is an example. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +node_1.SetValue(Kratos.PRESSURE, 10) +node_2.SetValue(Kratos.PRESSURE, 20) + +# create the expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the PRESSURE +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.PRESSURE, False) + +print("PRESSURE before resetting:\n", nodal_expression.Evaluate()) + +scalar_expression = Kratos.Expression.NodalExpression(model_part) +Kratos.Expression.LiteralExpressionIO.SetData(scalar_expression, 1.0) +inverse_expression = scalar_expression / nodal_expression + +# now write the value to non-historical velocity +Kratos.Expression.VariableExpressionIO.Write(inverse_expression, Kratos.TEMPERATURE, False) + +# 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)}") +``` + +## 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 +advanced use cases. Following code snippet shows how to use bare ```Expressions```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +# now create the expression by reading non historical velocity: +exp = Kratos.Expression.LiteralExpressionIO.Input(model_part, Kratos.Array3([1,2,3]), Kratos.Expression.ContainerType.NodalNonHistorical).Execute() + +# do some arithmetic operations +exp *= 2.0 + +# now write the expression value to model part as ACCELERATION in the historical container +Kratos.Expression.VariableExpressionIO.Output(model_part, Kratos.ACCELERATION, Kratos.Expression.ContainerType.NodalNonHistorical).Execute(exp) + +# now print and see +for node in model_part.Nodes: + acceleration = node.GetValue(Kratos.ACCELERATION) + print(f"node_id: {node.Id}, acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") +``` 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 3e6168cf9e7e..4094eb283294 100644 --- a/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md @@ -1,7 +1,78 @@ --- title: Nodal Position Expression IO keywords: -tags: [Nodal_Position_Expression_IO.md] +tags: [nodal position, initial, current, expressions] sidebar: kratos_expressions summary: --- + +## Introduction + +```NodalPositionExpressionIO``` allows writing and reading nodal positions of a given model part. This can be used on following configurations: +* Initial -> This uses the initial nodal position to read and write. +* Current -> This uses the current position of the nodes to read and write. + +In the case of **distributed memory** parallelized runs, the reading will only read the nodal positions of the nodes in the local mesh, and the writing will write to local mesh nodes and will afterwards synchronize to update the ghost meshes. + +## Reading and writing nodal positions +Following code snippet shows how to read initial and current configuration from nodes. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +model_part.AddNodalSolutionStepVariable(Kratos.ACCELERATION) +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +delta = 10.0 +node_1.X += delta +node_1.Y += delta + +# now create the expression: +initial_nodal_expression = Kratos.Expression.NodalExpression(model_part) +current_nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# now read the nodal positions +Kratos.Expression.NodalPositionExpressionIO.Read(initial_nodal_expression,Kratos.Configuration.Initial) +Kratos.Expression.NodalPositionExpressionIO.Read(current_nodal_expression,Kratos.Configuration.Current) + +print("initial:\n", initial_nodal_expression.Evaluate()) +print("current:\n", current_nodal_expression.Evaluate()) + +# now do some arithmatics with the exps +initial_nodal_expression *= 2 +current_nodal_expression *= 2 + +# now write the modified nodal positions back to nodes +Kratos.Expression.NodalPositionExpressionIO.Write(initial_nodal_expression,Kratos.Configuration.Initial) +Kratos.Expression.NodalPositionExpressionIO.Write(current_nodal_expression,Kratos.Configuration.Current) + +# 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}]") +``` + +## 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 +advanced use cases. Following code snippet shows how to use bare ```Expressions```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) + +# now create the expression by reading initial configuration: +exp = Kratos.Expression.NodalPositionExpressionIO.Input(model_part, Kratos.Configuration.Initial).Execute() + +# do some arithmetic operations +exp *= 2.0 + +# now write the expression value to current configuration +Kratos.Expression.NodalPositionExpressionIO.Output(model_part, Kratos.Configuration.Current).Execute(exp) + +# 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 diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index 17430039ac75..5ab6c8f908a4 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -1,7 +1,7 @@ --- title: Variable Expression IO keywords: -tags: [variable expression io, expressions] +tags: [variable expression io, expressions, variable] sidebar: kratos_expressions summary: --- @@ -121,4 +121,33 @@ for element in model_part.Elements: velocity = element.GetValue(Kratos.VELOCITY) acceleration = element.GetValue(Kratos.ACCELERATION) print(f"element_id: {element.Id}, velocity: [{velocity[0]},{velocity[1]},{velocity[2]}], acceleration: [{acceleration[0]},{acceleration[1]},{acceleration[2]}]") -``` \ No newline at end of file +``` + +## 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 +advanced use cases. Following code snippet shows how to use bare ```Expressions```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([3,4,5])) + +# now create the expression by reading non historical velocity: +exp = Kratos.Expression.VariableExpressionIO.Input(model_part, Kratos.VELOCITY, Kratos.Expression.ContainerType.NodalNonHistorical).Execute() + +# do some arithmetic operations +exp *= 2.0 + +# now write the expression value to model part as ACCELERATION in the historical container +Kratos.Expression.VariableExpressionIO.Output(model_part, Kratos.ACCELERATION, Kratos.Expression.ContainerType.NodalNonHistorical).Execute(exp) + +# now print and see +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]}]") +``` From 65f1ba46eac739ecb1cebd5cad23e06ac6644b0d Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 09:57:10 +0100 Subject: [PATCH 07/99] update IOs --- .../Expressions/IOs/Integration_Point_Expression_IO.md | 4 ++-- .../Kratos/Expressions/IOs/Literal_Expression_Input.md | 8 ++++---- .../Kratos/Expressions/IOs/Variable_Expression_IO.md | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md index 40cf0a633dd7..2c2c7110d8d8 100644 --- a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md @@ -73,11 +73,11 @@ cond1 = model_part.CreateNewElement("Element2D3N", 1, [1, 2, 3], prop) cond1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) # now create the expression by reading non historical velocity: -exp = Kratos.Expression.IntegrationPointExpressionIO.Input(model_part, Kratos.VELOCITY, Kratos.Expression.ContainerType.ElementNonHistorical).Execute() +exp = Kratos.Expression.IntegrationPointExpressionIO.Input(model_part, Kratos.VELOCITY, Kratos.Globals.DataLocation.Element).Execute() # do some arithmetic operations exp *= 2.0 # now write the expression value to model part as ACCELERATION in the historical container -Kratos.Expression.IntegrationPointExpressionIO.Output(model_part, Kratos.ACCELERATION, Kratos.Expression.ContainerType.ElementNonHistorical).Execute(exp) +Kratos.Expression.IntegrationPointExpressionIO.Output(model_part, Kratos.ACCELERATION, Kratos.Globals.DataLocation.Element).Execute(exp) ``` diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index b30648c5ad8c..5d37db5013c1 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -1,9 +1,9 @@ --- title: Literal Expression Input -keywords: +keywords: tags: [literal values, expressions, scalars] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -125,13 +125,13 @@ node_1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) node_2 = model_part.CreateNewNode(2, 0.0, 1.0, 0.0) # now create the expression by reading non historical velocity: -exp = Kratos.Expression.LiteralExpressionIO.Input(model_part, Kratos.Array3([1,2,3]), Kratos.Expression.ContainerType.NodalNonHistorical).Execute() +exp = Kratos.Expression.LiteralExpressionIO.Input(model_part, Kratos.Array3([1,2,3]), Kratos.Globals.DataLocation.NodeNonHistorical).Execute() # do some arithmetic operations exp *= 2.0 # now write the expression value to model part as ACCELERATION in the historical container -Kratos.Expression.VariableExpressionIO.Output(model_part, Kratos.ACCELERATION, Kratos.Expression.ContainerType.NodalNonHistorical).Execute(exp) +Kratos.Expression.VariableExpressionIO.Output(model_part, Kratos.ACCELERATION, Kratos.Globals.DataLocation.NodeNonHistorical).Execute(exp) # now print and see for node in model_part.Nodes: diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index 5ab6c8f908a4..b865819a8922 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Variable Expression IO -keywords: +keywords: tags: [variable expression io, expressions, variable] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -137,13 +137,13 @@ node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([3,4,5])) # now create the expression by reading non historical velocity: -exp = Kratos.Expression.VariableExpressionIO.Input(model_part, Kratos.VELOCITY, Kratos.Expression.ContainerType.NodalNonHistorical).Execute() +exp = Kratos.Expression.VariableExpressionIO.Input(model_part, Kratos.VELOCITY, Kratos.Globals.DataLocation.NodeNonHistorical).Execute() # do some arithmetic operations exp *= 2.0 # now write the expression value to model part as ACCELERATION in the historical container -Kratos.Expression.VariableExpressionIO.Output(model_part, Kratos.ACCELERATION, Kratos.Expression.ContainerType.NodalNonHistorical).Execute(exp) +Kratos.Expression.VariableExpressionIO.Output(model_part, Kratos.ACCELERATION, Kratos.Globals.DataLocation.NodeNonHistorical).Execute(exp) # now print and see for node in model_part.Nodes: From 1150805f8b77ebbfc46aa246f55568880ad12d77 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 10:25:47 +0100 Subject: [PATCH 08/99] add domain size exp io --- .../IOs/Domain_Size_Expression_IO.md | 35 ++++++++++++++++++- .../IOs/Integration_Point_Expression_IO.md | 4 +-- .../IOs/Literal_Expression_Input.md | 4 +-- .../Expressions/IOs/Variable_Expression_IO.md | 4 +-- 4 files changed, 40 insertions(+), 7 deletions(-) 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 896189a36906..3c456777474c 100644 --- a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -1,7 +1,40 @@ --- title: Domain Size Expression IO keywords: -tags: [Domain_Size_Expression_IO.md] +tags: [domain size, condition, element, expression io] sidebar: kratos_expressions summary: --- + +## Introduction + +```DomainSizeExpressionIO``` computes the domain sizes of each entitiy (such as ```Condition``` or ```Element```). This only supports ```ConditionExpression``` or ```ElementExression```. The domain sizes are computed by accessing underlying geometry's ```Geometry::DomainSize``` method of the entity. + +1. If the ```Condition``` or ```Element``` as a geometry representing a line, then this will compute an expression with line length for each entitiy. +2. If the ```Condition``` or ```Element``` as a geometry representing a surface, then this will compute an expression with surface area for each entitiy. +3. If the ```Condition``` or ```Element``` as a geometry representing a volume, then this will compute an expression with volume for each entitiy. + +The resulting expression will be always a scalar expression. + +## Reading domain sizes +Following code snippet shows how to read domain sizes to an expression +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +model_part.CreateNewNode(3, 1.0, 1.0, 0.0) + +prop = model_part.CreateNewProperties(1) +model_part.CreateNewElement("Element2D3N", 1, [1, 2, 3], prop) + +# now create the expression: +element_expression = Kratos.Expression.ElementExpression(model_part) + +# now read the element sizes (in this case triangle surface area) +Kratos.Expression.DomainSizeExpressionIO.Read(element_expression) + +shape = element_expression.Evaluate().shape +print(shape) +``` diff --git a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md index 2c2c7110d8d8..77c2c5b7777c 100644 --- a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Integration Point Expression IO -keywords: +keywords: tags: [Integration_Point_Expression_IO.md] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index 5d37db5013c1..0bfcb7fa9ef4 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -1,9 +1,9 @@ --- title: Literal Expression Input -keywords: +keywords: tags: [literal values, expressions, scalars] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index b865819a8922..162680caa54a 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Variable Expression IO -keywords: +keywords: tags: [variable expression io, expressions, variable] sidebar: kratos_expressions -summary: +summary: --- ## Introduction From b3fd523560a08a37e4381a50739062d151d5959d Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 10:30:14 +0100 Subject: [PATCH 09/99] update domain size exp io docs --- .../IOs/Domain_Size_Expression_IO.md | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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 3c456777474c..888b5f114509 100644 --- a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Domain Size Expression IO -keywords: +keywords: tags: [domain size, condition, element, expression io] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -38,3 +38,27 @@ Kratos.Expression.DomainSizeExpressionIO.Read(element_expression) shape = element_expression.Evaluate().shape print(shape) ``` + +## 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 +advanced use cases. Following code snippet shows how to use bare ```Expressions```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +model_part.CreateNewNode(1, 0.0, 0.0, 0.0) +model_part.CreateNewNode(2, 0.0, 1.0, 0.0) +model_part.CreateNewNode(3, 1.0, 1.0, 0.0) + +prop = model_part.CreateNewProperties(1) +model_part.CreateNewElement("Element2D3N", 1, [1, 2, 3], prop) + +# now create the expression by reading element domain sizes: +exp = Kratos.Expression.DomainSizeExpressionIO.Input(model_part, Kratos.Globals.DataLocation.Element).Execute() + +# do some arithmetic operations +exp *= 2.0 + +print(exp) +``` From 02ae667432ba6dfd886104f070b028226381e798 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 10:53:33 +0100 Subject: [PATCH 10/99] add expression arithmetics docs --- .../General/Expression_Arithmetics.md | 51 ++++++++++++++++++- .../IOs/Domain_Size_Expression_IO.md | 4 +- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index e93672bf3e77..271fbb4f10be 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -1,7 +1,56 @@ --- title: Expression Arithmetics keywords: -tags: [Expression_Arithmetics.md] +tags: [expression, arithmetaics] sidebar: kratos_expressions summary: --- + +## Introduction + +The ```Expressions``` of type ```NodalExpression```, ```ConditionExpression```, ```ElementExpression``` and their underlying ```Expression``` can be used in arithmetic formulations. + +Following operations are supported: +* Addition ```+``` or ```+=``` +* Substraction ```-``` or ```-=``` +* Multiplication ```*``` or ```*=``` +* Division ```/``` or ```/=``` +* Power ```**``` or ```**=``` + +**All these arithmatics always has ```O(1)``` computational cost because, they are not evaluated at the point these arithmetics are used. They are only evaluated when the final value of the ```Expression``` is required.** + +## Example usage +Following code snippet explains few use cases for ```NodalExpression```. All the other ```Expression``` also have a similar usage. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([4,5,6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([7,8,9])) + + +# create nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read non-historical nodal VELOCITY to expression +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +# now we can do arithmetics. +nodal_expression += 1 # Adds 1 to all the components of VELOCITY in all the entities +nodal_expression *= 2 # Multiplies by 2, the all the components of VELOCITY in all the entities +nodal_expression /= 3 # Divides by 2, the all the components of VELOCITY in all the entities +nodal_expression -= 0.5 # Substract by 2, the all the components of VELOCITY in all the entities + + +# writing the result to the ACCELERATION variable +Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.ACCELERATION, False) + +for node in model_part.Nodes: + print(node.GetValue(Kratos.ACCELERATION)) +``` 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 888b5f114509..b0c8fc39a6dc 100644 --- a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Domain Size Expression IO -keywords: +keywords: tags: [domain size, condition, element, expression io] sidebar: kratos_expressions -summary: +summary: --- ## Introduction From 57e86d31f96785d0808d3dbca22ff6d86278dbd8 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 11:00:17 +0100 Subject: [PATCH 11/99] add exp notes docs --- docs/pages/Kratos/Expressions/General/Notes.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Notes.md b/docs/pages/Kratos/Expressions/General/Notes.md index f5d296774213..dfa74cb0c18c 100644 --- a/docs/pages/Kratos/Expressions/General/Notes.md +++ b/docs/pages/Kratos/Expressions/General/Notes.md @@ -1,7 +1,15 @@ --- title: Notes keywords: -tags: [Notes.md] +tags: [notes, warnings, expression] sidebar: kratos_expressions summary: --- + +## Introduction + +The use of ```Expressions```, ```NodalExpression```, ```ConditionExpression``` or ```ElementExpression``` should be done carefully for the following reasons. + +1. If it is possible to implement the arithmetics or opertations you do in ```C++``` level, then it is encouraged. +2. Using arithmetics operators should be done carefully. In the case if, an expression being updated by another vectorial expression using operators such as ```+=```, ```-=```, ```*=```, ```/=```, ```**=```, then it will keep both left hand side and right hand side double vectors in memory. If this is being done for lot of iterations, it can exceed available RAM and crash the execution. Therefore, it is a good practice to use ```Kratos.Expression.Utils.Collpase``` to collapse the lazy expression hierarchy. +3. Use of expressions has an overhead cost due to the use of runtime-polymorphism. So, if it is bottleneck, then transfer the expression to the ```C++```. From f736e5c794379f7bd0397c08cc9723d1d40d05bd Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 11:37:49 +0100 Subject: [PATCH 12/99] add exp interface docs --- docs/pages/Kratos/Expressions/General/Expression_Interface.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Interface.md b/docs/pages/Kratos/Expressions/General/Expression_Interface.md index aa32449f875d..374432225719 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Interface.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Interface.md @@ -7,3 +7,5 @@ summary: --- ## Introduction + +TODO: Link this page to the doxygen page once it is properly online. From fabd2a305ed5989e164c8f525c0b3fdbbac76175 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 11:37:56 +0100 Subject: [PATCH 13/99] add abs docs --- .../pages/Kratos/Expressions/Utilities/Abs.md | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Abs.md b/docs/pages/Kratos/Expressions/Utilities/Abs.md index 4c80e023ab37..8cfb8b9ad465 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Abs.md +++ b/docs/pages/Kratos/Expressions/Utilities/Abs.md @@ -1,7 +1,84 @@ --- title: Abs keywords: -tags: [Abs.md] +tags: [abs, expression] sidebar: kratos_expressions summary: --- + +## Introduction + +This computes absolute value of each component of the given expression. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, N\right)\times\left[0, M\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, N\right)$$ for each entity and $$j\in \left[0, M\right)$$. Following equation illustrates the formulation of the resulting expression. + +

$$ Abs\left(\underline{\mathbb{u}}\right) = \left\lbrace \left|u_{ij}\right|, \forall (i,j)\in\left[0, N\right)\times\left[0, M\right)\right\rbrace$$

+ +## Use cases + +### Using to compute absolute values +Following code snippet illustrates how to use ```Abs```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +abs_nodal_expression = Kratos.Expression.Utils.Abs(nodal_expression) + +# now write the absolute value for checking to the ACCELERATION +Kratos.Expression.VariableExpressionIO.Write(abs_nodal_expression, Kratos.ACCELERATION, False) + +# now printing +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]}]") +``` + +### Using to compute entity wise inf-norm +Following code snippet illustrates how to use ```Abs``` to compute the entity wise inf-norm. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +norm_inf_nodal_expression = Kratos.Expression.Utils.EntityMax(Kratos.Expression.Utils.Abs(nodal_expression)) + +# now write the entity wise norm inf scalar value for checking to the PRESSURE +Kratos.Expression.VariableExpressionIO.Write(norm_inf_nodal_expression, Kratos.PRESSURE, False) + +# now printing +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}") +``` From 4e651c3171e995ba0073f0deaa9d1abf6f1cc1d8 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:04:13 +0100 Subject: [PATCH 14/99] add Pow docs --- .../pages/Kratos/Expressions/Utilities/Abs.md | 4 +- .../pages/Kratos/Expressions/Utilities/Pow.md | 94 ++++++++++++++++++- 2 files changed, 95 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Abs.md b/docs/pages/Kratos/Expressions/Utilities/Abs.md index 8cfb8b9ad465..8a30d2fef70c 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Abs.md +++ b/docs/pages/Kratos/Expressions/Utilities/Abs.md @@ -8,9 +8,9 @@ summary: ## Introduction -This computes absolute value of each component of the given expression. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, N\right)\times\left[0, M\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, N\right)$$ for each entity and $$j\in \left[0, M\right)$$. Following equation illustrates the formulation of the resulting expression. +This computes absolute value of each component of the given expression. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. -

$$ Abs\left(\underline{\mathbb{u}}\right) = \left\lbrace \left|u_{ij}\right|, \forall (i,j)\in\left[0, N\right)\times\left[0, M\right)\right\rbrace$$

+

$$ Abs\left(\underline{\mathbb{u}}\right) = \left\lbrace \left|u_{ij}\right|, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

## Use cases diff --git a/docs/pages/Kratos/Expressions/Utilities/Pow.md b/docs/pages/Kratos/Expressions/Utilities/Pow.md index 712745d9407a..c21d51052a0f 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Pow.md +++ b/docs/pages/Kratos/Expressions/Utilities/Pow.md @@ -1,7 +1,99 @@ --- title: Pow keywords: -tags: [Pow.md] +tags: [pow, expression] sidebar: kratos_expressions summary: --- + +## Introduction + +This raises value of each component to the specified power given by either a floating value or as an expression. +1. If it is raised to power given by a scalar, then all the components are raised to that power. +2. If it is raised to power given by a expression and the expression has the same shape as the input expression, then each component is raised to power by the expressions same component given by the second expression. +3. If it is raised to power given by a expression and the expression has shape of a scalar expression, then each component is raised to power by the second expression's entity value. + +Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. + +Case 1: +

$$ Pow\left(\underline{\mathbb{u}}, P\right) = \left\lbrace u_{ij}^P, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+ +Case 2: + +The expression with power is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ +

$$ Pow\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}^{P_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+ +Case 3: + +The expression with power is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ +

$$ Pow\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}^{P_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+ +## Use cases + +### Using to raise to power +Following code snippet illustrates how to use ```Pow```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +abs_nodal_expression = Kratos.Expression.Utils.Pow(nodal_expression, 3) + +# now write the absolute value for checking to the ACCELERATION +Kratos.Expression.VariableExpressionIO.Write(abs_nodal_expression, Kratos.ACCELERATION, False) + +# now printing +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]}]") +``` + +### Using to compute entity wise L2 norm +Following code snippet illustrates how to use ```Pow``` to compute the entity wise L2 norm. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +norm_l2_nodal_expression = Kratos.Expression.Utils.Pow(Kratos.Expression.Utils.EntitySum(Kratos.Expression.Utils.Pow(nodal_expression, 2)), 0.5) + +# now write the entity wise L2 norm scalar value for checking to the PRESSURE +Kratos.Expression.VariableExpressionIO.Write(norm_l2_nodal_expression, Kratos.PRESSURE, False) + +# now printing +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}") +``` From 14055375c2d88bd7a6f81554033d9eb4eed82c41 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:07:11 +0100 Subject: [PATCH 15/99] add scale docs --- .../pages/Kratos/Expressions/Utilities/Pow.md | 8 +-- .../Kratos/Expressions/Utilities/Scale.md | 60 ++++++++++++++++++- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Pow.md b/docs/pages/Kratos/Expressions/Utilities/Pow.md index c21d51052a0f..fa23a6ef830c 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Pow.md +++ b/docs/pages/Kratos/Expressions/Utilities/Pow.md @@ -1,9 +1,9 @@ --- title: Pow -keywords: +keywords: tags: [pow, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -21,12 +21,12 @@ Case 1: Case 2: The expression with power is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ -

$$ Pow\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}^{P_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+

$$ Pow\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}^{p_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 3: The expression with power is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ -

$$ Pow\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}^{P_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+

$$ Pow\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}^{p_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

## Use cases diff --git a/docs/pages/Kratos/Expressions/Utilities/Scale.md b/docs/pages/Kratos/Expressions/Utilities/Scale.md index 26439caa4bde..296c0d8a09a3 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Scale.md +++ b/docs/pages/Kratos/Expressions/Utilities/Scale.md @@ -1,7 +1,63 @@ --- title: Scale -keywords: +keywords: tags: [Scale.md] sidebar: kratos_expressions -summary: +summary: --- + +## Introduction + +This scales value of each component to the specified power given by either a floating value or as an expression. +1. If it is scaled given by a scalar, then all the components are raised to that power. +2. If it is scaled given by a expression and the expression has the same shape as the input expression, then each component is raised to power by the expressions same component given by the second expression. +3. If it is scaled given by a expression and the expression has shape of a scalar expression, then each component is raised to power by the second expression's entity value. + +Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. + +Case 1: +

$$ Scale\left(\underline{\mathbb{u}}, P\right) = \left\lbrace u_{ij}\times P, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+ +Case 2: + +The expression with scaling is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ +

$$ Scale\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}\times{p_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+ +Case 3: + +The expression with scaling is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ +

$$ Scale\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}\times{p_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+ +## Use cases +Following code snippet illustrates how to use ```Scale```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +abs_nodal_expression = Kratos.Expression.Utils.Scale(nodal_expression, 3) + +# now write the absolute value for checking to the ACCELERATION +Kratos.Expression.VariableExpressionIO.Write(abs_nodal_expression, Kratos.ACCELERATION, False) + +# now printing +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 From 1dce9d5ecad522db4102b63182b59e1434e1a5f8 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:09:42 +0100 Subject: [PATCH 16/99] minor --- docs/pages/Kratos/Expressions/Utilities/Pow.md | 4 ++-- docs/pages/Kratos/Expressions/Utilities/Scale.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Pow.md b/docs/pages/Kratos/Expressions/Utilities/Pow.md index fa23a6ef830c..9c83c474a208 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Pow.md +++ b/docs/pages/Kratos/Expressions/Utilities/Pow.md @@ -1,9 +1,9 @@ --- title: Pow -keywords: +keywords: tags: [pow, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/Utilities/Scale.md b/docs/pages/Kratos/Expressions/Utilities/Scale.md index 296c0d8a09a3..1fd2ce292006 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Scale.md +++ b/docs/pages/Kratos/Expressions/Utilities/Scale.md @@ -1,9 +1,9 @@ --- title: Scale -keywords: +keywords: tags: [Scale.md] sidebar: kratos_expressions -summary: +summary: --- ## Introduction From b770f854a2c3820e2747db210c929a7468a16dbb Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:10:30 +0100 Subject: [PATCH 17/99] minor --- docs/pages/Kratos/Expressions/Utilities/Scale.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Scale.md b/docs/pages/Kratos/Expressions/Utilities/Scale.md index 1fd2ce292006..099f95a11d50 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Scale.md +++ b/docs/pages/Kratos/Expressions/Utilities/Scale.md @@ -1,9 +1,9 @@ --- title: Scale -keywords: -tags: [Scale.md] +keywords: +tags: [scale, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction From e6873e476b9700a57d6cc8dc537a3d40a6da040c Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:20:03 +0100 Subject: [PATCH 18/99] add entity max docs --- .../Kratos/Expressions/Utilities/EntityMax.md | 46 +++++++++++++++++-- .../Kratos/Expressions/Utilities/Scale.md | 4 +- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md index 50cbcae50c34..98a9ead97e2a 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md @@ -1,7 +1,47 @@ --- title: EntityMax -keywords: -tags: [EntityMax.md] +keywords: +tags: [entity max, max, expression] sidebar: kratos_expressions -summary: +summary: --- + +## Introduction + +This get the maximum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. + +

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace \max_{j\in\left[0, N\right)} {u_{ij}}, \forall i\in\left[0, M\right)\right\rbrace$$

+ +## Use cases +Following code snippet illustrates how to use ```EntityMax```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +max_nodal_expression = Kratos.Expression.Utils.EntityMax(nodal_expression) + +# now write it to PRESSURE for checking. +Kratos.Expression.VariableExpressionIO.Write(max_nodal_expression, Kratos.PRESSURE, False) + +# now printing +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 diff --git a/docs/pages/Kratos/Expressions/Utilities/Scale.md b/docs/pages/Kratos/Expressions/Utilities/Scale.md index 099f95a11d50..273b94fec174 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Scale.md +++ b/docs/pages/Kratos/Expressions/Utilities/Scale.md @@ -1,9 +1,9 @@ --- title: Scale -keywords: +keywords: tags: [scale, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction From 41b4dc0cea9917f58e2ad6645e48b0e7f2eeba80 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:21:03 +0100 Subject: [PATCH 19/99] add entity min docs --- .../Kratos/Expressions/Utilities/EntityMin.md | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md index d7d6a81ee10f..4ee8ed50e59b 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md @@ -1,7 +1,46 @@ --- title: EntityMin -keywords: -tags: [EntityMin.md] +keywords: +tags: [entity min, min, expressions] sidebar: kratos_expressions -summary: +summary: --- +## Introduction + +This get the maximum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. + +

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace \min_{j\in\left[0, N\right)} {u_{ij}}, \forall i\in\left[0, M\right)\right\rbrace$$

+ +## Use cases +Following code snippet illustrates how to use ```EntityMax```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +min_nodal_expression = Kratos.Expression.Utils.EntityMin(nodal_expression) + +# now write it to PRESSURE for checking. +Kratos.Expression.VariableExpressionIO.Write(min_nodal_expression, Kratos.PRESSURE, False) + +# now printing +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 From 55df3d3865dbdda52cdd55dcdc1b15b0bc8ab3e4 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:21:55 +0100 Subject: [PATCH 20/99] minor --- docs/pages/Kratos/Expressions/Utilities/EntityMax.md | 4 ++-- docs/pages/Kratos/Expressions/Utilities/EntityMin.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md index 98a9ead97e2a..bd995ebabc80 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md @@ -1,9 +1,9 @@ --- title: EntityMax -keywords: +keywords: tags: [entity max, max, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md index 4ee8ed50e59b..5e51cb05eac5 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md @@ -9,7 +9,7 @@ summary: This get the maximum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. -

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace \min_{j\in\left[0, N\right)} {u_{ij}}, \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntityMin\left(\underline{\mathbb{u}}\right) = \left\lbrace \min_{j\in\left[0, N\right)} {u_{ij}}, \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases Following code snippet illustrates how to use ```EntityMax```. From 2017d1ad4955968925b44797153bbfb923643df0 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:26:20 +0100 Subject: [PATCH 21/99] fix for sets --- .../Kratos/Expressions/Utilities/EntityMax.md | 2 +- .../Kratos/Expressions/Utilities/EntityMin.md | 10 ++--- .../Kratos/Expressions/Utilities/EntitySum.md | 41 ++++++++++++++++++- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md index bd995ebabc80..a362d0fc728b 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md @@ -10,7 +10,7 @@ summary: This get the maximum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. -

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace \max_{j\in\left[0, N\right)} {u_{ij}}, \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \max_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases Following code snippet illustrates how to use ```EntityMax```. diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md index 5e51cb05eac5..2f99e12e1b64 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md @@ -1,18 +1,18 @@ --- title: EntityMin -keywords: +keywords: tags: [entity min, min, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This get the maximum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. +This get the minimum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. -

$$ EntityMin\left(\underline{\mathbb{u}}\right) = \left\lbrace \min_{j\in\left[0, N\right)} {u_{ij}}, \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \min_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases -Following code snippet illustrates how to use ```EntityMax```. +Following code snippet illustrates how to use ```EntityMin```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() diff --git a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md index 59c9f24eb350..2448c7b43bf3 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md @@ -1,7 +1,46 @@ --- title: EntitySum keywords: -tags: [EntitySum.md] +tags: [entity sum, sum, expressions] sidebar: kratos_expressions summary: --- +## Introduction + +This get the sum of value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. + +

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \sum_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

+ +## Use cases +Following code snippet illustrates how to use ```EntitySum```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +min_nodal_expression = Kratos.Expression.Utils.EntitySum(nodal_expression) + +# now write it to PRESSURE for checking. +Kratos.Expression.VariableExpressionIO.Write(min_nodal_expression, Kratos.PRESSURE, False) + +# now printing +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 From 5fd5dfa0f7670089f7e0b6e05e77b5a6df5d6963 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:27:43 +0100 Subject: [PATCH 22/99] minor --- docs/pages/Kratos/Expressions/Utilities/EntityMin.md | 2 +- docs/pages/Kratos/Expressions/Utilities/EntitySum.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md index 2f99e12e1b64..cdb4c6a02190 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md @@ -9,7 +9,7 @@ summary: This get the minimum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. -

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \min_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntityMin\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \min_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases Following code snippet illustrates how to use ```EntityMin```. diff --git a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md index 2448c7b43bf3..de7142b34aa5 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md @@ -9,7 +9,7 @@ summary: This get the sum of value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. -

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \sum_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntitySum\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \sum_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases Following code snippet illustrates how to use ```EntitySum```. From 23e65bc080e56ccf4881ee53207af1cb11c7522b Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:40:53 +0100 Subject: [PATCH 23/99] add scalar norm docs --- .../Expressions/Utilities/InnerProduct.md | 34 ++++++++++++++++++- .../Kratos/Expressions/Utilities/NormInf.md | 31 ++++++++++++++++- .../Kratos/Expressions/Utilities/NormL2.md | 31 ++++++++++++++++- .../Kratos/Expressions/Utilities/NormP.md | 31 ++++++++++++++++- 4 files changed, 123 insertions(+), 4 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md index ca21f2eafed4..120b791334f8 100644 --- a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md +++ b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md @@ -1,7 +1,39 @@ --- title: InnerProduct keywords: -tags: [InnerProduct.md] +tags: [inner product, expressions] sidebar: kratos_expressions summary: --- + +## Introduction +Computes component wise inner product between two expressions. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The second input expression is given by $$\underline{\mathbb{v}} = \left\lbrace v_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. + +**Both expressions should have the same shape** + +

$$ InnerProduct\left(\underline{\mathbb{u}}, \underline{\mathbb{v}}\right) = \sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)}u_{ij} \times v_{ij}$$

+ +## Use cases +Following code snippet illustrates how to use ```InnerProduct```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +print(Kratos.Expression.Utils.InnerProduct(nodal_expression, nodal_expression)) +``` \ No newline at end of file diff --git a/docs/pages/Kratos/Expressions/Utilities/NormInf.md b/docs/pages/Kratos/Expressions/Utilities/NormInf.md index ec51f0867728..dcbf7a889cbf 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormInf.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormInf.md @@ -1,7 +1,36 @@ --- title: NormInf keywords: -tags: [NormInf.md] +tags: [inf norm, expressions] sidebar: kratos_expressions summary: --- +## Introduction +Computes component wise inf norm in expressions. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. + +

$$ NormInf\left(\underline{\mathbb{u}}\right) = \max_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} \left|u_{ij}\right|$$

+ +## Use cases +Following code snippet illustrates how to use ```NormInf```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +print(Kratos.Expression.Utils.NormInf(nodal_expression)) +``` diff --git a/docs/pages/Kratos/Expressions/Utilities/NormL2.md b/docs/pages/Kratos/Expressions/Utilities/NormL2.md index 5d2d3015d266..0c639be21c7b 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormL2.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormL2.md @@ -1,7 +1,36 @@ --- title: NormL2 keywords: -tags: [NormL2.md] +tags: [l2 norm, expressions] sidebar: kratos_expressions summary: --- +## Introduction +Computes component wise L2 norm in expressions. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. + +

$$ NormL2\left(\underline{\mathbb{u}}\right) = \sqrt{\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {u_{ij}^2}}$$

+ +## Use cases +Following code snippet illustrates how to use ```NormL2```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +print(Kratos.Expression.Utils.NormL2(nodal_expression)) +``` \ No newline at end of file diff --git a/docs/pages/Kratos/Expressions/Utilities/NormP.md b/docs/pages/Kratos/Expressions/Utilities/NormP.md index 3410acd23b3a..64990b475e87 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormP.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormP.md @@ -1,7 +1,36 @@ --- title: NormP keywords: -tags: [NormP.md] +tags: [p norm, expressions] sidebar: kratos_expressions summary: --- +## Introduction +Computes component wise p norm in expressions. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. + +

$$ NormP\left(\underline{\mathbb{u}}, P\right) = \left({\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {\left|u_{ij}\right|^P}}\right)^{1/P}$$

+ +## Use cases +Following code snippet illustrates how to use ```NormL2```. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +print(Kratos.Expression.Utils.NormP(nodal_expression, 3)) +``` \ No newline at end of file From 617aed2451e9bf1e543839206589bd6beffe52ef Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 12:53:38 +0100 Subject: [PATCH 24/99] add collapse docs --- .../Kratos/Expressions/Utilities/Collapse.md | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Collapse.md b/docs/pages/Kratos/Expressions/Utilities/Collapse.md index 5713395258f3..a02a61aff0ec 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Collapse.md +++ b/docs/pages/Kratos/Expressions/Utilities/Collapse.md @@ -1,7 +1,44 @@ --- title: Collapse keywords: -tags: [Collapse.md] +tags: [collapse, lazy expression, expressions] sidebar: kratos_expressions summary: --- + +## Introduction +```Collapse``` method is used to collapse the lazy expression tree. **This is useful when the lazy expression tree is larger which occupies or exceeds the RAM +limitations.**. + +Using this method on an expression which will always result in an expression having the same shape, having the same evaluated values. But the resulting expression will be not having the tree structure since it is collapsed. + +## Use case +The max depth of an expression can be checked to identify the max depth of the lazy expression as explained in the following code snippet. It also explains how to collapse the tree hierarchy of the lazy expressions. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([-1,-2,-3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([-4,-5,-6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([-7,-8,-9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read the VELOCITY from non-historical nodal container +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +nodal_expression *= 2 +nodal_expression += 1 + +print(nodal_expression.GetMaxDepth()) + +collapsed_exp = Kratos.Expression.Utils.Collapse(nodal_expression) +print(collapsed_exp.GetMaxDepth()) +``` \ No newline at end of file From b77b6cf0120dc97c748192da60bbf94c451f4619 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 13:06:13 +0100 Subject: [PATCH 25/99] add comb docs --- .../Kratos/Expressions/Utilities/Comb.md | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Comb.md b/docs/pages/Kratos/Expressions/Utilities/Comb.md index 5a5e85aedcfd..0bc5b6972131 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Comb.md +++ b/docs/pages/Kratos/Expressions/Utilities/Comb.md @@ -1,7 +1,57 @@ --- title: Comb -keywords: -tags: [Comb.md] +keywords: +tags: [combing, expressions] sidebar: kratos_expressions -summary: +summary: --- + +## Introduction +This allows combining multiple expressions in to one expression. **The number of entities on all the combining expressions should have the same.** + +Example: +All provided expressions in the list_of_expression. +``` +For example, let the list_of_expression contain the following expressions: +exp_list[0] = data{1, 2, 3} with 3 items, and item shape = [] + - - - +exp_list[1] = data{4, 5, -1, 6, 7, -1, 8, 9, -1} with 3 items, and item shape = [3] + -------- -------- -------- +The resulting expression has item shape [3] with 4 items: +output_exp = [1, 4, 5, -1, 2, 6, 7, -1, 3, 8, 9, -1] + --------- -------- -------- +``` +This creates a lazy expression, hence it has a constant cost complexity irrespective of the data size (The expression won't be evaluated unless @ref Expression::Evaluate is called). + +## Use case +Following code snippet illustrates how the above example can be replicated. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY and PRESSURE of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([4,5,-1])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([6,7,-1])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([8,9,-1])) +node_1.SetValue(Kratos.PRESSURE, 1) +node_2.SetValue(Kratos.PRESSURE, 2) +node_3.SetValue(Kratos.PRESSURE, 3) + +# create expressions +u_exp = Kratos.Expression.NodalExpression(model_part) +p_exp = Kratos.Expression.NodalExpression(model_part) + +# read data in to expressions +Kratos.Expression.VariableExpressionIO.Read(u_exp, Kratos.VELOCITY, False) +Kratos.Expression.VariableExpressionIO.Read(p_exp, Kratos.PRESSURE, False) + +# now combine +combined_exp = Kratos.Expression.Utils.Comb([p_exp, u_exp]) + +print(combined_exp.Evaluate()) +``` \ No newline at end of file From f9cb77db63fc3a08f31439c7aaf53076f57380ff Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 13:09:23 +0100 Subject: [PATCH 26/99] add reshape docs --- .../Kratos/Expressions/Utilities/Comb.md | 4 +- .../Kratos/Expressions/Utilities/Reshape.md | 41 ++++++++++++++++++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Comb.md b/docs/pages/Kratos/Expressions/Utilities/Comb.md index 0bc5b6972131..84f89685c664 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Comb.md +++ b/docs/pages/Kratos/Expressions/Utilities/Comb.md @@ -1,9 +1,9 @@ --- title: Comb -keywords: +keywords: tags: [combing, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/Utilities/Reshape.md b/docs/pages/Kratos/Expressions/Utilities/Reshape.md index 39dcd1b37031..ef4e0a4cec00 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Reshape.md +++ b/docs/pages/Kratos/Expressions/Utilities/Reshape.md @@ -1,7 +1,46 @@ --- title: Reshape keywords: -tags: [Reshape.md] +tags: [reshape, expressions] sidebar: kratos_expressions summary: --- + +## Introduction +This method allows to reshape any expression to another new shape. **The total number of components in the new shape should be same as the original shape's total number of components.** + +## Use case +Following example showcases one of the use case of ```Reshape``` +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY and PRESSURE of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([4,5,-1])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([6,7,-1])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([8,9,-1])) +node_1.SetValue(Kratos.PRESSURE, 1) +node_2.SetValue(Kratos.PRESSURE, 2) +node_3.SetValue(Kratos.PRESSURE, 3) + +# create expressions +u_exp = Kratos.Expression.NodalExpression(model_part) +p_exp = Kratos.Expression.NodalExpression(model_part) + +# read data in to expressions +Kratos.Expression.VariableExpressionIO.Read(u_exp, Kratos.VELOCITY, False) +Kratos.Expression.VariableExpressionIO.Read(p_exp, Kratos.PRESSURE, False) + +# now combine +combined_exp = Kratos.Expression.Utils.Comb([p_exp, u_exp]) + +# now reshape +reshaped_exp = Kratos.Expression.Utils.Reshape(combined_exp, [2, 2]) + +print(reshaped_exp.Evaluate()) +``` From fc24f0915d119c581a3ae29e8f63f4d32f587b24 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Sat, 27 Jan 2024 13:15:12 +0100 Subject: [PATCH 27/99] add slice docs --- .../Kratos/Expressions/Utilities/Slice.md | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Slice.md b/docs/pages/Kratos/Expressions/Utilities/Slice.md index c62e9c674b46..69edbe93c80b 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Slice.md +++ b/docs/pages/Kratos/Expressions/Utilities/Slice.md @@ -1,7 +1,52 @@ --- title: Slice -keywords: -tags: [Slice.md] +keywords: +tags: [slice, expressions] sidebar: kratos_expressions -summary: +summary: --- + +## Introduction +This method slice existing expression to expressions having a new shape with some sub components from the original expression. +``` +Assume an @ref Expression of shape [3] and 3 entities with +the following data in the flattened representation: +@code +data = [1, 2, 3, 4, 5, 6, 7, 8, 9] + <- 1 -> <- 2 -> <- 3 -> +Data for entity 1 is represented with <-1->. + +Let Offset = 1 and Stride = 2. The resulting sliced expression +then represents the following data: + +output_data = [2, 3, 5, 6, 8, 9] +output container shape = [2] = equal to Stride. +``` + +## Use case +Following code snippet replicates the above example. +```python +import KratosMultiphysics as Kratos +model = Kratos.Model() +model_part = model.CreateModelPart("test") + +node_1 = model_part.CreateNewNode(1, 0, 0, 0) +node_2 = model_part.CreateNewNode(2, 1, 0, 0) +node_3 = model_part.CreateNewNode(3, 1, 1, 0) + +# setting VELOCITY of each node +node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) +node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([4,5,6])) +node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([7,8,9])) + +# create the nodal expression +nodal_expression = Kratos.Expression.NodalExpression(model_part) + +# read in the expression +Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, False) + +# slice +sliced_exp = Kratos.Expression.Utils.Slice(nodal_expression, 1, 2) + +print(sliced_exp.Evaluate()) +``` From e7bc7f0476bb322bd6c383e10ae5e4ac2deb773d Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 14:54:51 +0100 Subject: [PATCH 28/99] Update docs/pages/Kratos/Expressions/General/Overview.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Overview.md b/docs/pages/Kratos/Expressions/General/Overview.md index 404990689f6e..3b1aeaca7c39 100644 --- a/docs/pages/Kratos/Expressions/General/Overview.md +++ b/docs/pages/Kratos/Expressions/General/Overview.md @@ -7,9 +7,9 @@ summary: --- ## Introduction -An expression represents a mechanism where a given mathematical expression is evaluated when actual value of that expression in required. One can relate these -expressions to lazy expressions (expression templates) in [Eigen](https://eigen.tuxfamily.org/dox/TopicLazyEvaluation.html) or in [Boost](https://www.boost.org/doc/libs/1_82_0/doc/html/boost_yap/manual.html). The main difference being, Kratos expressions are lazy expressions which is evaluated at runtime, whereas Eigen anb Boost has lazy expressions which are evaluated at compile-time. Few of the main advantages of these lazy expressions are: -* May reduce memory foot. +An expression represents a mechanism where a given mathematical expression is evaluated when actual value of that expression in required. One can compare these +expressions to lazy expressions (expression templates) in [Eigen](https://eigen.tuxfamily.org/dox/TopicLazyEvaluation.html) or in [Boost](https://www.boost.org/doc/libs/1_82_0/doc/html/boost_yap/manual.html). The main difference being, Kratos expressions are **dynamic** lazy expressions (evaluated on demand, not automatically) whose type is evaluated at runtime, whereas Eigen and Boost has **static** lazy expressions whose type is known at compile-time. Few of the main advantages of these lazy expressions are: +* May reduce memory footprint. * May reduce computational cost. Kratos - Multiphysics has various types of data containers to store data. All of those data containers requires a ```Kratos::Variable``` to access its underlying data. This requires defining the variable before hand, and then using it to store and retrieve data. The expressions allows the user and/or developer to use these data containers with minimal to no variable to store/retrieve data from data containers. All the expressions are enabled with **shared memory** and **distributed memory** parallelisms. All of these expressions are implemented in C++, while being exposed to python. From bb193292423d5aa5e2e76e16d9bf0f023974085f Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 14:55:49 +0100 Subject: [PATCH 29/99] Update docs/pages/Kratos/Expressions/General/Overview.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Overview.md b/docs/pages/Kratos/Expressions/General/Overview.md index 3b1aeaca7c39..e04ab5fb0d01 100644 --- a/docs/pages/Kratos/Expressions/General/Overview.md +++ b/docs/pages/Kratos/Expressions/General/Overview.md @@ -12,7 +12,7 @@ expressions to lazy expressions (expression templates) in [Eigen](https://eigen. * May reduce memory footprint. * May reduce computational cost. -Kratos - Multiphysics has various types of data containers to store data. All of those data containers requires a ```Kratos::Variable``` to access its underlying data. This requires defining the variable before hand, and then using it to store and retrieve data. The expressions allows the user and/or developer to use these data containers with minimal to no variable to store/retrieve data from data containers. All the expressions are enabled with **shared memory** and **distributed memory** parallelisms. All of these expressions are implemented in C++, while being exposed to python. +KratosMultiphysics stores its data in different containers depending on what kind of geometry that data is associated with (node, element, condition, etc.) and what that data represents. Each container requires a ```Kratos::Variable``` to access its underlying data. This requires defining the variable beforehand, and then using it to store and retrieve its value. Expressions allow users/developers to access and manipulate the data within these containers regardless of what `Kratos::Variable` they belong to. All expressions support **shared memory** and **distributed memory** parallelism. Though implemented in C++, expressions are meant to be used mainly in python. ## Supported data containers From 025a2aeecdddbcdb3b206937beb4fd6dda7e633b Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 14:55:58 +0100 Subject: [PATCH 30/99] Update docs/pages/Kratos/Expressions/General/Overview.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Overview.md b/docs/pages/Kratos/Expressions/General/Overview.md index e04ab5fb0d01..c785b3f19184 100644 --- a/docs/pages/Kratos/Expressions/General/Overview.md +++ b/docs/pages/Kratos/Expressions/General/Overview.md @@ -16,7 +16,7 @@ KratosMultiphysics stores its data in different containers depending on what kin ## Supported data containers -Following data containers are supported: +The following data containers are supported: * NodalExpression - Nodal data value container (Historical / Non historical). * ConditionExpression - Condition data value container. * ElementExpression - Element data value container. From ca6c0a76e4865e9cb2a6dabbfa2044ec66d85999 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 14:56:15 +0100 Subject: [PATCH 31/99] Update docs/pages/Kratos/Expressions/General/Overview.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Overview.md b/docs/pages/Kratos/Expressions/General/Overview.md index c785b3f19184..c3bd581b18f6 100644 --- a/docs/pages/Kratos/Expressions/General/Overview.md +++ b/docs/pages/Kratos/Expressions/General/Overview.md @@ -17,9 +17,9 @@ KratosMultiphysics stores its data in different containers depending on what kin ## Supported data containers The following data containers are supported: -* NodalExpression - Nodal data value container (Historical / Non historical). -* ConditionExpression - Condition data value container. -* ElementExpression - Element data value container. +* NodalExpression - data related to nodes (with historical or non-historical variables). +* ConditionExpression - data related to conditions. +* ElementExpression - data related to elements. ## Supported data types From 945983c19de3576a33a44d2d1a2e16432d7b32e2 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 14:59:01 +0100 Subject: [PATCH 32/99] Update docs/pages/Kratos/Expressions/General/Overview.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Overview.md b/docs/pages/Kratos/Expressions/General/Overview.md index c3bd581b18f6..95fd6460becd 100644 --- a/docs/pages/Kratos/Expressions/General/Overview.md +++ b/docs/pages/Kratos/Expressions/General/Overview.md @@ -23,7 +23,7 @@ The following data containers are supported: ## Supported data types -The expressions support almost all the variable types in Kratos, and many more data types as well. The data storage in the expressions can be assumed as a flat ```int``` or ```double``` array. Followings are few supported data types: +Expressions are compatible with most main variable types in Kratos: * ```int``` * ```double``` From e984de2e920c2248c06d29d7bfe52c09aad86061 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 14:59:15 +0100 Subject: [PATCH 33/99] Update docs/pages/Kratos/Expressions/General/Overview.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Overview.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Overview.md b/docs/pages/Kratos/Expressions/General/Overview.md index 95fd6460becd..f6635163edda 100644 --- a/docs/pages/Kratos/Expressions/General/Overview.md +++ b/docs/pages/Kratos/Expressions/General/Overview.md @@ -36,13 +36,13 @@ Expressions are compatible with most main variable types in Kratos: ## Use cases -Expressions are usefull in following scenarios: -1. Transferring data back and forth from/to Kratos with another libraries - Library may be developed in another language like Fortran as well. -2. Transferring data back and forth from/to Kratos with numpy/scipy. -3. Transferring data back and forth from/to Kratos with HDF5. -4. If it is required to compute some intermediary value at python level, where a variable usage is not required such as in computing intermediate values with efficiency. +Expressions are useful in following scenarios: +1. Transferring data between Kratos and other libraries - third-party libraries may be developed in other languages like Fortran as well. +2. Transferring data between Kratos and numpy/scipy. +3. Storing and fetching Kratos data in HDF5. +4. Non performance-critical intermediate calculations in python. 5. Transerring data back and forth within Kratos without variables such as in OptimizationApplication. -6. Prototyping your research code with ease in python level while utilizing **shared memory** and **distributed memory** paralellism. +6. Quick and convenient prototyping of research code in python while using **shared memory** and **distributed memory** paralellism. From a1c4ff397b34f055dbe2b964a1d89602d2d61c37 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 14:59:37 +0100 Subject: [PATCH 34/99] Update docs/pages/Kratos/Expressions/General/Notes.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Notes.md b/docs/pages/Kratos/Expressions/General/Notes.md index dfa74cb0c18c..a5aa5d0b8fa0 100644 --- a/docs/pages/Kratos/Expressions/General/Notes.md +++ b/docs/pages/Kratos/Expressions/General/Notes.md @@ -8,7 +8,7 @@ summary: ## Introduction -The use of ```Expressions```, ```NodalExpression```, ```ConditionExpression``` or ```ElementExpression``` should be done carefully for the following reasons. +The use of ```Expression```, ```NodalExpression```, ```ConditionExpression``` or ```ElementExpression``` should be done carefully for the following reasons. 1. If it is possible to implement the arithmetics or opertations you do in ```C++``` level, then it is encouraged. 2. Using arithmetics operators should be done carefully. In the case if, an expression being updated by another vectorial expression using operators such as ```+=```, ```-=```, ```*=```, ```/=```, ```**=```, then it will keep both left hand side and right hand side double vectors in memory. If this is being done for lot of iterations, it can exceed available RAM and crash the execution. Therefore, it is a good practice to use ```Kratos.Expression.Utils.Collpase``` to collapse the lazy expression hierarchy. From 71fa5dbc895980cd3adc95efd004423f1f1f60ec Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:00:40 +0100 Subject: [PATCH 35/99] Update docs/pages/Kratos/Expressions/General/Notes.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Notes.md b/docs/pages/Kratos/Expressions/General/Notes.md index a5aa5d0b8fa0..9ef525e7bdf8 100644 --- a/docs/pages/Kratos/Expressions/General/Notes.md +++ b/docs/pages/Kratos/Expressions/General/Notes.md @@ -11,5 +11,5 @@ summary: The use of ```Expression```, ```NodalExpression```, ```ConditionExpression``` or ```ElementExpression``` should be done carefully for the following reasons. 1. If it is possible to implement the arithmetics or opertations you do in ```C++``` level, then it is encouraged. -2. Using arithmetics operators should be done carefully. In the case if, an expression being updated by another vectorial expression using operators such as ```+=```, ```-=```, ```*=```, ```/=```, ```**=```, then it will keep both left hand side and right hand side double vectors in memory. If this is being done for lot of iterations, it can exceed available RAM and crash the execution. Therefore, it is a good practice to use ```Kratos.Expression.Utils.Collpase``` to collapse the lazy expression hierarchy. +2. Use arithmetic operators (`+=`, `-=`, `*=`, `/=`, `**=`, `+`, `-`, `*`, `/`) carefully. Operators keep their operands in memory, which means that if you chain operations for long enough, at some point you will run out of RAM. In such cases, `Kratos.Expression.Utils.Collpase` to forcefully evaluate an expression and discard the hierarchy of operands it stored. An example use case would be updating the same expression with new data in every time step of an analysis. 3. Use of expressions has an overhead cost due to the use of runtime-polymorphism. So, if it is bottleneck, then transfer the expression to the ```C++```. From 630cbe8d45d487f034776f1cf86d0295464b495f Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:01:02 +0100 Subject: [PATCH 36/99] Update docs/pages/Kratos/Expressions/General/Notes.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Notes.md b/docs/pages/Kratos/Expressions/General/Notes.md index 9ef525e7bdf8..b500849e788d 100644 --- a/docs/pages/Kratos/Expressions/General/Notes.md +++ b/docs/pages/Kratos/Expressions/General/Notes.md @@ -12,4 +12,4 @@ The use of ```Expression```, ```NodalExpression```, ```ConditionExpression``` or 1. If it is possible to implement the arithmetics or opertations you do in ```C++``` level, then it is encouraged. 2. Use arithmetic operators (`+=`, `-=`, `*=`, `/=`, `**=`, `+`, `-`, `*`, `/`) carefully. Operators keep their operands in memory, which means that if you chain operations for long enough, at some point you will run out of RAM. In such cases, `Kratos.Expression.Utils.Collpase` to forcefully evaluate an expression and discard the hierarchy of operands it stored. An example use case would be updating the same expression with new data in every time step of an analysis. -3. Use of expressions has an overhead cost due to the use of runtime-polymorphism. So, if it is bottleneck, then transfer the expression to the ```C++```. +3. Expressions have significant memory and performance overhead due to dynamic polymorphism. If it becomes a bottleneck, move your calculations to `C++`. From 25a767d12d41151d0c6f6fa3dfc585b7ae96875e Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:01:28 +0100 Subject: [PATCH 37/99] Update docs/pages/Kratos/Expressions/General/Expression_Types.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- .../pages/Kratos/Expressions/General/Expression_Types.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Types.md b/docs/pages/Kratos/Expressions/General/Expression_Types.md index 8adf4661c94f..98fe310cd22f 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Types.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Types.md @@ -8,10 +8,11 @@ summary: ## Introduction -There are three types of expressions. -* NodalExpression -* ConditionExpression -* ElementExpression +There are four types of expressions. +* `Expression` +* `NodalExpression` +* `ConditionExpression` +* `ElementExpression` ## Nodal Expression From 0ea045f43ef09c8e198a8a3776db6e9cfaf6938f Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:02:04 +0100 Subject: [PATCH 38/99] Update docs/pages/Kratos/Expressions/General/Expression_Types.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Expression_Types.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Types.md b/docs/pages/Kratos/Expressions/General/Expression_Types.md index 98fe310cd22f..eb4ec82bb76d 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Types.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Types.md @@ -14,6 +14,13 @@ There are four types of expressions. * `ConditionExpression` * `ElementExpression` +## `Expression` + +`Expression` is the lowest level class that everything else is built on top of. It models an array of numeric values (scalars, vectors, matrices, etc.), supports arithmetic operations, but is not related to any container in Kratos. To create an `Expression` or write an existing one, you can use one of the derived classes of `ExpressionIO`. + +TODO: add an example (@matekelemen) - requires exposing the `Input` and `Output` nested classes of `VariableExpressionIO` to python. + + ## Nodal Expression Nodal expressions are used to store data related to nodal quantities. They may be historical or non-historical. Following code snippet illustrtes creating a nodal expression From a0762936a7361faf04ab191bdb91bd58496f276c Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:02:32 +0100 Subject: [PATCH 39/99] Update docs/pages/Kratos/Expressions/General/Expression_Types.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Expression_Types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Types.md b/docs/pages/Kratos/Expressions/General/Expression_Types.md index eb4ec82bb76d..498bc20f0b15 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Types.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Types.md @@ -24,7 +24,7 @@ TODO: add an example (@matekelemen) - requires exposing the `Input` and `Output` ## Nodal Expression Nodal expressions are used to store data related to nodal quantities. They may be historical or non-historical. Following code snippet illustrtes creating a nodal expression -and reading ```VELOCITY``` from nodal non-historical data value container. +and reading ```VELOCITY``` from non-historical nodal container. ```python import KratosMultiphysics as Kratos model = Kratos.Model() From 2e43ac93cd1c2afb653e882debec57f219a43083 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:02:45 +0100 Subject: [PATCH 40/99] Update docs/pages/Kratos/Expressions/General/Expression_Types.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Expression_Types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Types.md b/docs/pages/Kratos/Expressions/General/Expression_Types.md index 498bc20f0b15..a71fbb8000f3 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Types.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Types.md @@ -44,7 +44,7 @@ Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, F ## Condition Expression Condition expressions are used to store data related to condition quantities. Following code snippet illustrtes creating a condition expression -and reading ```VELOCITY``` from condition data value container. +and reading ```VELOCITY``` from the conditions' container. ```python import KratosMultiphysics as Kratos model = Kratos.Model() From a8f1bdec5cbdc67be95a634ea10fb5ca97b7f651 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:02:57 +0100 Subject: [PATCH 41/99] Update docs/pages/Kratos/Expressions/General/Expression_Types.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Expression_Types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Types.md b/docs/pages/Kratos/Expressions/General/Expression_Types.md index a71fbb8000f3..0b7b22ae13fe 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Types.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Types.md @@ -66,7 +66,7 @@ Kratos.Expression.VariableExpressionIO.Read(condition_expression, Kratos.VELOCIT ## Element Expression Element expressions are used to store data related to element quantities. Following code snippet illustrtes creating a element expression -and reading ```VELOCITY``` from element data value container. +and reading ```VELOCITY``` from the elements' container. ```python import KratosMultiphysics as Kratos model = Kratos.Model() From 33327ff29f552299639d3b4b68950d4d88435a3f Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:03:20 +0100 Subject: [PATCH 42/99] Update docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index 271fbb4f10be..c8fded609f6b 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -17,7 +17,7 @@ Following operations are supported: * Division ```/``` or ```/=``` * Power ```**``` or ```**=``` -**All these arithmatics always has ```O(1)``` computational cost because, they are not evaluated at the point these arithmetics are used. They are only evaluated when the final value of the ```Expression``` is required.** +These operations are carried out only when their results are required ([lazy evaluation](https://en.wikipedia.org/wiki/Lazy_evaluation)). ## Example usage Following code snippet explains few use cases for ```NodalExpression```. All the other ```Expression``` also have a similar usage. From 50f52cb894c1f8d3102c490f9f1e3eb564fc0c85 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:03:43 +0100 Subject: [PATCH 43/99] Update docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index c8fded609f6b..b767db68e67b 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -20,7 +20,7 @@ Following operations are supported: These operations are carried out only when their results are required ([lazy evaluation](https://en.wikipedia.org/wiki/Lazy_evaluation)). ## Example usage -Following code snippet explains few use cases for ```NodalExpression```. All the other ```Expression``` also have a similar usage. +Here is an example for using ```NodalExpression``` (other expression types can be used in a similar fashion). ```python import KratosMultiphysics as Kratos model = Kratos.Model() From 9b7d0b117cea0fb64bbc76516ba0343244b7bf5e Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:04:14 +0100 Subject: [PATCH 44/99] Update docs/pages/Kratos/Expressions/General/Working_with_Numpy.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Working_with_Numpy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index dfa929c57489..6699ebb1e47b 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -8,7 +8,7 @@ summary: ## Introduction -Expressions make working with nump/scipy or any other thrid party library easier. It allows reading numpy arrays to expressions, and then assign them to data value containers using variables and writing expressions to numpy arrays so variable data in data value containers of kratos do some calculation using numpy. +Expressions make working with numpy/scipy or any other thrid party library easier. It allows reading numpy arrays to expressions, and then assign them to Kratos containers using variables. **In the case of shared memory parallelized runs, these expressions will hold only data of corresponding data value containers of the local mesh**. From 2e92fd8bbc4684464bf820815fe24b7ed9ffc0c9 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:04:37 +0100 Subject: [PATCH 45/99] Update docs/pages/Kratos/Expressions/General/Working_with_Numpy.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Working_with_Numpy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index 6699ebb1e47b..6ad924c8ea68 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -10,7 +10,7 @@ summary: Expressions make working with numpy/scipy or any other thrid party library easier. It allows reading numpy arrays to expressions, and then assign them to Kratos containers using variables. -**In the case of shared memory parallelized runs, these expressions will hold only data of corresponding data value containers of the local mesh**. +**When running with MPI, these expressions will hold only data of corresponding containers of the local mesh**. ## Writing to numpy arrays From 8ee55303848ef0135f91b8adff514145aec17327 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:04:56 +0100 Subject: [PATCH 46/99] Update docs/pages/Kratos/Expressions/General/Working_with_Numpy.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Working_with_Numpy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index 6ad924c8ea68..07c60391fa31 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -41,7 +41,7 @@ print("Shape of the numpy array = ", numpy_nodal_expression.shape) ``` ## Reading from numpy arrays -Reading from a numpy array is also simple with Expressions. First you can create the numpy array independent from Kratos if you are aware of the number of local entities (i.e. number of nodes/conditions/elements in the local mesh). Followings are supported numpy data types for the conversion: +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``` 2. ```numpy.float64``` From 396c2ad24ffe12f445c8820c17a5fa14562c0b9d Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:05:22 +0100 Subject: [PATCH 47/99] Update docs/pages/Kratos/Expressions/General/Working_with_Numpy.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Working_with_Numpy.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index 07c60391fa31..b50d3b494dc3 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -14,8 +14,6 @@ Expressions make working with numpy/scipy or any other thrid party library easie ## Writing to numpy arrays -Writing an expression to a numpy array is super simple. In the case of **shared memory** parallelized runs, this will only generate a numpy array having only the data from the -```LocalMesh```. Following code snippet shows an example: ```python import KratosMultiphysics as Kratos model = Kratos.Model() From dd57579d8979b2bb48c77f76efbf23db59e807fd Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:05:41 +0100 Subject: [PATCH 48/99] Update docs/pages/Kratos/Expressions/General/Working_with_Numpy.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Working_with_Numpy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index b50d3b494dc3..6aa3c6a0d0ac 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -43,7 +43,7 @@ First create the numpy array independent from Kratos if the number of local enti 1. ```numpy.int32``` 2. ```numpy.float64``` -Thereafter, you can make a **copy** of the values to an expression. Following code snippet shows an example: +The numpy array can then be **copied** to the expression. The following code snippet shows an example: ```python import numpy From 2c00817e748b017d1a4cad8d17e4f13f1f390bec Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 15:06:19 +0100 Subject: [PATCH 49/99] Update docs/pages/Kratos/Expressions/General/Working_with_Numpy.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/General/Working_with_Numpy.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index 6aa3c6a0d0ac..be9bfe45441a 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -79,9 +79,8 @@ for node in model_part.Nodes: ## Moving from numpy arrays -This is similar to the [reading from numpy arrays](#reading-from-numpy-arraystest). The difference is, this does not create a copy within the expression. -It uses the memory location of the original numpy array with in the expression, hence it is of ```O(1)``` cost. No new meory allocation will be done -within the expression. So, if someone uses the moving of numpy array to an expression, **they need to make sure that the numpy array is not destroyed untill the expression or any of the dependent expressions are used up**. Otherwise, there will be a **Segmentation fault** error. +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. +It uses the memory location of the original numpy array within the expression, eliding the copy and its related memory allocation. An important consequence is that **the original numpy array must be kept in memory for entire lifetime of the expression**, otherwise evaluating the expression will result in a segmentation fault. Following code snippet illustrates how to move numpy arrays to expressions: ```python From 49060a5c58e2a1596593e3b7bc50714e46b7bf9b Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Fri, 2 Feb 2024 15:44:45 +0100 Subject: [PATCH 50/99] minor --- .../General/Expression_Arithmetics.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index b767db68e67b..bb93b27e936e 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -1,9 +1,9 @@ --- title: Expression Arithmetics -keywords: -tags: [expression, arithmetaics] +keywords: +tags: [expression, arithmetics] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -12,7 +12,7 @@ The ```Expressions``` of type ```NodalExpression```, ```ConditionExpression```, Following operations are supported: * Addition ```+``` or ```+=``` -* Substraction ```-``` or ```-=``` +* Subtraction ```-``` or ```-=``` * Multiplication ```*``` or ```*=``` * Division ```/``` or ```/=``` * Power ```**``` or ```**=``` @@ -34,7 +34,6 @@ node_1.SetValue(Kratos.VELOCITY, Kratos.Array3([1,2,3])) node_2.SetValue(Kratos.VELOCITY, Kratos.Array3([4,5,6])) node_3.SetValue(Kratos.VELOCITY, Kratos.Array3([7,8,9])) - # create nodal expression nodal_expression = Kratos.Expression.NodalExpression(model_part) @@ -45,12 +44,13 @@ Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, F nodal_expression += 1 # Adds 1 to all the components of VELOCITY in all the entities nodal_expression *= 2 # Multiplies by 2, the all the components of VELOCITY in all the entities nodal_expression /= 3 # Divides by 2, the all the components of VELOCITY in all the entities -nodal_expression -= 0.5 # Substract by 2, the all the components of VELOCITY in all the entities - +nodal_expression -= 0.5 # Subtract by 2, the all the components of VELOCITY in all the entities # writing the result to the ACCELERATION variable Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.ACCELERATION, False) for node in model_part.Nodes: print(node.GetValue(Kratos.ACCELERATION)) -``` + +## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION +``` \ No newline at end of file From 33f921f9ceecddb300235af053e509f7e61da0e4 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Fri, 2 Feb 2024 16:12:15 +0100 Subject: [PATCH 51/99] add expected output --- .../General/Expression_Arithmetics.md | 22 ++++++-- .../Expressions/General/Working_with_Numpy.md | 51 ++++++++++++++++++- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index bb93b27e936e..fbbc4008049b 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -1,9 +1,9 @@ --- title: Expression Arithmetics -keywords: +keywords: tags: [expression, arithmetics] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -53,4 +53,20 @@ for node in model_part.Nodes: print(node.GetValue(Kratos.ACCELERATION)) ## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION -``` \ No newline at end of file +``` + +Expected output: +```bash +[3](0.833333,1.5,2.16667) +[3](2.83333,3.5,4.16667) +[3](4.83333,5.5,6.16667) + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + 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/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index be9bfe45441a..e96000b025d5 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -36,6 +36,21 @@ numpy_nodal_expression = nodal_expression.Evaluate() # rest of the dimensions represent the dimensions of the entity data. In this case, VELOCITY have only three components, # it shows 3 as the last dimension. print("Shape of the numpy array = ", numpy_nodal_expression.shape) +## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION +``` + +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 @@ -75,6 +90,22 @@ Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.VELOCITY, for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") +## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION +``` + +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 @@ -124,4 +155,22 @@ Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.VELOCITY, for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") -``` \ No newline at end of file +## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION +``` + +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. +``` From af0ebd6347e88505347f9923a59c0c1720275474 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 21:59:08 +0100 Subject: [PATCH 52/99] Update docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 17bf6d44430f..fc3b0d4fa96f 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -8,7 +8,7 @@ summary: ## Introduction -```CArrayExpressionIO``` is used to exchange data between `C` type arrays and expressions. This allows reading from `C` arrays as well as writing to `C` arrays. In the python later, it can be used to exchange data between numpy arrays, ```Kratos::Vectors``` as well. +```CArrayExpressionIO``` is used to exchange data between `C` type arrays and expressions. In python, it can be used to exchange data between numpy arrays, ```Kratos::Vectors```, or any other contiguous array of supported types. ## Reading and moving from numpy array From dcb3acb108b9198f622188f732fc08dadae69998 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 21:59:42 +0100 Subject: [PATCH 53/99] Update docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fc3b0d4fa96f..d02e411a953d 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -10,7 +10,7 @@ summary: ```CArrayExpressionIO``` is used to exchange data between `C` type arrays and expressions. In python, it can be used to exchange data between numpy arrays, ```Kratos::Vectors```, or any other contiguous array of supported types. -## Reading and moving from numpy array +## Reading or viewing a numpy array Please refer to [Working with numpy](../General/Working_with_Numpy.html) section. From ccab6cf16b849122cf6b0fbc10fc6f1367ea74a5 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:00:02 +0100 Subject: [PATCH 54/99] Update docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 d02e411a953d..605f48c19946 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -15,8 +15,7 @@ summary: Please refer to [Working with numpy](../General/Working_with_Numpy.html) section. ## Writing to numpy array -Writing an expression to a numpy array is super simple. In the case of **shared memory** parallelized runs, this will only write only the data from the -```LocalMesh``` to the numpy array. The size of the numpy array should be compatible with the expression shape. Following code snippet shows an example: +In MPI runs, expressions will only write data from the ```LocalMesh``` to the numpy array. The size of the numpy array should be compatible with the expression shape. The following code snippet shows an example: ```python import numpy import KratosMultiphysics as Kratos From 8e58f6130db3b54b2bb518ab155bc53440178e1e Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:00:13 +0100 Subject: [PATCH 55/99] Update docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 605f48c19946..17c614fc6f5f 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -42,7 +42,7 @@ Kratos.Expression.CArrayExpressionIO.Write(nodal_expression, numpy_array) print("numpy array = ", numpy_array) ``` -## Reading and writing to Kratos::Vector +## Reading and writing to `Kratos::Vector` ```CArrayExpressionIO``` also allows reading and writing from ```Kratos::Vector``` data 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. The arguments for reading from a ```Kratos::Vector``` are, first the expression should be passed, secondly the ```Kratos::Vector``` should be passed. Finally the shape of the entity data should be passed. Following code snippet illustrates the usage. From 9c465b91794b7bdd875b9e0f6ea94c50043c4d00 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:01:21 +0100 Subject: [PATCH 56/99] Update docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 17c614fc6f5f..0b5f4f4ec828 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -43,7 +43,7 @@ print("numpy array = ", numpy_array) ``` ## Reading and writing to `Kratos::Vector` -```CArrayExpressionIO``` also allows reading and writing from ```Kratos::Vector``` data 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. +```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. The arguments for reading from a ```Kratos::Vector``` are, first the expression should be passed, secondly the ```Kratos::Vector``` should be passed. Finally the shape of the entity data should be passed. Following code snippet illustrates the usage. ```python From a6b1f873c170ebea8e6acabafdfde898739fee2d Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:01:45 +0100 Subject: [PATCH 57/99] Update docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 0b5f4f4ec828..281ddc17cb77 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -45,7 +45,12 @@ print("numpy array = ", numpy_array) ## 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. -The arguments for reading from a ```Kratos::Vector``` are, first the expression should be passed, secondly the ```Kratos::Vector``` should be passed. Finally the shape of the entity data should be passed. Following code snippet illustrates the usage. +The arguments for reading from a ```Kratos::Vector``` are: +- expression to read to +- `Kratos::Vector` to read from +- shape of the entity + +Example: ```python import KratosMultiphysics as Kratos model = Kratos.Model() From 16c6488a616614a55096a60394bfe2fc9bc72b4c Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:02:18 +0100 Subject: [PATCH 58/99] Update docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b0c8fc39a6dc..7f2e52543450 100644 --- a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -8,7 +8,7 @@ summary: ## Introduction -```DomainSizeExpressionIO``` computes the domain sizes of each entitiy (such as ```Condition``` or ```Element```). This only supports ```ConditionExpression``` or ```ElementExression```. The domain sizes are computed by accessing underlying geometry's ```Geometry::DomainSize``` method of the entity. +```DomainSizeExpressionIO``` computes the domain sizes (length, surface or volume, depending of the entity's dimension) of each entitiy (such as ```Condition``` or ```Element```) in the provided `ModelPart`. This only supports ```ConditionExpression``` or ```ElementExression```. Domain sizes are computed by accessing underlying geometry's ```Geometry::DomainSize``` method. 1. If the ```Condition``` or ```Element``` as a geometry representing a line, then this will compute an expression with line length for each entitiy. 2. If the ```Condition``` or ```Element``` as a geometry representing a surface, then this will compute an expression with surface area for each entitiy. From d3b92b52a3c1bcaa90edf46ae7462980658b8430 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:02:36 +0100 Subject: [PATCH 59/99] Update docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7f2e52543450..5dc9baef068b 100644 --- a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -14,7 +14,7 @@ summary: 2. If the ```Condition``` or ```Element``` as a geometry representing a surface, then this will compute an expression with surface area for each entitiy. 3. If the ```Condition``` or ```Element``` as a geometry representing a volume, then this will compute an expression with volume for each entitiy. -The resulting expression will be always a scalar expression. +The resulting expression is always a scalar expression. ## Reading domain sizes Following code snippet shows how to read domain sizes to an expression From d7bd0fd7e0c7893a01231535f1d625696b8395a5 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:02:56 +0100 Subject: [PATCH 60/99] Update docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- .../Kratos/Expressions/IOs/Integration_Point_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md index 77c2c5b7777c..972e34f33aca 100644 --- a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md @@ -8,7 +8,7 @@ summary: ## Introduction -```IntegrationPointExpressionIO``` is used to set and get the integration point quantities from ```Kratos::Condition``` or ```Kratos::Element``` containers. +```IntegrationPointExpressionIO``` is used to set or get quantities at integration points from elements or conditions. ### Variable types Following data types are supported for integration point quantity calculations. From 5131b41da78576867f2367bde5196bc20a2256b2 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:03:26 +0100 Subject: [PATCH 61/99] Update docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- .../Kratos/Expressions/IOs/Integration_Point_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md index 972e34f33aca..c607f172f112 100644 --- a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md @@ -22,7 +22,7 @@ Following data types are supported for integration point quantity calculations. * ```Matrix``` ### Shape of resulting expressions -The resulting expressions computed by ```IntegrationPointExpressionIO``` will have two additional dimensionalities apart from the dimensionality of the entity data type. The first dimension will illustrate number of entities in the expression. Second dimension will be number of gauss points computed in each entitiy. Rest of the dimensions will be representing the dimensionality of the entity data. +The resulting expressions computed by ```IntegrationPointExpressionIO``` will have two additional dimensions on top of the data type's dimensions. The first one indicates the number of entities in the expression, while the second dimension is the number of gauss points computed in each entitiy. The rest of the dimensions are carried over from the integration point quantity. ## Reading and writing integration point data Following code snippet shows how to read and write integration point data. From 5dd974af25a3efaa13e8c32550fd343f3dac8f9d Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:04:00 +0100 Subject: [PATCH 62/99] Update docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index 162680caa54a..baff82d2a294 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -23,7 +23,7 @@ Following variable types are allowed to be read in or write to from an expressio * ```Kratos::Variable``` ### Shape of the resulting expression -In the case of static data types given by static data type variables (such as ```Kratos::Variable```, ```Kratos::Variable>```), the shape of the expression will be always have number of local entities in the first dimension, rest will be followed by the static size of the data type. If the variable type being used is of dynamic data type (such as ```Kratos::Variable```, ```Kratos::Variable```), then it will represent still the number of local entities in the first dimension. Rest of the dimensions will represent the dimenions of the first data value found in the respective container. [In the case of **distributed memory** parallelized runs, first data value shape synchronization is done to identify the shape of the expression]. +If the data type has static size (such as ```Kratos::Variable```, ```Kratos::Variable>```), the result's shape is the number of local entities, followed by the static size of the type. However, if the data type has dynamic size (such as ```Kratos::Variable```, ```Kratos::Variable```), then all entries in the container are assumed to have the same shape as the first entry. [In MPI runs, the first entry's shape is synchronized across all ranks to determine the final shape of the expression]. ## Reading/Writing nodal values From 4e537cf2091969fc25541d168d08b0fa7f085740 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:04:39 +0100 Subject: [PATCH 63/99] Update docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- .../Expressions/IOs/Integration_Point_Expression_IO.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md index c607f172f112..25c1724e08aa 100644 --- a/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Integration_Point_Expression_IO.md @@ -55,9 +55,8 @@ Kratos.Expression.IntegrationPointExpressionIO.Write(element_expression, Kratos. ``` ## 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 -advanced use cases. Following code snippet shows how to use bare ```Expressions```. +The underlying `Expression` instance of ```NodalExpression```, ```ConditionExpression``` and ```ElementExpression``` can be accessed directly, if necessary. The advantage of working +with bare ```Expression```s is that they are not bound to a specific model part or entity type, which means that they are completely interchangable. The following code snippet shows how to use bare ```Expression```s. ```python import KratosMultiphysics as Kratos model = Kratos.Model() From 172b51d44558be3c116a39acb2061b13fd4806ea Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:04:54 +0100 Subject: [PATCH 64/99] Update docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index 0bfcb7fa9ef4..f2fbf9c0d83b 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -8,7 +8,7 @@ summary: ## Introduction -```LiteralExpressionIO``` is used to represent literal values. Following literal types are supported: +```LiteralExpressionIO``` is used to represent literal values. The following literal types are supported: * int * double * array_1d From 03ac264f47c7215a4cb97e619c8b3501633d0ddf Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:05:12 +0100 Subject: [PATCH 65/99] Update docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index f2fbf9c0d83b..10707c6245fd 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -18,8 +18,7 @@ summary: * Vector * Matrix -This IO will create an expression with the specified literal for all entities. Since it is going to be constant for all entities, the literal will be stored only once for -all entities making the memory occupation the least. When the expression is evaluated, this stored literal will be read by all entities. +This IO will create an expression with the specified literal for all entities. ## Setting literal expressions From 073659087748abebacf2094ca56442faf23bf99b Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:05:41 +0100 Subject: [PATCH 66/99] Update docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index baff82d2a294..40f313d7541b 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -27,7 +27,6 @@ If the data type has static size (such as ```Kratos::Variable```, ```Kra ## Reading/Writing nodal values -Reading and writing to nodal values have the same interface within ```VariableExpressionIO```. The first argument shall be a `NodalExpression`, the second argumen shall be a ```Kratos::Variable``` and the last argument shall be a boolean indicating true if it is required to read from historical nodal data value container or false if it is required read from non-historical nodal data value container. In the case of **distributed memory** parallelized runs, a proper synchronization between ghost nodes are done when writing is executed. ```python import KratosMultiphysics as Kratos From 54755317bb0fa0ffb626bf4fab4f408cb6d9532a Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:05:56 +0100 Subject: [PATCH 67/99] Update docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index 10707c6245fd..65605b243bee 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -22,7 +22,7 @@ This IO will create an expression with the specified literal for all entities. ## Setting literal expressions -Following code snippet shows how to set literal expressions +The following code snippet shows how to set literal expressions ```python import KratosMultiphysics as Kratos model = Kratos.Model() From 78b8aba14ade2c0a25a093574ea343c003556ca5 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:06:32 +0100 Subject: [PATCH 68/99] Update docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index 65605b243bee..e24ce5e8caf3 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -47,7 +47,7 @@ for node in model_part.Nodes: ## 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 dynamic data types, it will create empty data sets [Such as Vector with size 0, Matrix with shape (0,0)**. The passed variable is only used to determine the entity data shape. Following code-snippet shows an example: +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: ```python import KratosMultiphysics as Kratos model = Kratos.Model() From 19f5579c2bcc0af04bacb04110f64b9c6ab2803c Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:07:51 +0100 Subject: [PATCH 69/99] Update docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- .../Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4094eb283294..ac64fec40f9e 100644 --- a/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md @@ -8,7 +8,7 @@ summary: ## Introduction -```NodalPositionExpressionIO``` allows writing and reading nodal positions of a given model part. This can be used on following configurations: +```NodalPositionExpressionIO``` allows writing and reading nodal positions of a given model part. This can be used on following the configurations: * Initial -> This uses the initial nodal position to read and write. * Current -> This uses the current position of the nodes to read and write. From 4e60c14a0bdb9d2044ad6102c6771889fa3783a8 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:08:38 +0100 Subject: [PATCH 70/99] Update docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- .../Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ac64fec40f9e..873820a35cf1 100644 --- a/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md @@ -9,8 +9,8 @@ summary: ## Introduction ```NodalPositionExpressionIO``` allows writing and reading nodal positions of a given model part. This can be used on following the configurations: -* Initial -> This uses the initial nodal position to read and write. -* Current -> This uses the current position of the nodes to read and write. +* Initial -> initial positions of the node +* Current -> positions of the nodes in the current configuration In the case of **distributed memory** parallelized runs, the reading will only read the nodal positions of the nodes in the local mesh, and the writing will write to local mesh nodes and will afterwards synchronize to update the ghost meshes. From 787c79cca7a655ca1df844f1ec8a45e822395d27 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:08:50 +0100 Subject: [PATCH 71/99] Update docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index 40f313d7541b..af47be949129 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -90,7 +90,6 @@ for condition in model_part.Conditions: ``` ## Reading/Writing element values -Reading and writing to element values have the same interface within ```VariableExpressionIO```. The first argument shall be a `ElementExpression` and the second argumen shall be a ```Kratos::Variable```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() From 0c1c235d4edddfe0b0cea5a2fcc6eafef73b1f6b Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:08:57 +0100 Subject: [PATCH 72/99] Update docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index af47be949129..ddac4fdd4b81 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -58,7 +58,6 @@ for node in model_part.Nodes: ``` ## Reading/Writing condition values -Reading and writing to condition values have the same interface within ```VariableExpressionIO```. The first argument shall be a `ConditionExpression` and the second argumen shall be a ```Kratos::Variable```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() From 75ca8d207389ff9b8ee546ac73b67508f8a1649b Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:09:12 +0100 Subject: [PATCH 73/99] Update docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index ddac4fdd4b81..4d62ae337eba 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -8,7 +8,7 @@ summary: ## Introduction -```VariableExpressionIO``` is used to read ```Kratos::Variable``` data in a data value container to a expression or write an expression data in to a ```Kratos::Variable``` in a specified data value container. The expression will only read or write to the entities (i.e. nodes/conditions/elements) in the local mesh. In the case of writing expression data to a variable in data value container, if it is used in ***distributed memory** parallelized environment, proper synchronization will be automatically done. Hence, all of these operations are compatible with **shared memory** and **distributed memory** parallelizations. +```VariableExpressionIO``` is used to read ```Kratos::Variable``` from a container to an expression vice versa. The expression will only read or write to the entities (i.e. nodes/conditions/elements) in the local mesh. If writing an expression to a variable in a container during an MPI run, synchronization between ranks is automatically done. ### Variable types From d51e94b2188d5ebfcf4c464c7a27a2e98f723ee0 Mon Sep 17 00:00:00 2001 From: Suneth Warnakulasuriya Date: Fri, 2 Feb 2024 22:09:30 +0100 Subject: [PATCH 74/99] Update docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Máté Kelemen <44344022+matekelemen@users.noreply.github.com> --- docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index 4d62ae337eba..3f054c551c8a 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -12,7 +12,7 @@ summary: ### Variable types -Following variable types are allowed to be read in or write to from an expression. +The following Kratos variable types are supported: * ```Kratos::Variable``` * ```Kratos::Variable``` * ```Kratos::Variable>``` From edd63e36db0c1d4f032222bd592a8ee110ef74f7 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Fri, 2 Feb 2024 22:14:17 +0100 Subject: [PATCH 75/99] revert changes --- .../General/Expression_Arithmetics.md | 22 +------- .../Expressions/General/Working_with_Numpy.md | 54 +------------------ 2 files changed, 4 insertions(+), 72 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index fbbc4008049b..67373b344558 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -1,9 +1,9 @@ --- title: Expression Arithmetics -keywords: +keywords: tags: [expression, arithmetics] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -51,22 +51,4 @@ Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.ACCELERATI for node in model_part.Nodes: print(node.GetValue(Kratos.ACCELERATION)) - -## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION -``` - -Expected output: -```bash -[3](0.833333,1.5,2.16667) -[3](2.83333,3.5,4.16667) -[3](4.83333,5.5,6.16667) - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ -_|\_\_| \__,_|\__|\___/ ____/ - 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/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index e96000b025d5..2c3831f13098 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -1,9 +1,9 @@ --- title: Working with Numpy -keywords: +keywords: tags: [numpy, scipy, expressions, variable expression io, carray expression io] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -36,21 +36,6 @@ numpy_nodal_expression = nodal_expression.Evaluate() # rest of the dimensions represent the dimensions of the entity data. In this case, VELOCITY have only three components, # it shows 3 as the last dimension. print("Shape of the numpy array = ", numpy_nodal_expression.shape) -## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION -``` - -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 @@ -90,24 +75,7 @@ Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.VELOCITY, for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") -## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION -``` - -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. @@ -155,22 +123,4 @@ Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.VELOCITY, for node in model_part.Nodes: velocity = node.GetValue(Kratos.VELOCITY) print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") -## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION -``` - -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. ``` From f4065d1844051d3c44535ae9ebafacc9c691c61a Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Fri, 2 Feb 2024 22:18:02 +0100 Subject: [PATCH 76/99] add exp arithmetics exp output --- .../General/Expression_Arithmetics.md | 21 +++++++++++++++++-- .../Expressions/General/Working_with_Numpy.md | 4 ++-- .../Kratos/Expressions/Utilities/Slice.md | 4 ++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index 67373b344558..07d10fe20bea 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -1,9 +1,9 @@ --- title: Expression Arithmetics -keywords: +keywords: tags: [expression, arithmetics] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -51,4 +51,21 @@ Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.ACCELERATI for node in model_part.Nodes: print(node.GetValue(Kratos.ACCELERATION)) +## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION +``` + +Expected output: +```bash +[3](0.833333,1.5,2.16667) +[3](2.83333,3.5,4.16667) +[3](4.83333,5.5,6.16667) + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ +_|\_\_| \__,_|\__|\___/ ____/ + 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/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index 2c3831f13098..a727d7ee61ba 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -1,9 +1,9 @@ --- title: Working with Numpy -keywords: +keywords: tags: [numpy, scipy, expressions, variable expression io, carray expression io] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/Utilities/Slice.md b/docs/pages/Kratos/Expressions/Utilities/Slice.md index 69edbe93c80b..1d481d2c14ba 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Slice.md +++ b/docs/pages/Kratos/Expressions/Utilities/Slice.md @@ -1,9 +1,9 @@ --- title: Slice -keywords: +keywords: tags: [slice, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction From b7de9eb97257a853d2575d906355b3aac126eac6 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Fri, 2 Feb 2024 22:34:47 +0100 Subject: [PATCH 77/99] minor --- docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index 07d10fe20bea..8e3bfc4c2bad 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -51,9 +51,7 @@ Kratos.Expression.VariableExpressionIO.Write(nodal_expression, Kratos.ACCELERATI for node in model_part.Nodes: print(node.GetValue(Kratos.ACCELERATION)) -## POST_PROCESS_PAGES_PYTHON_OUTPUT_GENERATION ``` - Expected output: ```bash [3](0.833333,1.5,2.16667) From 9a32385a9cc3472fd0c6eaa86673753b4302c3fd Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Fri, 2 Feb 2024 22:49:29 +0100 Subject: [PATCH 78/99] 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. +``` From c5599c98445a7244a283a66878caedba3add89ed Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Mon, 5 Feb 2024 16:52:13 +0100 Subject: [PATCH 79/99] fix cpp output order --- .../General/Expression_Arithmetics.md | 18 +++++------ .../Expressions/General/Working_with_Numpy.md | 22 ++++++------- .../Expressions/IOs/C_Array_Expression_IO.md | 17 +++++----- .../IOs/Domain_Size_Expression_IO.md | 8 ++--- .../IOs/Literal_Expression_Input.md | 32 +++++++++---------- .../IOs/Nodal_Position_Expression_IO.md | 26 ++++++++------- .../Expressions/IOs/Variable_Expression_IO.md | 20 ++++++------ 7 files changed, 72 insertions(+), 71 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index 8e3bfc4c2bad..c6efb312aaeb 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -1,9 +1,9 @@ --- title: Expression Arithmetics -keywords: +keywords: tags: [expression, arithmetics] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -54,16 +54,16 @@ for node in model_part.Nodes: ``` Expected output: ```bash -[3](0.833333,1.5,2.16667) -[3](2.83333,3.5,4.16667) -[3](4.83333,5.5,6.16667) - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +[3](0.833333,1.5,2.16667) +[3](2.83333,3.5,4.16667) +[3](4.83333,5.5,6.16667) ``` diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index 0ef77f1d1af0..56a824be4364 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -40,16 +40,16 @@ 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +Shape of the numpy array = (2, 3) ``` ## Reading from numpy arrays @@ -93,18 +93,19 @@ for node in model_part.Nodes: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +node id: 1, velocity: [1.0, 2.0, 3.0] +node id: 2, velocity: [3.0, 4.0, 5.0] ``` + ## 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. @@ -153,20 +154,19 @@ 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +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] ``` 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 ac30ce13277c..abca2715c6fd 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -44,17 +44,17 @@ 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +numpy array = [[1. 2. 3.] + [3. 4. 5.]] ``` ## Reading and writing to `Kratos::Vector` @@ -91,17 +91,17 @@ for node in model_part.Nodes: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +node_id: 1, velocity: [1.0, 2.0, 3.0] +node_id: 2, velocity: [4.0, 5.0, 6.0] ``` 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. @@ -128,15 +128,14 @@ print(vector) Expected output: ```bash -[6](1,2,3,3,4,5) | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +[6](1,2,3,3,4,5) ``` - 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 c5ca441dd94d..56654da4da35 100644 --- a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -41,16 +41,16 @@ print(shape) Expected output: ```bash -(1,) | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +(1,) ``` ## Using expressions without the model parts @@ -79,14 +79,14 @@ print(exp) Expected output: ```bash -(DoubleVec[]*2) | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +(DoubleVec[]*2) ``` diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index 2ff9cd3026f9..3789a3fa942a 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -47,17 +47,17 @@ for node in model_part.Nodes: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +node_id: 1, velocity = [1.0, 2.0, 3.0] +node_id: 2, velocity = [1.0, 2.0, 3.0] ``` ## Setting literal expression to zero @@ -94,19 +94,19 @@ for node in model_part.Nodes: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +PRESSURE before resetting: + [10. 20.] +node_id: 1, pressure = 10.0, temperature = 0.0 +node_id: 2, pressure = 20.0, temperature = 0.0 ``` ## Use cases @@ -145,19 +145,19 @@ for node in model_part.Nodes: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +PRESSURE before resetting: + [10. 20.] +node_id: 1, pressure = 10.0, temperature = 0.1 +node_id: 2, pressure = 20.0, temperature = 0.05 ``` ## Using expressions without the model parts @@ -188,15 +188,15 @@ for node in model_part.Nodes: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +node_id: 1, acceleration: [2.0,4.0,6.0] +node_id: 2, acceleration: [2.0,4.0,6.0] ``` 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 2029d1e465ea..807e1f836dbf 100644 --- a/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md @@ -54,23 +54,23 @@ for node in model_part.Nodes: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +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] ``` ## Using expressions without the model parts @@ -97,17 +97,19 @@ Kratos.Expression.NodalPositionExpressionIO.Output(model_part, Kratos.Configurat 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 -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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +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] ``` + diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index e94a6f9d5cdd..18030d3bb2e9 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -59,17 +59,17 @@ for node in model_part.Nodes: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +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] ``` ## Reading/Writing condition values @@ -105,16 +105,16 @@ for condition in model_part.Conditions: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +condition_id: 1, velocity: [1.0,2.0,3.0], acceleration: [2.0,4.0,6.0] ``` ## Reading/Writing element values @@ -151,16 +151,16 @@ for element in model_part.Elements: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +element_id: 1, velocity: [1.0,2.0,3.0], acceleration: [2.0,4.0,6.0] ``` ## Using expressions without the model parts @@ -194,15 +194,15 @@ for node in model_part.Nodes: 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 + Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-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. +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] ``` From 8988ac23c1e65a8feea5aa571c45cdcf48d35b40 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Mon, 5 Feb 2024 17:04:25 +0100 Subject: [PATCH 80/99] replace mathbb with mathbf --- .../pages/Kratos/Expressions/Utilities/Abs.md | 20 ++++++------- .../Kratos/Expressions/Utilities/EntityMax.md | 14 +++++----- .../Kratos/Expressions/Utilities/EntityMin.md | 14 +++++----- .../Kratos/Expressions/Utilities/EntitySum.md | 14 +++++----- .../Expressions/Utilities/InnerProduct.md | 14 +++++----- .../Kratos/Expressions/Utilities/NormInf.md | 14 +++++----- .../Kratos/Expressions/Utilities/NormL2.md | 14 +++++----- .../Kratos/Expressions/Utilities/NormP.md | 14 +++++----- .../pages/Kratos/Expressions/Utilities/Pow.md | 28 +++++++++---------- .../Kratos/Expressions/Utilities/Scale.md | 22 +++++++-------- 10 files changed, 84 insertions(+), 84 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Abs.md b/docs/pages/Kratos/Expressions/Utilities/Abs.md index 9797335d27ba..451433ec603d 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Abs.md +++ b/docs/pages/Kratos/Expressions/Utilities/Abs.md @@ -1,16 +1,16 @@ --- title: Abs -keywords: +keywords: tags: [abs, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This computes absolute value of each component of the given expression. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. +This computes absolute value of each component of the given expression. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. -

$$ Abs\left(\underline{\mathbb{u}}\right) = \left\lbrace \left|u_{ij}\right|, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+

$$ Abs\left(\underline{\mathbf{u}}\right) = \left\lbrace \left|u_{ij}\right|, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

## Use cases @@ -54,9 +54,9 @@ Expected output: 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 @@ -104,9 +104,9 @@ Expected output: 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 diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md index 4536c76b5347..e7ba6f7012ec 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md @@ -1,16 +1,16 @@ --- title: EntityMax -keywords: +keywords: tags: [entity max, max, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This get the maximum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. +This get the maximum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. -

$$ EntityMax\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \max_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntityMax\left(\underline{\mathbf{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \max_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases Following code snippet illustrates how to use ```EntityMax```. @@ -50,9 +50,9 @@ Expected output: 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 diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md index 11319a07cabc..a1d458c2344a 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md @@ -1,15 +1,15 @@ --- title: EntityMin -keywords: +keywords: tags: [entity min, min, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This get the minimum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. +This get the minimum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. -

$$ EntityMin\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \min_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntityMin\left(\underline{\mathbf{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \min_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases Following code snippet illustrates how to use ```EntityMin```. @@ -49,9 +49,9 @@ Expected output: 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 diff --git a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md index 1c73ad4f4cf5..d6c573a186a6 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md @@ -1,15 +1,15 @@ --- title: EntitySum -keywords: +keywords: tags: [entity sum, sum, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This get the sum of value from each component in each entity. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. +This get the sum of value from each component in each entity. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. -

$$ EntitySum\left(\underline{\mathbb{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \sum_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntitySum\left(\underline{\mathbf{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \sum_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases Following code snippet illustrates how to use ```EntitySum```. @@ -49,9 +49,9 @@ Expected output: 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 diff --git a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md index 0b44ee410dcb..93019732ea18 100644 --- a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md +++ b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md @@ -1,17 +1,17 @@ --- title: InnerProduct -keywords: +keywords: tags: [inner product, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise inner product between two expressions. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The second input expression is given by $$\underline{\mathbb{v}} = \left\lbrace v_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +Computes component wise inner product between two expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The second input expression is given by $$\underline{\mathbf{v}} = \left\lbrace v_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. **Both expressions should have the same shape** -

$$ InnerProduct\left(\underline{\mathbb{u}}, \underline{\mathbb{v}}\right) = \sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)}u_{ij} \times v_{ij}$$

+

$$ InnerProduct\left(\underline{\mathbf{u}}, \underline{\mathbf{v}}\right) = \sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)}u_{ij} \times v_{ij}$$

## Use cases Following code snippet illustrates how to use ```InnerProduct```. @@ -40,9 +40,9 @@ print(Kratos.Expression.Utils.InnerProduct(nodal_expression, nodal_expression)) 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 diff --git a/docs/pages/Kratos/Expressions/Utilities/NormInf.md b/docs/pages/Kratos/Expressions/Utilities/NormInf.md index 91859d7e4adc..046187792a66 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormInf.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormInf.md @@ -1,14 +1,14 @@ --- title: NormInf -keywords: +keywords: tags: [inf norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise inf norm in expressions. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +Computes component wise inf norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. -

$$ NormInf\left(\underline{\mathbb{u}}\right) = \max_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} \left|u_{ij}\right|$$

+

$$ NormInf\left(\underline{\mathbf{u}}\right) = \max_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} \left|u_{ij}\right|$$

## Use cases Following code snippet illustrates how to use ```NormInf```. @@ -38,9 +38,9 @@ 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 diff --git a/docs/pages/Kratos/Expressions/Utilities/NormL2.md b/docs/pages/Kratos/Expressions/Utilities/NormL2.md index 66cd91ce32ba..f6f79b9d4031 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormL2.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormL2.md @@ -1,14 +1,14 @@ --- title: NormL2 -keywords: +keywords: tags: [l2 norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise L2 norm in expressions. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +Computes component wise L2 norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. -

$$ NormL2\left(\underline{\mathbb{u}}\right) = \sqrt{\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {u_{ij}^2}}$$

+

$$ NormL2\left(\underline{\mathbf{u}}\right) = \sqrt{\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {u_{ij}^2}}$$

## Use cases Following code snippet illustrates how to use ```NormL2```. @@ -37,9 +37,9 @@ print(Kratos.Expression.Utils.NormL2(nodal_expression)) 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 diff --git a/docs/pages/Kratos/Expressions/Utilities/NormP.md b/docs/pages/Kratos/Expressions/Utilities/NormP.md index de2ecc0daab9..9542a982c3f1 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormP.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormP.md @@ -1,14 +1,14 @@ --- title: NormP -keywords: +keywords: tags: [p norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise p norm in expressions. Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +Computes component wise p norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. -

$$ NormP\left(\underline{\mathbb{u}}, P\right) = \left({\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {\left|u_{ij}\right|^P}}\right)^{1/P}$$

+

$$ NormP\left(\underline{\mathbf{u}}, P\right) = \left({\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {\left|u_{ij}\right|^P}}\right)^{1/P}$$

## Use cases Following code snippet illustrates how to use ```NormL2```. @@ -37,9 +37,9 @@ print(Kratos.Expression.Utils.NormP(nodal_expression, 3)) 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 diff --git a/docs/pages/Kratos/Expressions/Utilities/Pow.md b/docs/pages/Kratos/Expressions/Utilities/Pow.md index 4f87d7890f94..fb39301420e0 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Pow.md +++ b/docs/pages/Kratos/Expressions/Utilities/Pow.md @@ -1,9 +1,9 @@ --- title: Pow -keywords: +keywords: tags: [pow, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -13,20 +13,20 @@ This raises value of each component to the specified power given by either a flo 2. If it is raised to power given by a expression and the expression has the same shape as the input expression, then each component is raised to power by the expressions same component given by the second expression. 3. If it is raised to power given by a expression and the expression has shape of a scalar expression, then each component is raised to power by the second expression's entity value. -Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. +Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. Case 1: -

$$ Pow\left(\underline{\mathbb{u}}, P\right) = \left\lbrace u_{ij}^P, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+

$$ Pow\left(\underline{\mathbf{u}}, P\right) = \left\lbrace u_{ij}^P, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 2: -The expression with power is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ -

$$ Pow\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}^{p_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+The expression with power is illustrated by $$\underline{\mathbf{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ +

$$ Pow\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}^{p_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 3: -The expression with power is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ -

$$ Pow\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}^{p_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+The expression with power is illustrated by $$\underline{\mathbf{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ +

$$ Pow\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}^{p_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

## Use cases @@ -69,9 +69,9 @@ Expected output: 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 @@ -119,9 +119,9 @@ Expected output: 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 diff --git a/docs/pages/Kratos/Expressions/Utilities/Scale.md b/docs/pages/Kratos/Expressions/Utilities/Scale.md index e37f79267be1..e8354ed8e167 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Scale.md +++ b/docs/pages/Kratos/Expressions/Utilities/Scale.md @@ -1,9 +1,9 @@ --- title: Scale -keywords: +keywords: tags: [scale, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -13,20 +13,20 @@ This scales value of each component to the specified power given by either a flo 2. If it is scaled given by a expression and the expression has the same shape as the input expression, then each component is raised to power by the expressions same component given by the second expression. 3. If it is scaled given by a expression and the expression has shape of a scalar expression, then each component is raised to power by the second expression's entity value. -Assume the input expression is given by $$\underline{\mathbb{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. +Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. Case 1: -

$$ Scale\left(\underline{\mathbb{u}}, P\right) = \left\lbrace u_{ij}\times P, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+

$$ Scale\left(\underline{\mathbf{u}}, P\right) = \left\lbrace u_{ij}\times P, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 2: -The expression with scaling is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ -

$$ Scale\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}\times{p_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+The expression with scaling is illustrated by $$\underline{\mathbf{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ +

$$ Scale\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}\times{p_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 3: -The expression with scaling is illustrated by $$\underline{\mathbb{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ -

$$ Scale\left(\underline{\mathbb{u}}, \underline{\mathbb{P}}\right) = \left\lbrace u_{ij}\times{p_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+The expression with scaling is illustrated by $$\underline{\mathbf{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ +

$$ Scale\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}\times{p_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

## Use cases Following code snippet illustrates how to use ```Scale```. @@ -66,9 +66,9 @@ Expected output: 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 From a7d7da1f9ca0c6fcc62c41384a31286ba47b3488 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 08:58:55 +0100 Subject: [PATCH 81/99] minor --- docs/pages/Kratos/Documentation_Guide/How_Tos/Testing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/Kratos/Documentation_Guide/How_Tos/Testing.md b/docs/pages/Kratos/Documentation_Guide/How_Tos/Testing.md index 5ad490fd3764..4821017bfd01 100644 --- a/docs/pages/Kratos/Documentation_Guide/How_Tos/Testing.md +++ b/docs/pages/Kratos/Documentation_Guide/How_Tos/Testing.md @@ -1,9 +1,9 @@ --- title: Documentation testing and updating -keywords: +keywords: tags: [Testing.md] sidebar: documentation_guide -summary: +summary: --- From 2821a6c81e8b9d0defedd893ac8ffe065820ad3c Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:05:28 +0100 Subject: [PATCH 82/99] update abs --- .../pages/Kratos/Expressions/Utilities/Abs.md | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Abs.md b/docs/pages/Kratos/Expressions/Utilities/Abs.md index 451433ec603d..811c5403bec9 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Abs.md +++ b/docs/pages/Kratos/Expressions/Utilities/Abs.md @@ -1,21 +1,20 @@ --- title: Abs -keywords: +keywords: tags: [abs, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This computes absolute value of each component of the given expression. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. +This computes the componentwise absolute value of the given expression. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The Following equation illustrates the formulation of the resulting expression.

$$ Abs\left(\underline{\mathbf{u}}\right) = \left\lbrace \left|u_{ij}\right|, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

## Use cases ### Using to compute absolute values -Following code snippet illustrates how to use ```Abs```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -50,23 +49,23 @@ for node in model_part.Nodes: ``` 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] +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 494037 +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] ``` ### Using to compute entity wise inf-norm -Following code snippet illustrates how to use ```Abs``` to compute the entity wise inf-norm. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -100,17 +99,18 @@ for node in model_part.Nodes: ``` 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 +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 494090 +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 ``` From 39f1f16f2e0cece3aa52fe286f48679a1bd916ca Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:11:06 +0100 Subject: [PATCH 83/99] fix collapse --- .../Kratos/Expressions/Utilities/Collapse.md | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Collapse.md b/docs/pages/Kratos/Expressions/Utilities/Collapse.md index afd53237a202..5ccbfa0b3844 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Collapse.md +++ b/docs/pages/Kratos/Expressions/Utilities/Collapse.md @@ -7,13 +7,13 @@ summary: --- ## Introduction -```Collapse``` method is used to collapse the lazy expression tree. **This is useful when the lazy expression tree is larger which occupies or exceeds the RAM +```Collapse``` method is used to collapse the lazy expression tree. **This is useful when the lazy expression tree is larger which may occupy or exceeds the RAM limitations.**. -Using this method on an expression which will always result in an expression having the same shape, having the same evaluated values. But the resulting expression will be not having the tree structure since it is collapsed. +The resulting expression retains the original's shape, having the same evaluated values. But the resulting expression will not be having the tree structure since it is collapsed. ## Use case -The max depth of an expression can be checked to identify the max depth of the lazy expression as explained in the following code snippet. It also explains how to collapse the tree hierarchy of the lazy expressions. +The following example shows how to compute the maximum depth of the expression hierarchy, and collapse it down to a single array. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -40,19 +40,25 @@ nodal_expression += 1 print(nodal_expression.GetMaxDepth()) collapsed_exp = Kratos.Expression.Utils.Collapse(nodal_expression) + +# Destroy the original expression to free up memory +del nodal_expression + print(collapsed_exp.GetMaxDepth()) ``` + Expected output: -```bash -3 -1 +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 499448 +3 +1 ``` From 4956e08f4069f694c9d3b879bb54d898c530bbb0 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:24:05 +0100 Subject: [PATCH 84/99] fix comb --- .../Kratos/Expressions/Utilities/Comb.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Comb.md b/docs/pages/Kratos/Expressions/Utilities/Comb.md index 2a8def76f439..b4efe020e29d 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Comb.md +++ b/docs/pages/Kratos/Expressions/Utilities/Comb.md @@ -7,10 +7,9 @@ summary: --- ## Introduction -This allows combining multiple expressions in to one expression. **The number of entities on all the combining expressions should have the same.** +`Comb` merges multiple expressions in to one. **All input expressions must have the same number of entities.** Example: -All provided expressions in the list_of_expression. ``` For example, let the list_of_expression contain the following expressions: exp_list[0] = data{1, 2, 3} with 3 items, and item shape = [] @@ -21,10 +20,9 @@ The resulting expression has item shape [3] with 4 items: output_exp = [1, 4, 5, -1, 2, 6, 7, -1, 3, 8, 9, -1] --------- -------- -------- ``` -This creates a lazy expression, hence it has a constant cost complexity irrespective of the data size (The expression won't be evaluated unless @ref Expression::Evaluate is called). +The expression won't be evaluated unless `Expression::Evaluate` is called. ## Use case -Following code snippet illustrates how the above example can be replicated. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -55,18 +53,20 @@ combined_exp = Kratos.Expression.Utils.Comb([p_exp, u_exp]) print(combined_exp.Evaluate()) ``` + Expected output: -```bash -[[ 1. 4. 5. -1.] - [ 2. 6. 7. -1.] - [ 3. 8. 9. -1.]] - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 502917 +[[ 1. 4. 5. -1.] + [ 2. 6. 7. -1.] + [ 3. 8. 9. -1.]] ``` From f9f5f1ab782879ae647d028f3182938ac9c2e183 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:24:13 +0100 Subject: [PATCH 85/99] fix entity max --- .../Kratos/Expressions/Utilities/EntityMax.md | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md index e7ba6f7012ec..9a20330034c7 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMax.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMax.md @@ -1,19 +1,18 @@ --- title: EntityMax -keywords: +keywords: tags: [entity max, max, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This get the maximum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. +`EntityMax` finds the largest component of each entity. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The result is always a scalar expression. -

$$ EntityMax\left(\underline{\mathbf{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \max_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntityMax\left(\underline{\mathbf{u}}\right) = \left\lbrace v_i | \quad v_i = \max_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases -Following code snippet illustrates how to use ```EntityMax```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -45,18 +44,20 @@ 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 = -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 - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 506403 +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 ``` From 4dca0e6f282fa49877a9d4e5f003af32a4d76661 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:26:21 +0100 Subject: [PATCH 86/99] fix entity min --- .../Kratos/Expressions/Utilities/EntityMin.md | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md index a1d458c2344a..0638be416b0c 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntityMin.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntityMin.md @@ -1,18 +1,17 @@ --- title: EntityMin -keywords: +keywords: tags: [entity min, min, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This get the minimum value from each component in each entity. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. +`EntityMin` finds the smallest component of each entity. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The result is always a scalar expression. -

$$ EntityMin\left(\underline{\mathbf{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \min_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntityMin\left(\underline{\mathbf{u}}\right) = \left\lbrace v_i | \quad v_i = \min_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases -Following code snippet illustrates how to use ```EntityMin```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -44,18 +43,20 @@ 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 - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 508605 +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 ``` From b026471abb0487f4d19281b1132d30aaf95c1ae6 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:30:07 +0100 Subject: [PATCH 87/99] fix entity sum --- .../Kratos/Expressions/Utilities/EntitySum.md | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md index d6c573a186a6..78ebdc11a76d 100644 --- a/docs/pages/Kratos/Expressions/Utilities/EntitySum.md +++ b/docs/pages/Kratos/Expressions/Utilities/EntitySum.md @@ -1,18 +1,17 @@ --- title: EntitySum -keywords: +keywords: tags: [entity sum, sum, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This get the sum of value from each component in each entity. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression which is always a scalar expression. +`EntitySum` computes the sum of the components of each entity. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The result is always a scalar expression. -

$$ EntitySum\left(\underline{\mathbf{u}}\right) = \left\lbrace v_i, \text{where} \quad v_i = \sum_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

+

$$ EntitySum\left(\underline{\mathbf{u}}\right) = \left\lbrace v_i | \quad v_i = \sum_{j\in\left[0, N\right)} {u_{ij}} \quad \forall i\in\left[0, M\right)\right\rbrace$$

## Use cases -Following code snippet illustrates how to use ```EntitySum```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -44,18 +43,20 @@ 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 = -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 - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 511541 +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 ``` From 1ee6f767f0b3b5779d99bdc9cde485ca4f6af8bc Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:32:32 +0100 Subject: [PATCH 88/99] fix inner product --- .../Kratos/Expressions/Utilities/InnerProduct.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md index 93019732ea18..130d33b546f6 100644 --- a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md +++ b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md @@ -7,14 +7,13 @@ summary: --- ## Introduction -Computes component wise inner product between two expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The second input expression is given by $$\underline{\mathbf{v}} = \left\lbrace v_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +Computes component wise inner product between two expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The second input expression is given by $$\underline{\mathbf{v}} = \left\lbrace v_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. -**Both expressions should have the same shape** +**Both expressions should have the same shape.**

$$ InnerProduct\left(\underline{\mathbf{u}}, \underline{\mathbf{v}}\right) = \sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)}u_{ij} \times v_{ij}$$

## Use cases -Following code snippet illustrates how to use ```InnerProduct```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -37,16 +36,18 @@ Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, F print(Kratos.Expression.Utils.InnerProduct(nodal_expression, nodal_expression)) ``` + Expected output: -```bash -285.0 +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 513031 +285.0 ``` From e7e61da5181f1727cda570e34a78f7405eae60a0 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:34:10 +0100 Subject: [PATCH 89/99] fix inner product --- docs/pages/Kratos/Expressions/Utilities/InnerProduct.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md index 130d33b546f6..c56a1bd6af6a 100644 --- a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md +++ b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md @@ -1,9 +1,9 @@ --- title: InnerProduct -keywords: +keywords: tags: [inner product, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction From cfc8b2706ba2edfde83c56eb926038efa637d304 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:34:17 +0100 Subject: [PATCH 90/99] fix norm inf --- .../Kratos/Expressions/Utilities/NormInf.md | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/NormInf.md b/docs/pages/Kratos/Expressions/Utilities/NormInf.md index 046187792a66..df78a36b6cd1 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormInf.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormInf.md @@ -1,17 +1,16 @@ --- title: NormInf -keywords: +keywords: tags: [inf norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise inf norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +Computes component wise inf norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity.

$$ NormInf\left(\underline{\mathbf{u}}\right) = \max_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} \left|u_{ij}\right|$$

## Use cases -Following code snippet illustrates how to use ```NormInf```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -36,15 +35,17 @@ print(Kratos.Expression.Utils.NormInf(nodal_expression)) ``` Expected output: -```bash -9.0 - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 514980 +9.0 ``` + From 23fe1ca4d045c9faa790c072b1d2e3b9ea66d1f6 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:35:22 +0100 Subject: [PATCH 91/99] norm l2 fixing --- .../Kratos/Expressions/Utilities/NormL2.md | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/NormL2.md b/docs/pages/Kratos/Expressions/Utilities/NormL2.md index f6f79b9d4031..924f34841108 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormL2.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormL2.md @@ -1,17 +1,16 @@ --- title: NormL2 -keywords: +keywords: tags: [l2 norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise L2 norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +Computes component wise L2 norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity.

$$ NormL2\left(\underline{\mathbf{u}}\right) = \sqrt{\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {u_{ij}^2}}$$

## Use cases -Following code snippet illustrates how to use ```NormL2```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -34,16 +33,18 @@ Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, F print(Kratos.Expression.Utils.NormL2(nodal_expression)) ``` + Expected output: -```bash -16.881943016134134 - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 516520 +16.881943016134134 ``` From 578198db1c25e0832760ae36ef371f23fc63f98f Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:41:11 +0100 Subject: [PATCH 92/99] fix p norm --- docs/pages/Kratos/Expressions/Utilities/NormP.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/NormP.md b/docs/pages/Kratos/Expressions/Utilities/NormP.md index 9542a982c3f1..a77688b17fe4 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormP.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormP.md @@ -1,17 +1,15 @@ --- title: NormP -keywords: +keywords: tags: [p norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise p norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +Computes component wise p norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity.

$$ NormP\left(\underline{\mathbf{u}}, P\right) = \left({\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {\left|u_{ij}\right|^P}}\right)^{1/P}$$

- ## Use cases -Following code snippet illustrates how to use ```NormL2```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -34,16 +32,18 @@ Kratos.Expression.VariableExpressionIO.Read(nodal_expression, Kratos.VELOCITY, F print(Kratos.Expression.Utils.NormP(nodal_expression, 3)) ``` + Expected output: -```bash -12.651489979526238 +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 517572 +12.651489979526238 ``` From da51ebb2983cd8b4830aad023e3badaa0ce8202f Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:42:05 +0100 Subject: [PATCH 93/99] minor --- .../Kratos/Expressions/Utilities/InnerProduct.md | 6 +++--- docs/pages/Kratos/Expressions/Utilities/NormInf.md | 14 +++++++------- docs/pages/Kratos/Expressions/Utilities/NormL2.md | 14 +++++++------- docs/pages/Kratos/Expressions/Utilities/NormP.md | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md index c56a1bd6af6a..22bdd7385e88 100644 --- a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md +++ b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md @@ -1,13 +1,13 @@ --- title: InnerProduct -keywords: +keywords: tags: [inner product, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise inner product between two expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The second input expression is given by $$\underline{\mathbf{v}} = \left\lbrace v_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +`InnerProduct `computes component wise inner product between two expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. The second input expression is given by $$\underline{\mathbf{v}} = \left\lbrace v_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. **Both expressions should have the same shape.** diff --git a/docs/pages/Kratos/Expressions/Utilities/NormInf.md b/docs/pages/Kratos/Expressions/Utilities/NormInf.md index df78a36b6cd1..24d17e11bffc 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormInf.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormInf.md @@ -1,12 +1,12 @@ --- title: NormInf -keywords: +keywords: tags: [inf norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise inf norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +`NormInf` computes component wise inf norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity.

$$ NormInf\left(\underline{\mathbf{u}}\right) = \max_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} \left|u_{ij}\right|$$

@@ -36,16 +36,16 @@ print(Kratos.Expression.Utils.NormInf(nodal_expression)) Expected output: ```console - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. -Process Id: 514980 +Process Id: 514980 9.0 ``` diff --git a/docs/pages/Kratos/Expressions/Utilities/NormL2.md b/docs/pages/Kratos/Expressions/Utilities/NormL2.md index 924f34841108..978e8240cc74 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormL2.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormL2.md @@ -1,12 +1,12 @@ --- title: NormL2 -keywords: +keywords: tags: [l2 norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise L2 norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +`NormL2` computes component wise L2 norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity.

$$ NormL2\left(\underline{\mathbf{u}}\right) = \sqrt{\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {u_{ij}^2}}$$

@@ -36,15 +36,15 @@ print(Kratos.Expression.Utils.NormL2(nodal_expression)) Expected output: ```console - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. -Process Id: 516520 +Process Id: 516520 16.881943016134134 ``` diff --git a/docs/pages/Kratos/Expressions/Utilities/NormP.md b/docs/pages/Kratos/Expressions/Utilities/NormP.md index a77688b17fe4..06543213a733 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormP.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormP.md @@ -1,12 +1,12 @@ --- title: NormP -keywords: +keywords: tags: [p norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -Computes component wise p norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. +`NormP` computes component wise p norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity.

$$ NormP\left(\underline{\mathbf{u}}, P\right) = \left({\sum_{(i,j)\in\left[0, M\right)\times\left[0,N\right)} {\left|u_{ij}\right|^P}}\right)^{1/P}$$

## Use cases From e0f0ef205716eb16f8b6497dc1d754892b9e116f Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:47:12 +0100 Subject: [PATCH 94/99] fix pow --- .../Expressions/Utilities/InnerProduct.md | 4 +- .../Kratos/Expressions/Utilities/NormInf.md | 4 +- .../Kratos/Expressions/Utilities/NormL2.md | 4 +- .../Kratos/Expressions/Utilities/NormP.md | 4 +- .../pages/Kratos/Expressions/Utilities/Pow.md | 40 +++++++++---------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md index 22bdd7385e88..f12d4dea0798 100644 --- a/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md +++ b/docs/pages/Kratos/Expressions/Utilities/InnerProduct.md @@ -1,9 +1,9 @@ --- title: InnerProduct -keywords: +keywords: tags: [inner product, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/Utilities/NormInf.md b/docs/pages/Kratos/Expressions/Utilities/NormInf.md index 24d17e11bffc..8867e482e53a 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormInf.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormInf.md @@ -1,9 +1,9 @@ --- title: NormInf -keywords: +keywords: tags: [inf norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction `NormInf` computes component wise inf norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. diff --git a/docs/pages/Kratos/Expressions/Utilities/NormL2.md b/docs/pages/Kratos/Expressions/Utilities/NormL2.md index 978e8240cc74..33b5eb752e73 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormL2.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormL2.md @@ -1,9 +1,9 @@ --- title: NormL2 -keywords: +keywords: tags: [l2 norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction `NormL2` computes component wise L2 norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. diff --git a/docs/pages/Kratos/Expressions/Utilities/NormP.md b/docs/pages/Kratos/Expressions/Utilities/NormP.md index 06543213a733..4a263846596e 100644 --- a/docs/pages/Kratos/Expressions/Utilities/NormP.md +++ b/docs/pages/Kratos/Expressions/Utilities/NormP.md @@ -1,9 +1,9 @@ --- title: NormP -keywords: +keywords: tags: [p norm, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction `NormP` computes component wise p norm in expressions. Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. diff --git a/docs/pages/Kratos/Expressions/Utilities/Pow.md b/docs/pages/Kratos/Expressions/Utilities/Pow.md index fb39301420e0..d910eccdb55e 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Pow.md +++ b/docs/pages/Kratos/Expressions/Utilities/Pow.md @@ -1,37 +1,37 @@ --- title: Pow -keywords: +keywords: tags: [pow, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This raises value of each component to the specified power given by either a floating value or as an expression. +`Pos` raises value of each component to the specified power given by either a floating value or as an expression. 1. If it is raised to power given by a scalar, then all the components are raised to that power. 2. If it is raised to power given by a expression and the expression has the same shape as the input expression, then each component is raised to power by the expressions same component given by the second expression. 3. If it is raised to power given by a expression and the expression has shape of a scalar expression, then each component is raised to power by the second expression's entity value. -Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. +Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equations illustrate the formulation of the resulting expression for each case. Case 1: +

$$ Pow\left(\underline{\mathbf{u}}, P\right) = \left\lbrace u_{ij}^P, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 2: -The expression with power is illustrated by $$\underline{\mathbf{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ -

$$ Pow\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}^{p_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

+The expression with power is given by $$\underline{\mathbf{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ +

$$ Pow\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}^{p_{ij}} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 3: -The expression with power is illustrated by $$\underline{\mathbf{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ +The expression with power is given by $$\underline{\mathbf{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$

$$ Pow\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}^{p_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

## Use cases ### Using to raise to power -Following code snippet illustrates how to use ```Pow```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -65,23 +65,22 @@ for node in model_part.Nodes: ``` 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] +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 525614 +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] ``` - ### Using to compute entity wise L2 norm -Following code snippet illustrates how to use ```Pow``` to compute the entity wise L2 norm. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -115,17 +114,18 @@ for node in model_part.Nodes: ``` 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 +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 525646 +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 ``` From 6a8728c69d233a38aab0497331c7942a4284b68b Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:48:16 +0100 Subject: [PATCH 95/99] fix reshape --- .../Kratos/Expressions/Utilities/Reshape.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Reshape.md b/docs/pages/Kratos/Expressions/Utilities/Reshape.md index e75573832609..9bdfc18844dc 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Reshape.md +++ b/docs/pages/Kratos/Expressions/Utilities/Reshape.md @@ -7,10 +7,9 @@ summary: --- ## Introduction -This method allows to reshape any expression to another new shape. **The total number of components in the new shape should be same as the original shape's total number of components.** +`Reshape` is used to reshape any expression to another new shape. **The total number of components in the new shape should be same as the original shape's total number of components.** ## Use case -Following example showcases one of the use case of ```Reshape``` ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -46,22 +45,23 @@ print(reshaped_exp.Evaluate()) ``` Expected output: -```bash -[[[ 1. 4.] - [ 5. -1.]] - - [[ 2. 6.] - [ 7. -1.]] - - [[ 3. 8.] - [ 9. -1.]]] +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 528742 +[[[ 1. 4.] + [ 5. -1.]] + + [[ 2. 6.] + [ 7. -1.]] + + [[ 3. 8.] + [ 9. -1.]]] ``` From 996c08971c0fc7027c3bd297e7b5b1d4aaa7e685 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:56:02 +0100 Subject: [PATCH 96/99] fix scale --- .../pages/Kratos/Expressions/Utilities/Pow.md | 14 ++++----- .../Kratos/Expressions/Utilities/Scale.md | 31 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/docs/pages/Kratos/Expressions/Utilities/Pow.md b/docs/pages/Kratos/Expressions/Utilities/Pow.md index d910eccdb55e..4e07361c77a9 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Pow.md +++ b/docs/pages/Kratos/Expressions/Utilities/Pow.md @@ -8,12 +8,12 @@ summary: ## Introduction -`Pos` raises value of each component to the specified power given by either a floating value or as an expression. -1. If it is raised to power given by a scalar, then all the components are raised to that power. -2. If it is raised to power given by a expression and the expression has the same shape as the input expression, then each component is raised to power by the expressions same component given by the second expression. -3. If it is raised to power given by a expression and the expression has shape of a scalar expression, then each component is raised to power by the second expression's entity value. +`Pow` raises value of each component to the specified power given by either a floating value or as an expression. +1. If it is raised to power by a scalar, then all the components are raised to that power. +2. If it is raised to power by an expression and that expression has the same shape as the first expression, then each component of the first expression is raised to power by the second expression's same component. +3. If it is raised to power by an expression and that expression has shape of a scalar expression, then each component of the first expression is raised to power by the second expression's entity value. -Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equations illustrate the formulation of the resulting expression for each case. +Assume the first expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equations illustrate the formulations of the resulting expression for each case. Case 1: @@ -21,12 +21,12 @@ Case 1: Case 2: -The expression with power is given by $$\underline{\mathbf{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ +The expression with power (i.e. second expression) is given by $$\underline{\mathbf{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

$$ Pow\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}^{p_{ij}} | \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 3: -The expression with power is given by $$\underline{\mathbf{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ +The expression with power (i.e. second expression) is given by $$\underline{\mathbf{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$

$$ Pow\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}^{p_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

## Use cases diff --git a/docs/pages/Kratos/Expressions/Utilities/Scale.md b/docs/pages/Kratos/Expressions/Utilities/Scale.md index e8354ed8e167..ffedee0e9dd5 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Scale.md +++ b/docs/pages/Kratos/Expressions/Utilities/Scale.md @@ -1,35 +1,34 @@ --- title: Scale -keywords: +keywords: tags: [scale, expression] sidebar: kratos_expressions -summary: +summary: --- ## Introduction -This scales value of each component to the specified power given by either a floating value or as an expression. -1. If it is scaled given by a scalar, then all the components are raised to that power. -2. If it is scaled given by a expression and the expression has the same shape as the input expression, then each component is raised to power by the expressions same component given by the second expression. -3. If it is scaled given by a expression and the expression has shape of a scalar expression, then each component is raised to power by the second expression's entity value. +`Scale` scales value of each component to the specified value given by either a floating value or as an expression. +1. If it is scaled by a floating value, then all the components are scaled with the same. +2. If it is scaled by an expression and that expression has the same shape as the first expression, then each component of the first expression is scaled by the second expression's corresponding same component value. +3. If it is scaled by an expression and that expression has shape of a scalar expression, then each component of the first expression is scaled by the second expression's entity value. -Assume the input expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equation illustrates the formulation of the resulting expression. +Assume the first expression is given by $$\underline{\mathbf{u}} = \left\lbrace u_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ where the $$i^{th}$$ entity's $$j^{th}$$ component is represented by $$u_{ij}$$ with $$i\in \left[0, M\right)$$ for each entity and $$j\in \left[0, N\right)$$ for each component in each entity. Following equations illustrate the formulations of the resulting expression. Case 1:

$$ Scale\left(\underline{\mathbf{u}}, P\right) = \left\lbrace u_{ij}\times P, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 2: -The expression with scaling is illustrated by $$\underline{\mathbf{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$ +The expression with scaling (i.e. second expression) is given by $$\underline{\mathbf{P}} = \left\lbrace p_{ij}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

$$ Scale\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}\times{p_{ij}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

Case 3: -The expression with scaling is illustrated by $$\underline{\mathbf{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$ +The expression with scaling (i.e. second expression) is given by $$\underline{\mathbf{P}} = \left\lbrace p_{i}, \forall i\in\left[0, M\right)\right\rbrace$$

$$ Scale\left(\underline{\mathbf{u}}, \underline{\mathbf{P}}\right) = \left\lbrace u_{ij}\times{p_{i}}, \forall (i,j)\in\left[0, M\right)\times\left[0, N\right)\right\rbrace$$

## Use cases -Following code snippet illustrates how to use ```Scale```. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -61,18 +60,20 @@ 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 = [-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] +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 534910 +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] ``` From 2f7b511d60501fa4ec90f2b67bb01a4117c441e6 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:56:08 +0100 Subject: [PATCH 97/99] minor --- .../Kratos/Expressions/General/Expression_Arithmetics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index c6efb312aaeb..ca347ac9259f 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -1,9 +1,9 @@ --- title: Expression Arithmetics -keywords: +keywords: tags: [expression, arithmetics] sidebar: kratos_expressions -summary: +summary: --- ## Introduction From b7248a59ee717c2e8cc17f84d08ed2e20a881083 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:57:21 +0100 Subject: [PATCH 98/99] fix bash with console --- .../General/Expression_Arithmetics.md | 6 ++-- .../Expressions/General/Working_with_Numpy.md | 28 +++++++-------- .../Expressions/IOs/C_Array_Expression_IO.md | 28 +++++++-------- .../IOs/Domain_Size_Expression_IO.md | 20 +++++------ .../IOs/Literal_Expression_Input.md | 36 +++++++++---------- .../IOs/Nodal_Position_Expression_IO.md | 20 +++++------ .../Expressions/IOs/Variable_Expression_IO.md | 36 +++++++++---------- 7 files changed, 87 insertions(+), 87 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index ca347ac9259f..feb3146459da 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -1,9 +1,9 @@ --- title: Expression Arithmetics -keywords: +keywords: tags: [expression, arithmetics] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -53,7 +53,7 @@ for node in model_part.Nodes: print(node.GetValue(Kratos.ACCELERATION)) ``` Expected output: -```bash +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index 56a824be4364..740ce9c9b9ec 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -1,9 +1,9 @@ --- title: Working with Numpy -keywords: +keywords: tags: [numpy, scipy, expressions, variable expression io, carray expression io] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -39,10 +39,10 @@ print("Shape of the numpy array = ", numpy_nodal_expression.shape) ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -92,10 +92,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -155,10 +155,10 @@ for node in model_part.Nodes: print(f"node id: {node.Id}, velocity: [{velocity[0]}, {velocity[1]}, {velocity[2]}]") ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 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 abca2715c6fd..3112882a13da 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -1,9 +1,9 @@ --- title: C Array Expression IO -keywords: +keywords: tags: [c array expression io, numpy, scipy, Vector] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -43,10 +43,10 @@ print("numpy array = ", numpy_array) ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -90,10 +90,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -127,10 +127,10 @@ print(vector) ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 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 56654da4da35..211f4bb2a8be 100644 --- a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Domain Size Expression IO -keywords: +keywords: tags: [domain size, condition, element, expression io] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -40,10 +40,10 @@ print(shape) ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -78,10 +78,10 @@ print(exp) ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index 3789a3fa942a..8463490140c2 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -1,9 +1,9 @@ --- title: Literal Expression Input -keywords: +keywords: tags: [literal values, expressions, scalars] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -46,10 +46,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -93,10 +93,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -144,10 +144,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -187,10 +187,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 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 807e1f836dbf..dd4016027608 100644 --- a/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Nodal Position Expression IO -keywords: +keywords: tags: [nodal position, initial, current, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -53,10 +53,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -99,10 +99,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index 18030d3bb2e9..6057085c29c3 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Variable Expression IO -keywords: +keywords: tags: [variable expression io, expressions, variable] sidebar: kratos_expressions -summary: +summary: --- ## Introduction @@ -58,10 +58,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -104,10 +104,10 @@ for condition in model_part.Conditions: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -150,10 +150,10 @@ for element in model_part.Elements: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 @@ -193,10 +193,10 @@ for node in model_part.Nodes: ``` Expected output: -```bash - | / | - ' / __| _` | __| _ \ __| - . \ | ( | | ( |\__ \ +```console + | / | + ' / __| _` | __| _ \ __| + . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ Multi-Physics 9.4."3"-docs/expression_documentation-156476ea1c-Release-x86_64 Compiled for GNU/Linux and Python3.11 with GCC-13.2 From 2d43e74dcf29152583f76141c00117c3bd14e585 Mon Sep 17 00:00:00 2001 From: sunethwarna Date: Tue, 6 Feb 2024 09:58:43 +0100 Subject: [PATCH 99/99] fix slice --- .../Expressions/General/Expression_Arithmetics.md | 4 ++-- .../Expressions/General/Working_with_Numpy.md | 4 ++-- .../Expressions/IOs/C_Array_Expression_IO.md | 4 ++-- .../Expressions/IOs/Domain_Size_Expression_IO.md | 4 ++-- .../Expressions/IOs/Literal_Expression_Input.md | 4 ++-- .../IOs/Nodal_Position_Expression_IO.md | 4 ++-- .../Expressions/IOs/Variable_Expression_IO.md | 4 ++-- docs/pages/Kratos/Expressions/Utilities/Slice.md | 14 +++++++------- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md index feb3146459da..634ca371a02d 100644 --- a/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md +++ b/docs/pages/Kratos/Expressions/General/Expression_Arithmetics.md @@ -1,9 +1,9 @@ --- title: Expression Arithmetics -keywords: +keywords: tags: [expression, arithmetics] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md index 740ce9c9b9ec..0ed901957b9e 100644 --- a/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md +++ b/docs/pages/Kratos/Expressions/General/Working_with_Numpy.md @@ -1,9 +1,9 @@ --- title: Working with Numpy -keywords: +keywords: tags: [numpy, scipy, expressions, variable expression io, carray expression io] sidebar: kratos_expressions -summary: +summary: --- ## Introduction 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 3112882a13da..57baa3286400 100644 --- a/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/C_Array_Expression_IO.md @@ -1,9 +1,9 @@ --- title: C Array Expression IO -keywords: +keywords: tags: [c array expression io, numpy, scipy, Vector] sidebar: kratos_expressions -summary: +summary: --- ## Introduction 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 211f4bb2a8be..a1ff83ebf6ad 100644 --- a/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Domain_Size_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Domain Size Expression IO -keywords: +keywords: tags: [domain size, condition, element, expression io] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md index 8463490140c2..b2cbf2cff341 100644 --- a/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md +++ b/docs/pages/Kratos/Expressions/IOs/Literal_Expression_Input.md @@ -1,9 +1,9 @@ --- title: Literal Expression Input -keywords: +keywords: tags: [literal values, expressions, scalars] sidebar: kratos_expressions -summary: +summary: --- ## Introduction 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 dd4016027608..fc9800262e96 100644 --- a/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Nodal_Position_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Nodal Position Expression IO -keywords: +keywords: tags: [nodal position, initial, current, expressions] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md index 6057085c29c3..ec933bdf1196 100644 --- a/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md +++ b/docs/pages/Kratos/Expressions/IOs/Variable_Expression_IO.md @@ -1,9 +1,9 @@ --- title: Variable Expression IO -keywords: +keywords: tags: [variable expression io, expressions, variable] sidebar: kratos_expressions -summary: +summary: --- ## Introduction diff --git a/docs/pages/Kratos/Expressions/Utilities/Slice.md b/docs/pages/Kratos/Expressions/Utilities/Slice.md index 9182342f4421..0ceb30fab586 100644 --- a/docs/pages/Kratos/Expressions/Utilities/Slice.md +++ b/docs/pages/Kratos/Expressions/Utilities/Slice.md @@ -7,7 +7,7 @@ summary: --- ## Introduction -This method slice existing expression to expressions having a new shape with some sub components from the original expression. +`Slice` method slices existing expression to expressions having a new shape with some sub components from the original expression. ``` Assume an @ref Expression of shape [3] and 3 entities with the following data in the flattened representation: @@ -24,7 +24,6 @@ output container shape = [2] = equal to Stride. ``` ## Use case -Following code snippet replicates the above example. ```python import KratosMultiphysics as Kratos model = Kratos.Model() @@ -52,17 +51,18 @@ print(sliced_exp.Evaluate()) ``` Expected output: -```bash -[[2. 3.] - [5. 6.] - [8. 9.]] +```console | / | ' / __| _` | __| _ \ __| . \ | ( | | ( |\__ \ _|\_\_| \__,_|\__|\___/ ____/ - Multi-Physics 9.4."3"-docs/expression_documentation-6de5f1a499-Release-x86_64 + Multi-Physics 9.4."3"-docs/add_python_processing_locally-eb00abccc7-FullDebug-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. +Process Id: 540110 +[[2. 3.] + [5. 6.] + [8. 9.]] ```