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
31
39 int64_t inside_index;
40 int64_t container_index;
41 int inside_tag;
42 int container_tag;
43 nec_float distance;
44 nec_float container_radius;
45};
46
65{
66public:
67 c_geometry();
68 void set_context(nec_context* m_context);
69
70
78 void wire( int tag_id, int segment_count,
79 nec_float xw1, nec_float yw1, nec_float zw1, // first co-ordinate
80 nec_float xw2, nec_float yw2, nec_float zw2, // second co-ordinate
81 nec_float rad,
82 nec_float rdel, nec_float rrad);
83
84
85 void arc( int tag_id, int segment_count, nec_float rada,
86 nec_float ang1, nec_float ang2, nec_float rad );
87
88 void helix(int tag_id, int segment_count,
89 nec_float s, nec_float hl, nec_float a1, nec_float b1,
90 nec_float a2, nec_float b2, nec_float rad);
91
92 void move( nec_float rox, nec_float roy, nec_float roz, nec_float xs,
93 nec_float ys, nec_float zs, int its, int nrpt, int itgi );
94
102 void reflect(int ix, int iy, int iz, int itx) {
103 int nop = 100*ix + 10*iy + iz;
104 this->reflect(ix, iy, iz, itx, nop);
105 }
106
112 void generate_cylindrical_structure(int itx, int nop)
113 {
114 this->reflect(-1, 0, 0, itx, nop);
115 }
116
117 void reflect( int ix, int iy, int iz, int itx, int nop );
118
120 void scale( nec_float xw1);
121
122 void patch( int nx, int ny,
123 nec_float ax1, nec_float ay1, nec_float az1,
124 nec_float ax2, nec_float ay2, nec_float az2,
125 nec_float ax3, nec_float ay3, nec_float az3,
126 nec_float ax4, nec_float ay4, nec_float az4 );
127
128
129 void sp_card( int ns,
130 nec_float in_x1, nec_float in_y1, nec_float in_z1,
131 nec_float in_x2, nec_float in_y2, nec_float in_z2);
132
133 void sc_card( int i2,
134 nec_float x3, nec_float y3, nec_float z3,
135 nec_float x4, nec_float y4, nec_float z4);
136 void sc_multiple_card(int i2,
137 nec_float x3, nec_float y3, nec_float z3,
138 nec_float x4, nec_float y4, nec_float z4);
139
140 void gx_card(int card_int_1, int card_int_2);
141
148 void set_intersection_check(bool enable) { _check_intersections = enable; }
149
154 void set_intersection_fatal(bool fatal) { _overlap_is_fatal = fatal; }
155
160 const std::vector<nec_overlap_finding>& overlap_findings() const { return m_overlap_findings; }
161
165 void geometry_complete(nec_context* m_context, int gpflag);
166
167
168
171 void parse_geometry(nec_context* m_context, FILE* input_fp);
172
173
176 int test_ek_approximation(int seg1, int seg2);
177
178 int64_t get_segment_number( int in_tag, int m);
179
180
181 void frequency_scale(nec_float freq_mhz);
182
183 void tbf( int i, int icap);
184 void trio( int j );
185
186 void get_current_coefficients(nec_float wavelength, complex_array& curx,
187 real_array& air, real_array& aii,
188 real_array& bir, real_array& bii,
189 real_array& cir, real_array& cii,
190 complex_array& vqds, int nqds,
191 int_array& iqds);
192
193 nec_float patch_angle(int patch_index, nec_float in_ax, nec_float in_ay, nec_float in_az);
194
197 void fflds(nec_float rox, nec_float roy, nec_float roz,
198 complex_array& scur,
199 nec_complex *in_ex, nec_complex *in_ey, nec_complex *in_ez );
200
201 int64_t n_segments; // The number of segments
202 int64_t np;
203 int_array segment_tags;
204 real_array x, y, z, segment_length, segment_radius;
205 real_array x2, y2, z2;
206 real_array cab, sab, salp;
207
208 int64_t m, mp; // The number of patches
209 int m_ipsym;
210
211 real_array t1x, t1y, t1z, t2x, t2y, t2z; // t1, t2 basis co-ordinates?
212 real_array px, py, pz, pbi, psalp; // patch data
213
214
215 int_array icon1, icon2;
216 // Connected Segment Information (was common /segj/ in FORTRAN code)
217 int jsno, nscon, maxcon; /* Max. no. connections */
218 int_array jco;
219 real_array ax, bx, cx;
220
221 inline int64_t n_plus_m(void) const {
222 return n_segments + m;
223 }
224 int64_t n_plus_2m, n_plus_3m; /* n+m,n+2m,n+3m */
225private:
226 // The geometry data measured in meters is stored in these arrays
227 // and the x,y,z,si,bi arrays are then scaled for each frequency
228 real_array x_unscaled, y_unscaled, z_unscaled, si_unscaled, bi_unscaled;
229 real_array px_unscaled, py_unscaled, pz_unscaled, pbi_unscaled;
230
231 void sbf( int i, int is, nec_float *aa, nec_float *bb, nec_float *cc );
232
233 void divide_patch( int nx );
234
235 void connect_segments( int ignd );
236
243 void check_segment_intersections();
244
245 void collect_overlap_findings();
246
247 void build_connections( int ignd );
248 void resolve_junctions();
249
250 /* Parses a geometry card from a line buffer (shared by FILE* and istream overloads) */
251 void parse_geometry_card_line(const char* line_buf, char *gm,
252 int *i1, int *i2,
253 nec_float *x1, nec_float *y1,nec_float *z1,
254 nec_float *x2, nec_float *y2, nec_float *z2,
255 nec_float *rad );
256
257 void read_geometry_card(FILE* input_fp, char *gm,
258 int *i1, int *i2,
259 nec_float *x1, nec_float *y1,nec_float *z1,
260 nec_float *x2, nec_float *y2, nec_float *z2,
261 nec_float *rad );
262 void read_geometry_card(std::istream& is, char *gm,
263 int *i1, int *i2,
264 nec_float *x1, nec_float *y1,nec_float *z1,
265 nec_float *x2, nec_float *y2, nec_float *z2,
266 nec_float *rad );
267
268 nec_context* m_context;
269 nec_output_file* m_output;
270 bool _check_intersections;
271 bool _overlap_is_fatal;
272 std::vector<nec_overlap_finding> m_overlap_findings;
273
274 void reflect_plane(int sym_plane, int& tag_increment);
275
281 struct geometry_parse_state {
282 char gm[3] = {0,0,0};
283 int card_int_1 = 0, card_int_2 = 0;
284 nec_float xw1=0, yw1=0, zw1=0, xw2=0, yw2=0, zw2=0, rad=0;
285 nec_float x3=0, y3=0, z3=0, x4=0, y4=0, z4=0; // patch corners carried SP/SM -> SC
286 int isct = 0; // patch continuation flag (set by SP, consumed by following SC)
287 int nwire = 0; // running count of wire/arc/helix elements
288 };
289
290 void parse_structure_header();
291 void parse_gw_card(FILE* input_fp, geometry_parse_state& st);
292 void parse_gr_card(geometry_parse_state& st);
293 void parse_gs_card(geometry_parse_state& st);
294 void parse_gm_card(geometry_parse_state& st);
295 void parse_sp_card(FILE* input_fp, geometry_parse_state& st);
296 void parse_sm_card(FILE* input_fp, geometry_parse_state& st);
297 void parse_ga_card(geometry_parse_state& st);
298 void parse_sc_card(geometry_parse_state& st);
299 void parse_gh_card(geometry_parse_state& st);
300 void parse_geometry_error(const geometry_parse_state& st);
301
302 int patch_type;
303 nec_3vector patch_x1, patch_x2, patch_x3, patch_x4;
304 bool _prev_sc;
305};
Definition c_geometry.h:65
int64_t get_segment_number(int in_tag, int m)
Get a segment number for a specified tag.
Definition c_geometry.cpp:76
void reflect(int ix, int iy, int iz, int itx)
Reflects partial structure along x,y, or z axes.
Definition c_geometry.h:102
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:3421
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:2315
void scale(nec_float xw1)
Scale all dimensions of a structure by a constant.
Definition c_geometry.cpp:1308
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:614
void set_intersection_fatal(bool fatal)
Choose what an overlap finding does.
Definition c_geometry.h:154
void geometry_complete(nec_context *m_context, int gpflag)
Geometry is complete.
Definition c_geometry.cpp:454
void set_intersection_check(bool enable)
Enable or disable segment intersection checking. Intersection checking is on by default....
Definition c_geometry.h:148
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:112
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:115
int test_ek_approximation(int seg1, int seg2)
Helper method to decide whether extended. thin-wire approximation can be used.
Definition c_geometry.cpp:3449
const std::vector< nec_overlap_finding > & overlap_findings() const
The overlap findings the last geometry check produced.
Definition c_geometry.h:160
Container for an nec2++ simulation.
Definition nec_context.h:80
Definition nec_output.h:53
One segment center found inside the volume of a segment that it does not meet at a shared node.
Definition c_geometry.h:38