double time;
};
-
+/*------------------------------ Inline functions ------------------------------*/
inline double
FunctionTime::get_time () const
string id;
};
+/*------------------------------ Inline functions ------------------------------*/
+
extern JobIdentifier dealjobid;
#endif
ostream *file;
bool was_endl;
- unsigned int std_depth, file_depth;
+ unsigned int std_depth;
+ unsigned int file_depth;
public:
/**
* colon and there is a double
* colon after the last prefix.
*/
- void push (const string& text) {
- // strange enough: if make this
- // function non-inline with
- // gcc2.8, we get very strange
- // compiler errors...
- string pre=prefixes.top();
- pre += text;
- pre += string(":");
- prefixes.push(pre);
- }
+ void push (const string& text);
/**
* Remove the last prefix.
* tells the #LogStream# that the end of
* the line is reached.
*/
- LogStream & operator << (void (*f)(LogStream &));
+ LogStream & operator << (void (f)(LogStream &));
/**
* Declare this function as a friend.
* Remove this function at the first
* possible time.
*/
- ostream & get_std_stream () {
- return *std;
- };
-
+ ostream & get_std_stream ();
};
/* ----------------------------- Inline functions and templates ---------------- */
+inline
+void
+LogStream::push (const string& text)
+{
+ // strange enough: if make this
+ // function non-inline with
+ // gcc2.8, we get very strange
+ // compiler errors...
+ string pre=prefixes.top();
+ pre += text;
+ pre += string(":");
+ prefixes.push(pre);
+}
+
+inline
+ostream &
+LogStream::get_std_stream ()
+{
+ return *std;
+}
+
template <class T>
inline void
writestuff(LogStream& s, const T& t)
* @author Wolfgang Bangerth, October 1997, revised February 1998
* @see MultipleParameterLoop
*/
-class ParameterHandler {
+class ParameterHandler
+{
public:
/**
* Constructor.
* Return status of this object:
* #true#=clean or #false#=error occured.
*/
- bool ok() const { return status; };
+ bool ok() const;
/**
* clear status bit and contents.
};
+/*------------------------------ Inline functions ------------------------------*/
+inline
+bool
+ParameterHandler::ok() const
+{
+ return status;
+}
/********************** parameter-handler.h ****************************/
/* end of #ifndef __parameter_handler_H */
-/* --------------------------- Template functions ------------------------------*/
+/* --------------------------- inline Template functions ------------------------------*/
template <typename T>
#include <base/tensor_base.h>
+template <int rank_, int dim> class Tensor;
/**
* Provide a general tensor class with an arbitrary rank, i.e. with
* runtime-dependent dimension.
*/
template <int rank_, int dim>
-class Tensor {
+class Tensor //<rank_, dim>
+{
public:
/**
* Provide a way to get the
/**
* Help function for unroll.
*/
- void unroll_recursion(Vector<double> & result, unsigned& start_index) const;
+ void unroll_recursion(Vector<double> & result, unsigned int& start_index) const;
template<>
friend void Tensor<rank_+1,dim>::unroll_recursion(Vector<double> &, unsigned&) const;
* Help function for unroll.
*/
void unroll_recursion (Vector<double> & result,
- unsigned& start_index) const;
+ unsigned int& start_index) const;
template<>
friend void Tensor<2,dim>::unroll_recursion(Vector<double> &,
/**
* Exception
*/
-DeclException2(ExcWrongVectorSize, unsigned, int, << "Tensor has " << arg1
+DeclException2(ExcWrongVectorSize, int, int, << "Tensor has " << arg1
<< " entries, but vector has size " << arg2);
DeclException1 (ExcDimTooSmall,
int,
#include <base/exceptions.h>
#include <vector>
+#include <base/subscriptor.h>
+#include <base/smartpointer.h>
+#include <base/function.h>
#include <base/point.h>
#include <base/functiontime.h>
#include <base/tensorindex.h>
#include <base/forward-declarations.h>
template <typename number> class Vector;
+template <int dim> class VectorFunction;
+template <int rank_, int dim> class TensorFunction;
/**
* Base class for multi-valued functions.
- *
- *
+ * While #TensorFunction# provides a highly structured class for multi-valued
+ * functions, #VectorFunction# is on a lower level. The results are #Vectors# of
+ * values without further structure. The dimension of the result is determined at
+ * execution time.
+ * @author Guido Kanschat, 1999
*/
template <int dim>
-class VectorFunction :
- public FunctionTime
+class VectorFunction //<dim>
+ :
+ public FunctionTime,
+ public Subscriptor
{
public:
/**
/**
* Number of vector components.
*/
- const unsigned n_components;
+ const unsigned int n_components;
+
+ /**
+ * Access #VectorFunction# as a #Function#.
+ * This class allows to store a reference to a
+ * #VectorFunction# and an #index#. Later on, it
+ * can be used as a normal single valued #Function#.
+ */
+ class Extractor
+ : public Function<dim>
+ {
+ public:
+ /**
+ * Constructor.
+ * The arguments are the #VectorFunction# to be
+ * accessed and the component index.
+ */
+ Extractor(const VectorFunction<dim>& f, unsigned int index);
+ /**
+ * Compute function value.
+ */
+ virtual double operator() (const Point<dim>& p) const;
+
+ /**
+ * Compute several values.
+ */
+ virtual void value_list (const vector<Point<dim> > &points,
+ vector<double> &values) const;
+
+
+ /**
+ * Compute derivative.
+ */
+ virtual Tensor<1,dim> gradient (const Point<dim>& p) const;
+
+ /**
+ * Compute several derivatives.
+ */
+ virtual void gradient_list (const vector<Point<dim> > &points,
+ vector<Tensor<1,dim> > &gradients) const;
+
+ private:
+ /**
+ * Pointer to the #VectorFunction#.
+ */
+ const SmartPointer<VectorFunction<dim> > vectorfunction;
+
+ /**
+ * Index in #VectorFunction#.
+ */
+ const unsigned int index;
+ };
+
+
/**
* Exception
*/
* @author Guido Kanschat, 1999
*/
template <int rank_, int dim>
-class TensorFunction :
+class TensorFunction //<rank_ , dim>
+ :
public VectorFunction<dim>
{
public:
/**
* Field of indices.
*/
- unsigned index[rank];
+ unsigned int index[rank];
public:
/**
* Constructor taking #rank# indices.
* in #n#th component
*
*/
- unsigned operator () (unsigned n) const;
- DeclException1(ExcRank, unsigned,
+ unsigned int operator () (unsigned int n) const;
+ DeclException1(ExcRank, int,
<< "Index " << arg1 << " higher than maximum " << rank-1);
};
-void LogStream::detach () {
+void LogStream::detach ()
+{
file = 0;
};
-void LogStream::pop () {
+void LogStream::pop ()
+{
prefixes.pop();
};
-void LogStream::depth_console(unsigned n) {
+void LogStream::depth_console(unsigned n)
+{
std_depth = n;
};
-void LogStream::depth_file(unsigned n) {
+void LogStream::depth_file(unsigned n)
+{
file_depth = n;
};
LogStream&
-LogStream::operator << (void (*f)(LogStream &))
+LogStream::operator << (void (f)(LogStream &))
{
f(*this);
return *this;
}
*/
-template <int dim> void
+template <int dim>
+void
VectorFunction<dim>::value (const Point<dim> &, Vector<double> &) const
{
Assert (false, ExcPureFunctionCalled());
}
-template <int dim> void
+template <int dim>
+void
VectorFunction<dim>::value_list (const vector<Point<dim> > &,
vector<Vector<double> > &) const
{
}
-template <int dim> void
+template <int dim>
+void
VectorFunction<dim>::gradient_list (const vector<Point<dim> > &,
vector<vector<Tensor<1,dim> > > &) const
{
Assert (false, ExcPureFunctionCalled());
}
+template <int dim>
+VectorFunction<dim>::Extractor::Extractor(const VectorFunction<dim>& f,
+ unsigned int index)
+ :
+ vectorfunction(f),
+ index(index)
+{}
+
+template <int dim>
+double
+VectorFunction<dim>::Extractor::operator() (const Point<dim>& p) const
+{
+ Vector<double> v(vectorfunction->n_components);
+ vectorfunction->value(p,v);
+ return v(index);
+}
+
+
+template <int dim>
+Tensor<1,dim>
+VectorFunction<dim>::Extractor::gradient (const Point<dim>&) const
+{
+ Assert(false, ExcNotImplemented());
+ return Tensor<1,dim>();
+}
+
+template <int dim>
+void
+VectorFunction<dim>::Extractor::value_list (const vector<Point<dim> > &points,
+ vector<double> &values) const
+{
+ vector<Vector<double> > v(values.size(),
+ Vector<double>(vectorfunction->n_components));
+ vectorfunction->value_list(p,v);
+ for (unsigned int i=0 ; i<values.size() ; ++i)
+ values[i] = v[i](index);
+}
+
+
+template <int dim>
+void
+VectorFunction<dim>::Extractor::gradient_list (const vector<Point<dim> > &points,
+ vector<Tensor<1,dim> > &gradients) const
+{
+ vector<vector<Tensor<1,dim> > > v(values.size(),
+ vector<Tensor<1,dim> >(vectorfunction->n_components));
+ vectorfunction->value_list(p,v);
+ for (unsigned int i=0 ; i<values.size() ; ++i)
+ values[i] = v[i][index];
+}
//////////////////////////////////////////////////////////////////////
// TensorFunction
};
-
-
template <int rank_, int dim>
Tensor<rank_+1,dim>
TensorFunction<rank_, dim>::gradient (const Point<dim> &) const
gradients[i] = gradient(points[i]);
};
-/*
+
template <int rank_, int dim> void
-TensorFunction<rank_, dim>::value (const Point<dim> &p, vector<double> &erg) const
+TensorFunction<rank_, dim>::value (const Point<dim> &p,
+ Vector<double> &erg) const
{
Tensor<rank_,dim> h = operator()(p);
h.unroll(erg);
}
-*/
-
-
-template <int rank_, int dim> void
-TensorFunction<rank_, dim>::value (const Point<dim> &, Vector<double> &) const
-{
- Assert(false, ExcNotImplemented());
-}
template <int rank_, int dim> void