00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MESH_H
00021 #define MESH_H
00022
00023 #include <vector>
00024 #include "edge.h"
00025 #include "cmindices.h"
00026 #include "config.h"
00027 #include "elementintegrator.h"
00028 #include "moments.h"
00029 #include "matrixss.h"
00030 #ifdef HAVE_LIBPLPLOTCXXD
00031 #include <plplot/plstream.h>
00032 #endif
00033
00034 typedef std::vector<int> elements;
00035 typedef std::vector<double> charges;
00036
00037 namespace nanomagn {
00038
00039 class group;
00040
00050 class mesh: public elementintegrator {
00051
00055 int nrule;
00056
00060 int maxpole;
00061
00065 conftrans CT;
00066
00070 edges Edges;
00071
00075 elements Elements;
00076
00080 std::vector<group*> baseGroups;
00081
00085 std::vector<moments> Moments;
00086
00090 cmindices cmi;
00091
00095 matrixss bulkmss;
00096
00100 matrixss sidemss;
00101
00105 matrixss sidevolmss;
00106
00110 matrixValues nimF;
00111
00115 matrixValues nimV;
00116
00120 matrixValues nimS;
00121
00125 matrixValues nimSV;
00126
00130 double normFactor;
00131 public:
00132
00139 mesh(conftrans CT, int nrule, int maxpole);
00140
00145 void reserve(int nelemreq);
00146
00150 void printMesh() const;
00151
00152 #ifdef HAVE_LIBPLPLOTCXXD
00153
00156 void drawMesh() const;
00157 #endif
00158
00162 inline void clearBaseGroupLinks() {
00163 baseGroups.clear();
00164 baseGroups.resize(getNElements());
00165 };
00166
00170 inline void clearNearInts() {
00171 bulkmss.clearIdx();
00172 sidemss.clearIdx();
00173 sidevolmss.clearIdx();
00174 };
00175
00179 inline bool isNearIntSymmetric() const {
00180 return bulkmss.isSymmetric() && sidemss.isSymmetric();
00181 };
00182
00186 inline void reduceNearInts() {
00187 bulkmss.reduce();
00188 sidemss.reduce();
00189 };
00190
00199 inline void noteNearInt(int i, int j) {
00200 bulkmss.noteIdx(i,j);
00201 if (isOuterBoundary(i))
00202 if (isOuterBoundary(j)) {
00203 sidemss.noteIdx(i,j);
00204 sidevolmss.noteIdx(i,j);
00205 sidevolmss.noteIdx(j,i);
00206 } else sidevolmss.noteIdx(i,j);
00207 else if (isOuterBoundary(j)) sidevolmss.noteIdx(j,i);
00208 };
00209
00214 inline const matrixss& getNearInteractionIndices() const {
00215 return bulkmss;
00216 };
00217
00223 inline void linkBaseGroup(int nelem, group *grp) {
00224 baseGroups[nelem]=grp;
00225 };
00226
00232 inline const group & getBaseGroup(int nelem) const {
00233 return *baseGroups[nelem];
00234 };
00235
00243 double calcEnergyMS(const charges &chrgF, const charges &chrgV, const charges &chrgS);
00244
00249 inline const cmindices& getCMI() const {
00250 return cmi;
00251 };
00252
00257 inline int getNRule() const {
00258 return nrule;
00259 };
00260
00265
00266
00267
00268
00273 inline int getNElements() const {
00274 int ne=Elements.size();
00275 assert((ne%4)==0);
00276 return ne/4;
00277 };
00278
00283 inline int getNEdges() const {
00284 return Edges.size();
00285 };
00286
00287
00292 inline const edges& getEdges() const {
00293 return Edges;
00294 };
00295
00301 inline const edge& getEdge(int ne) const {
00302 return Edges[ne];
00303 };
00304
00311 inline const edge& getEdge(int nelem, int i) const {
00312 return Edges[Elements[4*nelem+i]];
00313 };
00314
00320 inline const std::vector<const group*> getBaseGroups() const {
00321 return std::vector<const group*>( baseGroups.begin(), baseGroups.end() );
00322 }
00323
00328 inline const conftrans& getConfTrans() const {
00329 return CT;
00330 };
00331
00336 inline bool isOuterBoundary(int nelem) const {
00337 return Edges[Elements[4*nelem+1]].isOuterBoundary();
00338 }
00344 virtual double rintegrate(int nelem, const areaintegrand &integrand) const;
00345
00352 virtual double robintegrate(int nelem, const siderealintegrand &integrand) const;
00353
00360 virtual double robintegrate(int nelem1, int nelem2, const fsintegrand &integrand) const;
00361
00362
00369 virtual double rintegrate2(int nelem1, int nelem2, const fsintegrand &integrand) const;
00370
00376 double area(int nelem) const;
00377
00382 double area() const;
00383
00387 void calculateMoments();
00388
00393 void calculateNearIntMat(double g);
00394
00398 inline const moments& getMoments(int nelem) const {
00399 assert(Moments.size()==getNElements());
00400 return Moments[nelem];
00401 };
00408 int divideElement(int nelem);
00409
00414 bool checkCoverage() const;
00415
00421 int getMeshStorageSize();
00422
00427 int getMomentsStorageSize();
00428
00433 int getMatVFStorageSize();
00434
00439 int getMatSSStorageSize();
00440
00445 int getMatVSStorageSize();
00446
00450 ~mesh();
00451 };
00452
00453 };
00454 #endif