IFEM  90A354
FunctionSum.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef _FUNCTION_SUM_H
15 #define _FUNCTION_SUM_H
16 
17 #include "Function.h"
18 
19 
24 class FunctionSum : public FunctionBase
25 {
26  typedef std::pair<FunctionBase*,double> WeightedFunc;
27 
28 protected:
31 
32 public:
36  explicit FunctionSum(FunctionBase* f, double w = 1.0) { this->add(f,w); }
37 
39  virtual ~FunctionSum() {}
40 
44  bool add(FunctionBase* f, double w = 1.0);
45 
47  virtual unsigned char getType() const;
48 
50  virtual bool inDomain(const Vec3& X) const;
52  virtual bool initPatch(size_t idx);
53 
55  virtual std::vector<double> getValue(const Vec3& X) const;
57  virtual double getScalarValue(const Vec3& X) const;
58 
59 private:
60  std::vector<WeightedFunc> comps;
61 };
62 
63 #endif
General functions with arbitrary argument and value type.
Base class for unary spatial functions of arbitrary result type.
Definition: Function.h:147
Unary spatial function as a sum of other spatial functions.
Definition: FunctionSum.h:25
FunctionSum()
Constructor to allow empty initialization in subclasses.
Definition: FunctionSum.h:30
std::pair< FunctionBase *, double > WeightedFunc
Convenience type.
Definition: FunctionSum.h:26
FunctionSum(FunctionBase *f, double w=1.0)
The constructor specifies the first function to sum.
Definition: FunctionSum.h:36
virtual bool inDomain(const Vec3 &X) const
Checks if a specified point is within the function domain.
Definition: FunctionSum.C:51
bool add(FunctionBase *f, double w=1.0)
Adds a function to the list of functions to sum.
Definition: FunctionSum.C:18
virtual double getScalarValue(const Vec3 &X) const
Returns a representative scalar equivalent of the function value.
Definition: FunctionSum.C:91
virtual bool initPatch(size_t idx)
Returns true if current patch is affected by this function.
Definition: FunctionSum.C:61
std::vector< WeightedFunc > comps
List of weighted functions to sum.
Definition: FunctionSum.h:60
virtual ~FunctionSum()
Empty destructor.
Definition: FunctionSum.h:39
virtual unsigned char getType() const
Returns the function type flag.
Definition: FunctionSum.C:38
virtual std::vector< double > getValue(const Vec3 &X) const
Returns the function value as an array.
Definition: FunctionSum.C:71
Simple class for representing a point in 3D space.
Definition: Vec3.h:27