libMesh
Public Member Functions | Private Member Functions | List of all members
ParsedFunctionTest Class Reference
Inheritance diagram for ParsedFunctionTest:
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
 CPPUNIT_TEST_SUITE (ParsedFunctionTest)
 
 CPPUNIT_TEST (testValues)
 
 CPPUNIT_TEST (testInlineGetter)
 
 CPPUNIT_TEST (testInlineSetter)
 
 CPPUNIT_TEST (testTimeDependence)
 
 CPPUNIT_TEST_SUITE_END ()
 

Private Member Functions

void testValues ()
 
void testInlineGetter ()
 
void testInlineSetter ()
 
void testTimeDependence ()
 

Detailed Description

Definition at line 32 of file parsed_function_test.C.

Member Function Documentation

ParsedFunctionTest::CPPUNIT_TEST ( testValues  )
ParsedFunctionTest::CPPUNIT_TEST ( testInlineGetter  )
ParsedFunctionTest::CPPUNIT_TEST ( testInlineSetter  )
ParsedFunctionTest::CPPUNIT_TEST ( testTimeDependence  )
ParsedFunctionTest::CPPUNIT_TEST_SUITE ( ParsedFunctionTest  )
ParsedFunctionTest::CPPUNIT_TEST_SUITE_END ( )
void ParsedFunctionTest::setUp ( )

Definition at line 35 of file parsed_function_test.C.

35 {}
void ParsedFunctionTest::tearDown ( )

Definition at line 37 of file parsed_function_test.C.

37 {}
void ParsedFunctionTest::testInlineGetter ( )
private

Definition at line 64 of file parsed_function_test.C.

References libMesh::ParsedFunction< Output, OutputGradient >::get_inline_value(), libMesh::libmesh_real(), and libMesh::TOLERANCE.

65  {
66  ParsedFunction<Number> ax2("a:=4.5;a*x*2");
67 
68  CPPUNIT_ASSERT_DOUBLES_EQUAL
69  (libmesh_real(ax2(Point(0.25,0.25,0.25))), 2.25, TOLERANCE*TOLERANCE);
70 
71  CPPUNIT_ASSERT_DOUBLES_EQUAL
72  (libmesh_real(ax2.get_inline_value("a")), 4.5, TOLERANCE*TOLERANCE);
73 
75  ("a := 4 ; b := a/2+1; c:=b-a+3.5; c*x*2*y*4");
76 
77  CPPUNIT_ASSERT_DOUBLES_EQUAL
78  (libmesh_real(cxy8(Point(0.5,0.5,0.5))), 5.0, TOLERANCE*TOLERANCE);
79 
80  CPPUNIT_ASSERT_DOUBLES_EQUAL
81  (libmesh_real(cxy8.get_inline_value("b")), 3.0, TOLERANCE*TOLERANCE);
82 
83  CPPUNIT_ASSERT_DOUBLES_EQUAL
84  (libmesh_real(cxy8.get_inline_value("c")), 2.5, TOLERANCE*TOLERANCE);
85  }
T libmesh_real(T a)
A Function generated (via FParser) by parsing a mathematical expression.
static const Real TOLERANCE
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
void ParsedFunctionTest::testInlineSetter ( )
private

Definition at line 87 of file parsed_function_test.C.

References libMesh::ParsedFunction< Output, OutputGradient >::get_inline_value(), libMesh::libmesh_real(), libMesh::ParsedFunction< Output, OutputGradient >::set_inline_value(), and libMesh::TOLERANCE.

88  {
89  ParsedFunction<Number> ax2("a:=4.5;a*x*2");
90  ax2.set_inline_value("a", 2.5);
91 
92  CPPUNIT_ASSERT_DOUBLES_EQUAL
93  (libmesh_real(ax2(Point(0.25,0.25,0.25))), 1.25, TOLERANCE*TOLERANCE);
94 
95  CPPUNIT_ASSERT_DOUBLES_EQUAL
96  (libmesh_real(ax2.get_inline_value("a")), 2.5, TOLERANCE*TOLERANCE);
97 
99  ("a := 4 ; b := a/2+1; c:=b-a+3.5; c*x*2*y*4");
100  cxy8.set_inline_value("a", 2);
101 
102  CPPUNIT_ASSERT_DOUBLES_EQUAL
103  (libmesh_real(cxy8(Point(0.5,0.5,0.5))), 7.0, TOLERANCE*TOLERANCE);
104 
105  CPPUNIT_ASSERT_DOUBLES_EQUAL
106  (libmesh_real(cxy8.get_inline_value("b")), 2.0, TOLERANCE*TOLERANCE);
107 
108  CPPUNIT_ASSERT_DOUBLES_EQUAL
109  (libmesh_real(cxy8.get_inline_value("c")), 3.5, TOLERANCE*TOLERANCE);
110  }
T libmesh_real(T a)
A Function generated (via FParser) by parsing a mathematical expression.
static const Real TOLERANCE
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
void ParsedFunctionTest::testTimeDependence ( )
private

Definition at line 112 of file parsed_function_test.C.

References CPPUNIT_TEST_SUITE_REGISTRATION(), and libMesh::FunctionBase< Output >::is_time_dependent().

113  {
114  ParsedFunction<Number> no_t("x*2+y^2-tanh(z)+atan(x-y)");
115  CPPUNIT_ASSERT(!no_t.is_time_dependent());
116 
117  ParsedFunction<Number> xyt("x+y+t");
118  CPPUNIT_ASSERT(xyt.is_time_dependent());
119 
120  ParsedFunction<Number> x2y2t2("x*2+y^2+t^2");
121  CPPUNIT_ASSERT(x2y2t2.is_time_dependent());
122 
123  ParsedFunction<Number> ztanht("z*tanh(t)");
124  CPPUNIT_ASSERT(ztanht.is_time_dependent());
125  }
A Function generated (via FParser) by parsing a mathematical expression.
void ParsedFunctionTest::testValues ( )
private

Definition at line 51 of file parsed_function_test.C.

References libMesh::libmesh_real(), and libMesh::TOLERANCE.

52  {
53  ParsedFunction<Number> x2("x*2");
54 
55  CPPUNIT_ASSERT_DOUBLES_EQUAL
56  (libmesh_real(x2(Point(0.5,1.5,2.5))), 1.0, TOLERANCE*TOLERANCE);
57 
58  ParsedFunction<Number> xy8("x*y*8");
59 
60  CPPUNIT_ASSERT_DOUBLES_EQUAL
61  (libmesh_real(xy8(Point(0.5,1.5,2.5))), 6.0, TOLERANCE*TOLERANCE);
62  }
T libmesh_real(T a)
A Function generated (via FParser) by parsing a mathematical expression.
static const Real TOLERANCE
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38

The documentation for this class was generated from the following file: