File: MatrixManagement.hpp

package info (click to toggle)
freefem3d 1.0pre10-3.4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 25,016 kB
  • ctags: 8,675
  • sloc: cpp: 57,204; sh: 8,788; yacc: 2,975; makefile: 1,149; ansic: 508; perl: 110
file content (162 lines) | stat: -rw-r--r-- 4,387 bytes parent folder | download | duplicates (5)
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
//  This file is part of ff3d - http://www.freefem.org/ff3d
//  Copyright (C) 2001, 2002, 2003 Stphane Del Pino

//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2, or (at your option)
//  any later version.

//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.

//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software Foundation,
//  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  

//  $Id: MatrixManagement.hpp,v 1.3 2007/06/09 10:37:07 delpinux Exp $

#ifndef MATRIX_MANAGEMENT_HPP
#define MATRIX_MANAGEMENT_HPP

#include <cctype>

#include <ReferenceCounting.hpp>
#include <ParametrizableObject.hpp>

#include <SurfaceMesh.hpp>

#include <ErrorHandler.hpp>

class BaseMatrix;
class BaseVector;

class MemoryRepository
{
private:
  std::map<int, ReferenceCounting<BaseMatrix> > __matrices;
public:

  void store(int i,ReferenceCounting<BaseMatrix>& matrix);

  ReferenceCounting<BaseMatrix>& getMatrix(int i);

  bool stored(int i) const;

  ~MemoryRepository()
  {
    ;
  }
};

#warning REARANGE AND RENAME THIS FILE.

class Structured3DMesh;
class PDESystem;

extern  MemoryRepository *memoryRepository;

#include <GetParameter.hpp>
#include <MemoryManagerOptions.hpp>

class MemoryManager
{
private:
  MemoryRepository& __mr;

  GetParameter<MemoryManagerOptions> __options;
public:
  bool ReserveMatrix(ReferenceCounting<BaseMatrix>& A,
		     const size_t dimension,
		     const size_t nbDegreeOfFreefom);

  void ReserveVector(ReferenceCounting<BaseVector>& b,
		     const size_t dimension,
		     const size_t nbDegreeOfFreefom);

  MemoryManager()
    : __mr(*memoryRepository)
  {
    ;
  } 
};

#include <Vector.hpp>
#include <DoubleHashedMatrix.hpp>

#include <Index.hpp>
#include <Dirichlet.hpp>
#include <PDEProblem.hpp>

#include <Structured3DMesh.hpp>
class BoundaryConditionSurfaceMeshAssociation;

template<class VectType>
void computesDirichletMatrix(DoubleHashedMatrix& DM,
			     const DoubleHashedMatrix& A,
			     const PDEProblem& pdePb,
			     BoundaryConditionSurfaceMeshAssociation& bcMeshAssociation,
			     const Structured3DMesh& SMesh)
{
  throw ErrorHandler(__FILE__,__LINE__,
		     "not implemented",
		     ErrorHandler::unexpected);
//   // Dirichlet on the mesh border ...
//   for (size_t i=0; i<pdePb.Dimension(); ++i) {
//     for (bcMeshAssociation::iterator ibcMesh = bcMesh[i].begin();
// 	 ibcMesh !=bcMesh[i].end();
// 	 ++ibcMesh) {
//       const BoundaryCondition& BC = *(*ibcMesh).first;
//       const SurfaceMesh& surfMesh = *(*ibcMesh).second;

//       if (BC.condition().Type()==PDECondition::dirichlet) {
// 	bool proceed = false;
// 	for (size_t n=0; n<6; ++n)
// 	  if(BC.boundary().StructMesh(i))
// 	    proceed=true;
// 	if (proceed) {
// 	  const Dirichlet& D = dynamic_cast<const Dirichlet&>(BC.condition());

// 	  for (size_t vert=0; vert<surfMesh.SurfElements().size(); vert++)
// 	    for (size_t k=0; k<surfMesh.SurfElements(vert).NbQuadVertices(); k++) {
// 	      const QuadratureVertex& q = surfMesh.SurfElements(vert).QuadVertices(k);

// 	      const Index& iv = SMesh.vertexIndex(q); // Index of the vertex of
// 	      // the mesh the closer to q.         
// 	      const Vertex& V = SMesh.vertex(iv);

// 	      const real_t GValue = D.f(V);

// 	      const size_t I = SMesh.number(V);

// // 		switch (pdePb.Dimension()) {
// // 		case 1: {
// // 		  dirichletEliminate(I, i, GValue,
// // 				     static_cast<DoubleHashedMatrix<real_t>&>(*A),
// // 				     static_cast<Vector<real_t>&>(*b));
// // 		  break;
// // 		}
// // 		case 2: {
// // 		  dirichletEliminate(I, i, GValue,
// // 				     static_cast<DoubleHashedMatrix<TinyMatrix<2,2,real_t> >&>(*A),
// // 				     static_cast<Vector<TinyVector<2,real_t> >&>(*b));
// // 		  break;
// // 		}
// // 		case 3: {
// // 		  break;
// // 		}
// // 		case 4: {
// // 		  break;
// // 		}
// // 		default: {
// // 		}
// // 		}
// 	    }
// 	}
//       }
//     }
//   }
}

#endif // MATRIX_MANAGEMENT_HPP