1 /*
2 *	Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
3 *
4 *	This program is free software: you can redistribute it and/or modify
5 *	it under the terms of the GNU General Public License as published by
6 *	the Free Software Foundation, either version 3 of the License, or
7 *	(at your option) any later version.
8 *
9 *	This program is distributed in the hope that it will be useful,
10 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *	GNU General Public License for more details.
13 *
14 *	You should have received a copy of the GNU General Public License
15 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #include "operator_base.h"
19 
20 using namespace std;
21 
Operator_Base()22 Operator_Base::Operator_Base()
23 {
24 	Init();
25 	m_MeshType = CARTESIAN;
26 	m_StoreMaterial[0]=false;
27 	m_StoreMaterial[1]=false;
28 	m_StoreMaterial[2]=false;
29 	m_StoreMaterial[3]=false;
30 }
31 
~Operator_Base()32 Operator_Base::~Operator_Base()
33 {
34 	Delete();
35 }
36 
SetGeometryCSX(ContinuousStructure * geo)37 bool Operator_Base::SetGeometryCSX(ContinuousStructure* geo)
38 {
39 	if (geo==NULL) return false;
40 	CSX = geo;
41 
42 	return true;
43 }
44 
GetDirName(int ny) const45 std::string Operator_Base::GetDirName(int ny) const
46 {
47 	if (ny==0) return "x";
48 	if (ny==1) return "y";
49 	if (ny==2) return "z";
50 	return "";
51 }
52 
Init()53 void Operator_Base::Init()
54 {
55 	CSX = NULL;
56 
57 	dT = 0;
58 	for (int n=0; n<3; ++n)
59 		discLines[n]=NULL;
60 	for (int n=0; n<6; ++n)
61 		m_BC[n]=0;
62 
63 	SetBackgroundMaterial(1,1,0,0);
64 }
65 
Delete()66 void Operator_Base::Delete()
67 {
68 	for (int n=0; n<3; ++n)
69 	{
70 		delete[] discLines[n];
71 		discLines[n]=0;
72 	}
73 	for (int n=0; n<6; ++n)
74 		m_BC[n]=0;
75 	dT = 0;
76 }
77 
Reset()78 void Operator_Base::Reset()
79 {
80 	Delete();
81 }
82 
SetMaterialStoreFlags(int type,bool val)83 void Operator_Base::SetMaterialStoreFlags(int type, bool val)
84 {
85 	if ((type<0) || (type>4))
86 		return;
87 	m_StoreMaterial[type]=val;
88 }
89 
GetCellCenterMaterialAvgCoord(const unsigned int pos[3],double coord[3]) const90 bool Operator_Base::GetCellCenterMaterialAvgCoord(const unsigned int pos[3], double coord[3]) const
91 {
92 	int ipos[3] = {(int)pos[0], (int)pos[1], (int)pos[2]};
93 	return GetCellCenterMaterialAvgCoord(ipos, coord);
94 }
95 
SetBackgroundMaterial(double epsR,double mueR,double kappa,double sigma,double density)96 void Operator_Base::SetBackgroundMaterial(double epsR, double mueR, double kappa, double sigma, double density)
97 {
98 	SetBackgroundEpsR(epsR);
99 	SetBackgroundMueR(mueR);
100 	SetBackgroundKappa(kappa);
101 	SetBackgroundSigma(sigma);
102 	SetBackgroundDensity(density);
103 }
104 
SetBackgroundEpsR(double val)105 void Operator_Base::SetBackgroundEpsR(double val)
106 {
107 	if (val<1)
108 	{
109 		cerr << __func__ << ": Warning, a relative electric permittivity <1 it not supported, skipping" << endl;
110 		return;
111 	}
112 	m_BG_epsR=val;
113 }
114 
SetBackgroundMueR(double val)115 void Operator_Base::SetBackgroundMueR(double val)
116 {
117 	if (val<1)
118 	{
119 		cerr << __func__ << ": Warning, a relative magnetic permeability <1 it not supported, skipping" << endl;
120 		return;
121 	}
122 	m_BG_mueR=val;
123 }
124 
SetBackgroundKappa(double val)125 void Operator_Base::SetBackgroundKappa(double val)
126 {
127 	if (val<0)
128 	{
129 		cerr << __func__ << ": Warning, an electric conductivity <0 it not supported, skipping" << endl;
130 		return;
131 	}
132 	m_BG_kappa=val;
133 }
134 
SetBackgroundSigma(double val)135 void Operator_Base::SetBackgroundSigma(double val)
136 {
137 	if (val<0)
138 	{
139 		cerr << __func__ << ": Warning, an artifival magnetic conductivity <0 it not supported, skipping" << endl;
140 		return;
141 	}
142 	m_BG_sigma=val;
143 }
144 
145 
SetBackgroundDensity(double val)146 void Operator_Base::SetBackgroundDensity(double val)
147 {
148 	if (val<0)
149 	{
150 		cerr << __func__ << ": Warning, a mass density <0 it not supported, skipping" << endl;
151 		return;
152 	}
153 	m_BG_density=val;
154 }
155