/usr/include/deal.II/numerics/operator.h is in libdeal.ii-dev 6.3.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | //---------------------------------------------------------------------------
// $Id: operator.h 20898 2010-03-28 17:10:52Z janssen $
//
// Copyright (C) 2010 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
// to the file deal.II/doc/license.html for the text and
// further information on this license.
//
//---------------------------------------------------------------------------
#ifndef __deal2__operator_h
#define __deal2__operator_h
#include <base/config.h>
#include <base/named_data.h>
#include <base/event.h>
#include <dofs/dof_handler.h>
#include <fstream>
DEAL_II_NAMESPACE_OPEN
namespace Algorithms
{
/**
* The abstract base class of all algorithms in this library. An
* operator is an object with an operator(), which transforms a set
* of named vectors into another set of named vectors.
*
* Furthermore, an operator can be notified of parameter changes by
* the calling routine. The outer iteration can notify() the Operator
* of an Event, which could be for instance a change of mesh, a
* different time step size or too slow convergence of Newton's
* method, which would then trigger reassembling of a matrix or
* similar things.
*
* <h3>Usage for nested iterations</h3>
*
* This is probably the most prominent use for Operator, where an
* outer iterative method calls an inner solver and so on. Typically,
* the innermost method in such a nested system will have to compute a
* residual using values from all outer iterations. Since the depth
* and order of such a nesting is hardly predictable when designing a
* general tool, we use NamedData to access these vectors. Typically,
* the first vector in <tt>out</tt> contains the start vector when
* operator()() is called, and the solution when the function
* returns. The object <tt>in</tt> is providing additional information
* and forwarded to the inner Operator objects of the nested
* iteration.
*
* @author Guido Kanschat, 2010
*/
template <class VECTOR>
class Operator : public Subscriptor
{
public:
/**
* The virtual destructor.
*/
~Operator();
/**
* The actual operation, which
* is implemented in a derived class.
*/
virtual void operator() (NamedData<VECTOR*>& out, const NamedData<VECTOR*>& in) = 0;
/**
* Register an event triggered
* by an outer iteration.
*/
virtual void notify(const Event&);
/**
* Clear all #notifications.
*/
void clear_events();
protected:
/**
* Accumulate reasons for
* reassembling here. If any of
* those is set, the function
* solve() of a terminal
* application must take care
* of reassembling the matrix.
*/
Event notifications;
};
/**
* An unary operator base class, intended to output the vectors in
* NamedData in each step of an iteration.
*
* @author Guido Kanschat, 2010
*/
template <class VECTOR>
class OutputOperator : public Subscriptor
{
OutputOperator(const OutputOperator<VECTOR>&);
public:
OutputOperator ();
/**
* Empty virtual destructor.
*/
virtual ~OutputOperator();
/**
* Set the stream #os to
* which data is written. If
* no stream is selected with
* this function, data goes
* to #deallog.
*/
void initialize_stream(std::ostream& stream);
/**
* Set the current step.
*/
OutputOperator<VECTOR>& operator<< (unsigned int step);
/**
* Output all the vectors in NamedData.
*/
virtual OutputOperator<VECTOR>& operator<< (const NamedData<VECTOR*>& vectors);
protected:
unsigned int step;
private:
std::ostream* os;
};
template <class VECTOR>
OutputOperator<VECTOR>&
OutputOperator<VECTOR>::operator<< (unsigned int s)
{
step = s;
return *this;
}
template <class VECTOR, int dim, int spacedim=dim>
class DoFOutputOperator : public OutputOperator<VECTOR>
{
public:
void initialize (DoFHandler<dim, spacedim>& dof_handler);
virtual OutputOperator<VECTOR>&
operator<<(const NamedData<VECTOR*>& vectors);
private:
SmartPointer<DoFHandler<dim, spacedim>,
DoFOutputOperator<VECTOR, dim, spacedim> > dof;
};
template <class VECTOR, int dim, int spacedim>
void DoFOutputOperator<VECTOR, dim, spacedim>::initialize(
DoFHandler<dim, spacedim>& dof_handler)
{
dof = &dof_handler;
}
}
DEAL_II_NAMESPACE_CLOSE
#endif
|