IFEM  90A354
ElmNorm.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef _ELM_NORM_H
15 #define _ELM_NORM_H
16 
17 #include "LocalIntegral.h"
18 #include <cstddef>
19 
20 
28 class ElmNorm : public LocalIntegral
29 {
30 public:
34  ElmNorm(double* p, size_t n) : ptr(p), nnv(n) {}
42  explicit ElmNorm(size_t n) : buf(n,0.0), nnv(n) { ptr = &buf.front(); }
44  virtual ~ElmNorm() {}
45 
47  double& operator[](size_t i) { return ptr[i]; }
49  const double& operator[](size_t i) const { return ptr[i]; }
50 
52  size_t size() const { return nnv; }
53 
55  bool externalStorage() const { return buf.empty(); }
56 
62  virtual void destruct()
63  {
64  if (buf.empty())
65  {
66  vec.clear();
67  psol.clear();
68  }
69  else
70  delete this; // The internal buffer has been used, delete the whole thing
71  }
72 
73 private:
75  double* ptr;
76  size_t nnv;
77 
78 public:
80 };
81 
82 #endif
std::vector< Real > RealArray
A real-valued array without algebraic operations.
Definition: ImmersedBoundaries.h:29
Abstract interface for classes representing integrated quantities.
std::vector< Vector > Vectors
An array of real-valued vectors with algebraic operations.
Definition: MatVec.h:37
Class representing integrated norm quantities over an element.
Definition: ElmNorm.h:29
bool externalStorage() const
Returns whether the element norms are stored externally or not.
Definition: ElmNorm.h:55
virtual ~ElmNorm()
Empty destructor.
Definition: ElmNorm.h:44
const double & operator[](size_t i) const
Indexing operator for referencing.
Definition: ElmNorm.h:49
size_t nnv
Number of norm values.
Definition: ElmNorm.h:76
ElmNorm(double *p, size_t n)
The constructor assigns the internal pointer.
Definition: ElmNorm.h:34
double & operator[](size_t i)
Indexing operator for assignment.
Definition: ElmNorm.h:47
ElmNorm(size_t n)
Alternative constructor using the internal buffer buf.
Definition: ElmNorm.h:42
RealArray buf
Internal buffer used when element norms are not requested.
Definition: ElmNorm.h:74
Vectors psol
Element-level projected solution vectors.
Definition: ElmNorm.h:79
size_t size() const
Returns the number of norm values.
Definition: ElmNorm.h:52
virtual void destruct()
Virtual destruction method to clean up after numerical integration.
Definition: ElmNorm.h:62
double * ptr
Pointer to the actual norm values.
Definition: ElmNorm.h:75
Abstract base class representing an element level integrated quantity.
Definition: LocalIntegral.h:25
Vectors vec
Element-level primary solution vectors.
Definition: LocalIntegral.h:69