implemented mirror mesh, still not working for vol. cells
[engrid.git] / src / vertexmeshdensity.cpp
blob0e1ecab66246ef25d9ebcd0f5bd3035e047f7aeb
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "vertexmeshdensity.h"
24 #include "egvtkobject.h"
25 #include <iostream>
26 using namespace std;
28 VertexMeshDensity::VertexMeshDensity()
30 type = VTK_SIMPLE_VERTEX;
31 CurrentNode = 0;
34 //this=user defined
35 //VMD=VMD of current node
36 //This operator is NOT SYMMETRICAL. But it can be used with indexOf.
37 bool VertexMeshDensity::operator==(const VertexMeshDensity & VMD) const
39 if(this->nodeset.size()>0) //node ID mode
41 if(this->nodeset.contains(VMD.CurrentNode) ) return(true);//node ID given, we're done
42 else return(false);
44 else //node properties mode
46 if(this->type!=VMD.type && this->type!=-1) return(false);
48 QMapIterator<int, int> i(this->BCmap);
49 while (i.hasNext()) {
50 i.next();
51 int index=i.key();
52 if((this->BCmap)[index]!=VMD.BCmap[index] && (this->BCmap)[index]!=1) return(false);
55 return(true);
59 int VertexMeshDensity::findSmallestVMD( QVector <VertexMeshDensity> vector)
61 int ret = -1;
62 double Lmin = 0;
63 bool first = true;
64 for(int i=0;i<vector.size();i++){
65 if(vector[i]==*this) {
66 if(first) {
67 ret = i;
68 Lmin = vector[i].density;
69 first = false;
71 else if(vector[i].density < Lmin) {
72 ret = i;
73 Lmin = vector[i].density;
77 return(ret);
80 //converts string to nodeset
81 void VertexMeshDensity::setNodes(QString str)
83 nodeset.clear();//empty by default
84 // cout<<"str.size="<<str.size()<<endl;
85 if(str.size()>0)
87 QStringList L = str.split(",");
88 foreach(QString elt,L) nodeset.insert(elt.toInt());
92 ostream& operator<<(ostream &out, VertexMeshDensity A)
94 out<<" BCmap="<<A.BCmap;
95 out<<" type="<<(int)A.type;
96 out<<" nodeset="<<A.nodeset;
97 out<<" density="<<A.density;
98 return(out);
101 ostream& operator<<(ostream &out, QVector<VertexMeshDensity> VMDvector)
103 int N=VMDvector.size();
104 out<<"Size="<<N;
105 if(N>0) out<<endl;
106 for(int i=0;i<N;i++)
108 out<<VMDvector[i];
109 if(i!=N-1) out<<endl;
111 return(out);