24 #include "libmesh/point.h" 30 TEST_CASE(
"constant_field_functions",
"[field_function],[constant],[base]")
38 const Real initial_value = 4.984;
41 const std::string initial_name =
"cf1";
50 SECTION(
"constant field function can return a constant reference to its name")
52 const std::string& name = cfield1.
name();
53 CHECK( name == initial_name );
56 SECTION(
"constant field function can return a copy of its name")
58 std::string name = cfield1.
name();
59 CHECK( name == initial_name );
60 name +=
"_added_string";
61 CHECK( name != initial_name );
62 CHECK ( cfield1.
name() == initial_name );
65 SECTION(
"constant field function can return the value")
68 cfield1(cfield_value);
69 CHECK( cfield_value == initial_value );
72 SECTION(
"constant field function's derivative w.r.t. its own parameter is 1")
76 REQUIRE ( dvalue_dparam == 1.0 );
79 SECTION(
"constant field function's derivative w.r.t. another parameter is 0")
84 CHECK( dvalue_dparam == 0.0 );
87 SECTION(
"constant field function can return the value given a point and time")
90 const libMesh::Point point(2.3, 3.1, 5.2);
91 const Real time = 2.34;
92 cfield1(point, time, cfield_value);
93 CHECK( cfield_value == initial_value );
96 SECTION(
"constant field function is constant over time and space")
99 const libMesh::Point point(2.3, 3.1, 5.2);
100 const Real time = 2.34;
101 cfield1(point, time, cfield_value);
102 CHECK( cfield_value == initial_value );
105 const libMesh::Point point2(4.3, -16.4, 55.2);
106 const Real time2 = 88.4;
107 cfield1(point2, time2, cfield_value2);
108 CHECK( cfield_value2 == initial_value );
111 const libMesh::Point point3(-18.0, 10.2, -7.5);
112 const Real time3 = 36.7;
113 cfield1(point3, time3, cfield_value3);
114 CHECK( cfield_value3 == initial_value );
117 SECTION(
"constant field function can return derivative to its own parameter at a given point and time")
120 const libMesh::Point point(3.5, -2.4, -11.2);
121 const Real time = 6.87;
122 cfield1.
derivative(parameter1, point, time, dvalue_dparam);
123 CHECK( dvalue_dparam == 1.0 );
126 SECTION(
"constant field function can return derivative to other parameter at a given point and time")
130 const libMesh::Point point(3.5, -2.4, -11.2);
131 const Real time = 6.87;
132 cfield1.
derivative(parameter2, point, time, dvalue_dparam);
133 CHECK( dvalue_dparam == 0.0 );
137 SECTION(
"constant field function derivative w.r.t. itself is constant 1 over time and space")
140 const libMesh::Point point(-5.0, 8.4, 7.3);
141 const Real time = 3.5;
142 cfield1.
derivative(parameter1, point, time, dvalue_dparam);
143 CHECK( dvalue_dparam == 1.0 );
146 const libMesh::Point point2(8.8, -10.5, 200.3);
147 const Real time2 = 107.5;
148 cfield1.
derivative(parameter1, point2, time2, dvalue_dparam2);
149 CHECK( dvalue_dparam2 == 1.0 );
152 const libMesh::Point point3(0.0, 57.8,-150.7);
153 const Real time3 = 0.0;
154 cfield1.
derivative(parameter1, point3, time3, dvalue_dparam3);
155 CHECK( dvalue_dparam3 == 1.0 );
158 SECTION(
"constant field function derivative w.r.t. other parameters is constant 0 over time and space")
163 const libMesh::Point point(-5.0, 8.4, 7.3);
164 const Real time = 3.5;
165 cfield1.
derivative(parameter2, point, time, dvalue_dparam);
166 CHECK( dvalue_dparam == 0.0 );
169 const libMesh::Point point2(8.8, -10.5, 200.3);
170 const Real time2 = 107.5;
171 cfield1.
derivative(parameter2, point2, time2, dvalue_dparam2);
172 CHECK( dvalue_dparam2 == 0.0 );
175 const libMesh::Point point3(0.0, 57.8,-150.7);
176 const Real time3 = 0.0;
177 cfield1.
derivative(parameter2, point3, time3, dvalue_dparam3);
178 CHECK( dvalue_dparam3 == 0.0 );
181 SECTION(
"constant field function is NOT a shape parameter by default")
186 SECTION(
"constant field function can be set as a shape parameter")
192 SECTION(
"constant field function is NOT a topology parameter by default")
197 SECTION(
"constant field function can be set as a topology parameter")
virtual bool is_shape_parameter() const
const std::string & name() const
returns the name of this function
virtual void set_as_topology_parameter(bool f)
This is a scalar function whose value can be changed and one that can be used as a design variable in...
virtual bool is_topology_parameter() const
TEST_CASE("constant_field_functions", "[field_function],[constant],[base]")
virtual void derivative(const MAST::FunctionBase &f, Real &v) const
calculates the value of the function at the specified point, p, and time, t, and returns it in v...
virtual void set_as_shape_parameter(bool f)