Skip to main content

Addition

Addition operator + for FEVariable.

  • Add two instance of FEVariable.
  • A quadrature variable can be added to only a quadrature variable, unless one of the variable is constant.
  • A nodal variable can be added to only a nodal variable, unless one of the variable is a constant.
  • The rank of obj1 and obj2 should be the same, if none of the obj1 and obj2 are scalars.
  • A Scalar FEVariable can be added to a Vector and Matrix FEVariable.
Defined onobj1obj2result
NodalVariableconstantconstantconstant
constantspacespace
constanttimetime
constantspacetimespacetime
spaceconstantspace
spacespacespace
timeconstanttime
timetimetime
spacetimeconstantspacetime
spacetimespacetimespacetime

You can learn more about this method from the following pages

Examples 1

This example shows the use of addition operator for scalar nodal variable.

  • Constant + Constant
  • Space + Constant
  • Time + Constant
  • SpaceTime + Constant
Click here to example

This example tests addition (+) operator for scalar nodal-variable.

PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE(FEVariable_) :: obj
TYPE(FEVariable_) :: ans

constant+constant

obj = NodalVariable( 1.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableConstant ) &
+ NodalVariable( 2.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableConstant )
ans = NodalVariable( 3.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableConstant )
CALL OK( obj .EQ. ans, 'constant+constant' )
obj = NodalVariable( &
& 1.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableConstant ) &
+ 2.0_DFP
ans = NodalVariable( &
& 3.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableConstant )
CALL OK( obj .EQ. ans, 'constant+constant' )

space+constant

obj = NodalVariable( &
& arange(1.0_DFP, 3.0_DFP), &
& typeFEVariableScalar, &
& typeFEVariableSpace ) &
+ NodalVariable( 10.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableConstant )
ans = NodalVariable( &
& arange(1.0_DFP, 3.0_DFP)+10.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableSpace )
CALL OK( obj .EQ. ans, 'space+constant' )
obj = NodalVariable( &
& arange(1.0_DFP, 3.0_DFP), &
& typeFEVariableScalar, &
& typeFEVariableSpace ) &
+ 10.0_DFP
ans = NodalVariable( &
& arange(1.0_DFP, 3.0_DFP)+10.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableSpace )
CALL OK( obj .EQ. ans, 'space+constant' )

time+constant

obj = NodalVariable( &
& arange(0.0_DFP, 3.0_DFP), &
& typeFEVariableScalar, &
& typeFEVariableTime ) &
+ NodalVariable( 10.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableConstant )
ans = NodalVariable( &
& arange(0.0_DFP, 3.0_DFP) + 10.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableTime )
CALL OK( obj .EQ. ans, 'time+constant' )
obj = NodalVariable( arange(0.0_DFP, 3.0_DFP), &
& typeFEVariableScalar, &
& typeFEVariableTime ) &
+ 10.0_DFP
ans = NodalVariable( &
& arange(0.0_DFP, 3.0_DFP) + 10.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableTime )
CALL OK( obj .EQ. ans, 'time+constant' )

spacetime+constant

obj = NodalVariable( &
& reshape(arange(1.0_DFP, 6.0_DFP), [3,2]), &
& typeFEVariableScalar, &
& typeFEVariableSpaceTime ) &
+ NodalVariable( 10.0_DFP, &
& typeFEVariableScalar, &
& typeFEVariableConstant )
ans = NodalVariable( &
& reshape(arange(1.0_DFP, 6.0_DFP)+10.0_DFP, [3,2]), &
& typeFEVariableScalar, &
& typeFEVariableSpaceTime )
CALL OK( obj .EQ. ans, 'spacetime+constant' )
obj = NodalVariable( reshape(arange(1.0_DFP, 6.0_DFP), [3,2]), &
& typeFEVariableScalar, &
& typeFEVariableSpaceTime ) &
+ 10.0_DFP
ans = NodalVariable( &
& reshape(arange(1.0_DFP, 6.0_DFP)+10.0_DFP, [3,2]), &
& typeFEVariableScalar, &
& typeFEVariableSpaceTime )
CALL OK( obj .EQ. ans, 'spacetime+constant' )
END PROGRAM main

Example 2

  • [[FEVariable_test_11a]] Scalar, Nodal Variable

  • [[FEVariable_test_11b]] Scalar, Nodal Variable

  • [[FEVariable_test_11c]] Scalar, Quadrature Variable

  • [[FEVariable_test_11d]] Scalar, Quadrature Variable

  • [[FEVariable_test_12a]] Vector, Nodal Variable

  • [[FEVariable_test_12b]] Vector, Nodal Variable

  • [[FEVariable_test_12c]] Vector, Quadrature Variable

  • [[FEVariable_test_12d]] Vector, Quadrature Variable

  • [[FEVariable_test_13a]] Matrix, Nodal Variable

  • [[FEVariable_test_13b]] Matrix, Nodal Variable

  • [[FEVariable_test_13c]] Matrix, Quadrature Variable

  • [[FEVariable_test_13d]] Matrix, Quadrature Variable