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
170 int ground_connection() const { return m_gpflag; }
171
172
173
176 void parse_geometry(nec_context* m_context, FILE* input_fp);
177
178
181 int test_ek_approximation(int seg1, int seg2);
182
183 int64_t get_segment_number( int in_tag, int m);
184
185
186 void frequency_scale(nec_float freq_mhz);
187
188 void tbf( int i, int icap);
189 void trio( int j );
190
191 void get_current_coefficients(nec_float wavelength, complex_array& curx,
192 real_array& air, real_array& aii,
193 real_array& bir, real_array& bii,
194 real_array& cir, real_array& cii,
195 complex_array& vqds, int nqds,
196 int_array& iqds);
197
198 nec_float patch_angle(int patch_index, nec_float in_ax, nec_float in_ay, nec_float in_az);
199
202 void fflds(nec_float rox, nec_float roy, nec_float roz,
203 complex_array& scur,
204 nec_complex *in_ex, nec_complex *in_ey, nec_complex *in_ez );
205
206 int64_t n_segments; // The number of segments
207 int64_t np;
208 int_array segment_tags;
209 real_array x, y, z, segment_length, segment_radius;
210 real_array x2, y2, z2;
211 real_array cab, sab, salp;
212
213 int64_t m, mp; // The number of patches
214 int m_ipsym;
215 int m_gpflag; // Native GE ground flag (0, 1 or -1) from geometry_complete()
216
217 real_array t1x, t1y, t1z, t2x, t2y, t2z; // t1, t2 basis co-ordinates?
218 real_array px, py, pz, pbi, psalp; // patch data
219
220
221 int_array icon1, icon2;
222 // Connected Segment Information (was common /segj/ in FORTRAN code)
223 int jsno, nscon, maxcon; /* Max. no. connections */
224 int_array jco;
225 real_array ax, bx, cx;
226
227 inline int64_t n_plus_m(void) const {
228 return n_segments + m;
229 }
230 int64_t n_plus_2m, n_plus_3m; /* n+m,n+2m,n+3m */
231private:
232 // The geometry data measured in meters is stored in these arrays
233 // and the x,y,z,si,bi arrays are then scaled for each frequency
234 real_array x_unscaled, y_unscaled, z_unscaled, si_unscaled, bi_unscaled;
235 real_array px_unscaled, py_unscaled, pz_unscaled, pbi_unscaled;
236
237 void sbf( int i, int is, nec_float *aa, nec_float *bb, nec_float *cc );
238
239 void divide_patch( int nx );
240
241 void connect_segments( int ignd );
242
249 void check_segment_intersections();
250
251 void collect_overlap_findings();
252
253 void build_connections( int ignd );
254 void resolve_junctions();
255
256 /* Parses a geometry card from a line buffer (shared by FILE* and istream overloads) */
257 void parse_geometry_card_line(const char* line_buf, 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
263 void read_geometry_card(FILE* input_fp, char *gm,
264 int *i1, int *i2,
265 nec_float *x1, nec_float *y1,nec_float *z1,
266 nec_float *x2, nec_float *y2, nec_float *z2,
267 nec_float *rad );
268 void read_geometry_card(std::istream& is, char *gm,
269 int *i1, int *i2,
270 nec_float *x1, nec_float *y1,nec_float *z1,
271 nec_float *x2, nec_float *y2, nec_float *z2,
272 nec_float *rad );
273
274 nec_context* m_context;
275 nec_output_file* m_output;
276 bool _check_intersections;
277 bool _overlap_is_fatal;
278 std::vector<nec_overlap_finding> m_overlap_findings;
279
280 void reflect_plane(int sym_plane, int& tag_increment);
281
287 struct geometry_parse_state {
288 char gm[3] = {0,0,0};
289 int card_int_1 = 0, card_int_2 = 0;
290 nec_float xw1=0, yw1=0, zw1=0, xw2=0, yw2=0, zw2=0, rad=0;
291 nec_float x3=0, y3=0, z3=0, x4=0, y4=0, z4=0; // patch corners carried SP/SM -> SC
292 int isct = 0; // patch continuation flag (set by SP, consumed by following SC)
293 int nwire = 0; // running count of wire/arc/helix elements
294 };
295
296 void parse_structure_header();
297 void parse_gw_card(FILE* input_fp, geometry_parse_state& st);
298 void parse_gr_card(geometry_parse_state& st);
299 void parse_gs_card(geometry_parse_state& st);
300 void parse_gm_card(geometry_parse_state& st);
301 void parse_sp_card(FILE* input_fp, geometry_parse_state& st);
302 void parse_sm_card(FILE* input_fp, geometry_parse_state& st);
303 void parse_ga_card(geometry_parse_state& st);
304 void parse_sc_card(geometry_parse_state& st);
305 void parse_gh_card(geometry_parse_state& st);
306 void parse_geometry_error(const geometry_parse_state& st);
307
308 int patch_type;
309 nec_3vector patch_x1, patch_x2, patch_x3, patch_x4;
310 bool _prev_sc;
311};
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:77
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:3441
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:2335
void scale(nec_float xw1)
Scale all dimensions of a structure by a constant.
Definition c_geometry.cpp:1310
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:616
void set_intersection_fatal(bool fatal)
Choose what an overlap finding does.
Definition c_geometry.h:154
int ground_connection() const
The native GE ground flag (0, 1 or -1) the geometry was completed with.
Definition c_geometry.h:170
void geometry_complete(nec_context *m_context, int gpflag)
Geometry is complete.
Definition c_geometry.cpp:455
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:116
int test_ek_approximation(int seg1, int seg2)
Helper method to decide whether extended. thin-wire approximation can be used.
Definition c_geometry.cpp:3469
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