Skip to content

Commit f1fa787

Browse files
authored
Merge pull request #6537 from bangerth/replace
Derive VectorFunctionFromVelocityFunctionObject from VectorFunctionFromTensorFunctionObject.
2 parents ade88c7 + b99608d commit f1fa787

File tree

2 files changed

+6
-70
lines changed

2 files changed

+6
-70
lines changed

include/aspect/utilities.h

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,12 @@ namespace aspect
11031103
* that matches the dealii::Function interface with a number of output
11041104
* components equal to the number of components of the finite element
11051105
* in use.
1106+
*
1107+
* This function is a special case of the VectorFunctionFromTensorFunctionObject
1108+
* class.
11061109
*/
11071110
template <int dim>
1108-
class VectorFunctionFromVelocityFunctionObject : public Function<dim>
1111+
class VectorFunctionFromVelocityFunctionObject : public VectorFunctionFromTensorFunctionObject<dim>
11091112
{
11101113
public:
11111114
/**
@@ -1114,40 +1117,11 @@ namespace aspect
11141117
* interface.
11151118
*
11161119
* @param n_components total number of components of the finite element system.
1117-
* @param function_object The function that will form one component
1120+
* @param function_object The function that will form the first `dim` components
11181121
* of the resulting Function object.
11191122
*/
11201123
VectorFunctionFromVelocityFunctionObject (const unsigned int n_components,
11211124
const std::function<Tensor<1,dim> (const Point<dim> &)> &function_object);
1122-
1123-
/**
1124-
* Return the value of the
1125-
* function at the given
1126-
* point. Returns the value the
1127-
* function given to the constructor
1128-
* produces for this point.
1129-
*/
1130-
double value (const Point<dim> &p,
1131-
const unsigned int component = 0) const override;
1132-
1133-
/**
1134-
* Return all components of a
1135-
* vector-valued function at a
1136-
* given point.
1137-
*
1138-
* <tt>values</tt> shall have the right
1139-
* size beforehand,
1140-
* i.e. #n_components.
1141-
*/
1142-
void vector_value (const Point<dim> &p,
1143-
Vector<double> &values) const override;
1144-
1145-
private:
1146-
/**
1147-
* The function object which we call when this class's value() or
1148-
* value_list() functions are called.
1149-
*/
1150-
const std::function<Tensor<1,dim> (const Point<dim> &)> function_object;
11511125
};
11521126

11531127
/**

source/utilities.cc

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,50 +2777,12 @@ namespace aspect
27772777
(const unsigned int n_components,
27782778
const std::function<Tensor<1,dim> (const Point<dim> &)> &function_object)
27792779
:
2780-
Function<dim>(n_components),
2781-
function_object (function_object)
2780+
VectorFunctionFromTensorFunctionObject<dim>(function_object, 0, n_components)
27822781
{
27832782
}
27842783

27852784

27862785

2787-
template <int dim>
2788-
double
2789-
VectorFunctionFromVelocityFunctionObject<dim>::value (const Point<dim> &p,
2790-
const unsigned int component) const
2791-
{
2792-
Assert (component < this->n_components,
2793-
ExcIndexRange (component, 0, this->n_components));
2794-
2795-
if (component < dim)
2796-
{
2797-
const Tensor<1,dim> v = function_object(p);
2798-
return v[component];
2799-
}
2800-
else
2801-
return 0;
2802-
}
2803-
2804-
2805-
2806-
template <int dim>
2807-
void
2808-
VectorFunctionFromVelocityFunctionObject<dim>::
2809-
vector_value (const Point<dim> &p,
2810-
Vector<double> &values) const
2811-
{
2812-
AssertDimension(values.size(), this->n_components);
2813-
2814-
// set everything to zero, and then the right components to their correct values
2815-
values = 0;
2816-
2817-
const Tensor<1,dim> v = function_object(p);
2818-
for (unsigned int d=0; d<dim; ++d)
2819-
values(d) = v[d];
2820-
}
2821-
2822-
2823-
28242786
void throw_linear_solver_failure_exception(const std::string &solver_name,
28252787
const std::string &function_name,
28262788
const std::vector<SolverControl> &solver_controls,

0 commit comments

Comments
 (0)