nec2++ 2.1.1
c_geometry.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2004-2011 Timothy C.A. Molteno
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 2 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, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18#pragma once
19#include "math_util.h"
20#include <vector>
21#include <iostream>
22#include <istream>
23
24/* Replaces the "10000" limit used to */
25/* identify segment/patch connections */
26#define PCHCON 100000
27
28class nec_context;
29#include "nec_output.h"
30#include "nec_wire.h"
31
32
33
52{
53public:
54 c_geometry();
55 void set_context(nec_context* m_context);
56
57
65 void wire( int tag_id, int segment_count,
66 nec_float xw1, nec_float yw1, nec_float zw1, // first co-ordinate
67 nec_float xw2, nec_float yw2, nec_float zw2, // second co-ordinate
68 nec_float rad,
69 nec_float rdel, nec_float rrad);
70
71
72 void arc( int tag_id, int segment_count, nec_float rada,
73 nec_float ang1, nec_float ang2, nec_float rad );
74
75 void helix(int tag_id, int segment_count,
76 nec_float s, nec_float hl, nec_float a1, nec_float b1,
77 nec_float a2, nec_float b2, nec_float rad);
78
79 void move( nec_float rox, nec_float roy, nec_float roz, nec_float xs,
80 nec_float ys, nec_float zs, int its, int nrpt, int itgi );
81
89 void reflect(int ix, int iy, int iz, int itx) {
90 int nop = 100*ix + 10*iy + iz;
91 this->reflect(ix, iy, iz, itx, nop);
92 }
93
99 void generate_cylindrical_structure(int itx, int nop)
100 {
101 this->reflect(-1, 0, 0, itx, nop);
102 }
103
104 void reflect( int ix, int iy, int iz, int itx, int nop );
105
107 void scale( nec_float xw1);
108
109 void patch( int nx, int ny,
110 nec_float ax1, nec_float ay1, nec_float az1,
111 nec_float ax2, nec_float ay2, nec_float az2,
112 nec_float ax3, nec_float ay3, nec_float az3,
113 nec_float ax4, nec_float ay4, nec_float az4 );
114
115
116 void sp_card( int ns,
117 nec_float in_x1, nec_float in_y1, nec_float in_z1,
118 nec_float in_x2, nec_float in_y2, nec_float in_z2);
119
120 void sc_card( int i2,
121 nec_float x3, nec_float y3, nec_float z3,
122 nec_float x4, nec_float y4, nec_float z4);
123 void sc_multiple_card(int i2,
124 nec_float x3, nec_float y3, nec_float z3,
125 nec_float x4, nec_float y4, nec_float z4);
126
127 void gx_card(int card_int_1, int card_int_2);
128
135 void set_intersection_check(bool enable) { _check_intersections = enable; }
136
140 void geometry_complete(nec_context* m_context, int gpflag);
141
142
143
146 void parse_geometry(nec_context* m_context, FILE* input_fp);
147
148
151 int test_ek_approximation(int seg1, int seg2);
152
153 int get_segment_number( int in_tag, int m);
154
155
156 void frequency_scale(nec_float freq_mhz);
157
158 void tbf( int i, int icap);
159 void trio( int j );
160
161 void get_current_coefficients(nec_float wavelength, complex_array& curx,
162 real_array& air, real_array& aii,
163 real_array& bir, real_array& bii,
164 real_array& cir, real_array& cii,
165 complex_array& vqds, int nqds,
166 int_array& iqds);
167
168 nec_float patch_angle(int patch_index, nec_float in_ax, nec_float in_ay, nec_float in_az);
169
172 void fflds(nec_float rox, nec_float roy, nec_float roz,
173 complex_array& scur,
174 nec_complex *in_ex, nec_complex *in_ey, nec_complex *in_ez );
175
176 int n_segments; // The number of segments
177 int np;
178 int_array segment_tags;
179 real_array x, y, z, segment_length, segment_radius;
180 real_array x2, y2, z2;
181 real_array cab, sab, salp;
182
183 int m, mp; // The number of patches
184 int m_ipsym;
185
186 real_array t1x, t1y, t1z, t2x, t2y, t2z; // t1, t2 basis co-ordinates?
187 real_array px, py, pz, pbi, psalp; // patch data
188
189
190 int_array icon1, icon2;
191 // Connected Segment Information (was common /segj/ in FORTRAN code)
192 int jsno, nscon, maxcon; /* Max. no. connections */
193 int_array jco;
194 real_array ax, bx, cx;
195
196 inline int n_plus_m(void) const {
197 return n_segments + m;
198 }
199 int n_plus_2m, n_plus_3m; /* n+m,n+2m,n+3m */
200private:
201 // The geometry data measured in meters is stored in these arrays
202 // and the x,y,z,si,bi arrays are then scaled for each frequency
203 real_array x_unscaled, y_unscaled, z_unscaled, si_unscaled, bi_unscaled;
204 real_array px_unscaled, py_unscaled, pz_unscaled, pbi_unscaled;
205
206 void sbf( int i, int is, nec_float *aa, nec_float *bb, nec_float *cc );
207
208 void divide_patch( int nx );
209
210 void connect_segments( int ignd );
211 void build_connections( int ignd );
212 void resolve_junctions();
213
214 /* Parses a geometry card from a line buffer (shared by FILE* and istream overloads) */
215 void parse_geometry_card_line(const char* line_buf, char *gm,
216 int *i1, int *i2,
217 nec_float *x1, nec_float *y1,nec_float *z1,
218 nec_float *x2, nec_float *y2, nec_float *z2,
219 nec_float *rad );
220
221 void read_geometry_card(FILE* input_fp, char *gm,
222 int *i1, int *i2,
223 nec_float *x1, nec_float *y1,nec_float *z1,
224 nec_float *x2, nec_float *y2, nec_float *z2,
225 nec_float *rad );
226 void read_geometry_card(std::istream& is, char *gm,
227 int *i1, int *i2,
228 nec_float *x1, nec_float *y1,nec_float *z1,
229 nec_float *x2, nec_float *y2, nec_float *z2,
230 nec_float *rad );
231
232 nec_context* m_context;
233 nec_output_file* m_output;
234 bool _check_intersections;
235
236 std::vector<nec_wire> m_wires;
237
238 void reflect_plane(int sym_plane, int& tag_increment);
239
245 struct geometry_parse_state {
246 char gm[3] = {0,0,0};
247 int card_int_1 = 0, card_int_2 = 0;
248 nec_float xw1=0, yw1=0, zw1=0, xw2=0, yw2=0, zw2=0, rad=0;
249 nec_float x3=0, y3=0, z3=0, x4=0, y4=0, z4=0; // patch corners carried SP/SM -> SC
250 int isct = 0; // patch continuation flag (set by SP, consumed by following SC)
251 int nwire = 0; // running count of wire/arc/helix elements
252 };
253
254 void parse_structure_header();
255 void parse_gw_card(FILE* input_fp, geometry_parse_state& st);
256 void parse_gr_card(geometry_parse_state& st);
257 void parse_gs_card(geometry_parse_state& st);
258 void parse_gm_card(geometry_parse_state& st);
259 void parse_sp_card(FILE* input_fp, geometry_parse_state& st);
260 void parse_sm_card(FILE* input_fp, geometry_parse_state& st);
261 void parse_ga_card(geometry_parse_state& st);
262 void parse_sc_card(geometry_parse_state& st);
263 void parse_gh_card(geometry_parse_state& st);
264 void parse_geometry_error(const geometry_parse_state& st);
265
266 int patch_type;
267 nec_3vector patch_x1, patch_x2, patch_x3, patch_x4;
268 bool _prev_sc;
269};
Definition c_geometry.h:52
void reflect(int ix, int iy, int iz, int itx)
Reflects partial structure along x,y, or z axes.
Definition c_geometry.h:89
void fflds(nec_float rox, nec_float roy, nec_float roz, complex_array &scur, nec_complex *in_ex, nec_complex *in_ey, nec_complex *in_ez)
Calculate the xyz components of the electric field due to surface currents.
Definition c_geometry.cpp:3144
void patch(int nx, int ny, nec_float ax1, nec_float ay1, nec_float az1, nec_float ax2, nec_float ay2, nec_float az2, nec_float ax3, nec_float ay3, nec_float az3, nec_float ax4, nec_float ay4, nec_float az4)
patch generates and modifies patch geometry data.
Definition c_geometry.cpp:2050
void scale(nec_float xw1)
Scale all dimensions of a structure by a constant.
Definition c_geometry.cpp:1401
void wire(int tag_id, int segment_count, nec_float xw1, nec_float yw1, nec_float zw1, nec_float xw2, nec_float yw2, nec_float zw2, nec_float rad, nec_float rdel, nec_float rrad)
Generates segment geometry for a straingt wire.
Definition c_geometry.cpp:633
int get_segment_number(int in_tag, int m)
Get a segment number for a specified tag.
Definition c_geometry.cpp:62
void geometry_complete(nec_context *m_context, int gpflag)
Geometry is complete.
Definition c_geometry.cpp:450
void set_intersection_check(bool enable)
Enable or disable segment intersection checking. Intersection checking is on by default....
Definition c_geometry.h:135
void generate_cylindrical_structure(int itx, int nop)
Rotates structure along Z-axis to generate a copies in a cylindrical array.
Definition c_geometry.h:99
void parse_geometry(nec_context *m_context, FILE *input_fp)
Parse an NEC geometry description contained in the file input_fp.
Definition c_geometry.cpp:110
int test_ek_approximation(int seg1, int seg2)
Helper method to decide whether extended. thin-wire approximation can be used.
Definition c_geometry.cpp:3172
Container for an nec2++ simulation.
Definition nec_context.h:80
Definition nec_output.h:53