win32 · Шаг 5. Фаза 3 — сборка счётных ядер (H и X)

На этом шаге собираются два счётных ядра под 32 бита:

  • tmc_rth.exe — H‑поляризация (о‑мода);
  • tmc_rtx.exe — X‑мода (требует задания 6 макросов).

Оба — MFC‑приложения (статическая MFC, MultiByte). Оба линкуются с пятью библиотеками: sfile95, prepr, exprint, TMCIndan, TMCLibError.

Перед сборкой: все 6 библиотек Фазы 1 готовы; конфигурация Release, платформа Win32.


5.0 Что уже сделано в проектах ядер

Правки настроек сборки (.vcxproj/.sln), не код:

  • Toolset переключён на v145; добавлены конфигурации (Win32/x64 × Debug/Release).
  • Подключён build\ExeOutput.props; имя exe задаётся через <TargetName> (tmc_rth / tmc_rtx).
  • Удалены жёсткие пути E:\WORK\Source\Include, E:\WORK\Lib, OutputFile=c:\tmc\exe\....
  • Убрана опция линкера /MACHINE:I386 (несовместима с x64; лишняя и для win32), сняты переопределения ObjectFileName/ProgramDataBaseFileName/ PrecompiledHeaderOutputFile=.\Release/ и IgnoreAllDefaultLibraries (последняя ломала линковку MFC).
  • Исправлены пути к общим исходникам: оба проекта ссылались на ..\Tmcrtout\TmcSMatrix.cpp и ..\Tmcrtout\TmcTtoS.cpp (такой папки нет). Реальные файлы лежат в src\viewers\Tmcrtout — пути исправлены на ..\..\viewers\Tmcrtout\….

Правка в коде (общая, нужна и для win32) — П‑3:

  • В kernels\PlanarRT_H\PL_GLFUN.CPP и kernels\PlanarRT_X\Pl_glfun.cpp, функция s_tone (генерация звукового сигнала): современный компилятор удалил интринсики прямого доступа к портам outp/inp (error C3861). Ветка для Windows 95 (программирование таймера 8253 через порты 0x42/0x43/0x61) заменена на резервный Beep(freq, time). Эта ветка на современных ОС недостижима (выше по коду для NT уже вызывается Beep() и return). Звук/частоты считаются как раньше; математика расчётов не затронута. Правка одинакова для win32 и win64.

5.1 tmc_rth.exe — H‑поляризация

  1. Открыть проект ядра H — файл PlanRT_H.vcxproj из папки src\kernels\PlanarRT_H. (У ядер PlanRT_H.sln ссылается на новый .vcxproj — открыть можно и решение, но надёжнее открывать сам .vcxproj.)
  2. Конфигурация Release, платформа Win32.
  3. Проверить линковку: правой кнопкой по проекту → Properties → Linker → Input → Additional Dependencies. Должно быть:

sfile95.lib prepr.lib exprint.lib TMCIndan.lib TMCLibError.lib

  1. Build → Clean Solution (Очистить), затем Build → Build Solution (Собрать).
  2. Результат: dist\win32\bin\tmc_rth.exe.
Linker → Input для ядра (5 библиотек)
Linker → Input для ядра (5 библиотек)

5.2 tmc_rtx.exe — X‑мода (СНАЧАЛА задать 6 макросов!)

X‑мода собирается из тех же исходников, но требует 6 макросов препроцессора. Их задают только в проекте X‑моды через настройки — НЕ в общих заголовках. Это принципиально: общие заголовки (Typerth.h, Tmcgrviw.h) используются также H‑модой и вьюверами, и их правка сломала бы остальные сборки.

Шаг А — задать макросы

  1. Открыть проект X — файл PlanRT_X.vcxproj из папки src\kernels\PlanarRT_X (имя проекта — PlanRT_X, цель сборки — tmc_rtx.exe). Ранее этот файл назывался PlanRT_H.vcxproj; он переименован в PlanRT_X.vcxproj, чтобы согласоваться с именем проекта и с общим решением tamic.slnx (см. раздел «Сборка всего сразу через solution»).
  2. Правой кнопкой по проекту → Properties (Свойства).
  3. Раздел C/C++ → Preprocessor → Preprocessor Definitions (Препроцессор → Определения препроцессора).
  4. Добавить шесть макросов (через точку с запятой), сохранив существующее значение %(PreprocessorDefinitions) в конце:

ELECTRON_Q___;ELECTRON_M___;CTMCRTH_INDANBLCK_FILEY;CTMCRTH_INDANBLCK_RECTSTATY;CTMCRTH_INDANBLCK_CIRCSTATY;CTMCRTH_INDANBLCK_POLYGSTTY;%(PreprocessorDefinitions)

  1. Нажать OK.

Эти макросы уже заданы во всех 4 конфигурациях проекта X‑моды. Шаг А нужен, если вы открываете «голый» проект без них.

Preprocessor Definitions с шестью макросами X‑моды
Preprocessor Definitions с шестью макросами X‑моды

Назначение макросов

Макрос Что включает
ELECTRON_Q___ использование заряда электрона в расчёте X‑моды
ELECTRON_M___ использование массы электрона в расчёте X‑моды
CTMCRTH_INDANBLCK_FILEY блок задания структуры из файла
CTMCRTH_INDANBLCK_RECTSTATY блок прямоугольных включений
CTMCRTH_INDANBLCK_CIRCSTATY блок круглых включений
CTMCRTH_INDANBLCK_POLYGSTTY блок полигональных включений

Шаг Б — собрать

  1. Конфигурация Release, платформа Win32.
  2. Линковка — те же 5 библиотек, что у H‑моды (см. 5.1).
  3. Build → Clean Solution, затем Build → Build Solution.
  4. Результат: dist\win32\bin\tmc_rtx.exe.

Признак, что макросы применились: tmc_rtx.exe заметно крупнее tmc_rth.exe — макросы включают дополнительный код типов блоков.


5.3 Проверка Фазы 3

В <КОРЕНЬ>\dist\win32\bin добавились:

tmc_rth.exe
tmc_rtx.exe

Прогоните оба ядра на тестовых наборах из samples\SAMPLE_R.

Историческое примечание о кнопке «Статистика»: ранее в H и X моде при нажатии «View statistics» (Shift+F4) программа молча закрывалась (Баг #1). Этот баг исправлен правкой кода — подробности в 07-troubleshooting.md. Если у вас исходник без этой правки, баг проявится; решение там же.

Если оба ядра собраны — переходите к 06-build-fieldview.md (Фаза 4 — FieldView).


Чек‑лист «что уточнить»

  • [ ] Согласовать с автором (К.Н. Климов) физическую трактовку 6 макросов X‑моды.

win32 · Step 5. Phase 3 — building the compute kernels (H and X)

In this step two compute kernels are built for 32 bits:

  • tmc_rth.exe — H-polarization (o-mode);
  • tmc_rtx.exe — X-mode (requires 6 macros to be set).

Both are MFC applications (static MFC, MultiByte). Both link against five libraries: sfile95, prepr, exprint, TMCIndan, TMCLibError.

Before building: all 6 libraries from Phase 1 are ready; configuration Release, platform Win32.


5.0 What has already been done in the kernel projects

Build-settings changes (.vcxproj/.sln), not code:

  • The toolset was switched to v145; configurations were added (Win32/x64 × Debug/Release).
  • build\ExeOutput.props is attached; the exe name is set via <TargetName> (tmc_rth / tmc_rtx).
  • Hard paths E:\WORK\Source\Include, E:\WORK\Lib, OutputFile=c:\tmc\exe\... were removed.
  • The linker option /MACHINE:I386 was removed (incompatible with x64; unnecessary for win32 too); the overrides ObjectFileName/ProgramDataBaseFileName/PrecompiledHeaderOutputFile=.\Release/ and IgnoreAllDefaultLibraries (the last one broke MFC linking) were removed.
  • Paths to shared sources were fixed: both projects referenced ..\Tmcrtout\TmcSMatrix.cpp and ..\Tmcrtout\TmcTtoS.cpp (no such folder). The real files are in src\viewers\Tmcrtout — the paths were fixed to ..\..\viewers\Tmcrtout\….

A code change (shared, needed for win32 too) — P-3:

  • In kernels\PlanarRT_H\PL_GLFUN.CPP and kernels\PlanarRT_X\Pl_glfun.cpp, the function s_tone (sound-signal generation): the modern compiler removed the intrinsics for direct port access outp/inp (error C3861). The Windows 95 branch (programming the 8253 timer via ports 0x42/0x43/0x61) was replaced with a fallback Beep(freq, time). This branch is unreachable on modern OSes (higher up in the code Beep() and return are already called for NT). The sound/frequencies are computed as before; the computation math is not affected. The change is identical for win32 and win64.

5.1 tmc_rth.exe — H-polarization

  1. Open the H-kernel project — the file PlanRT_H.vcxproj from the folder src\kernels\PlanarRT_H. (For the kernels PlanRT_H.sln references the new .vcxproj — you can open the solution too, but opening the .vcxproj itself is more reliable.)
  2. Configuration Release, platform Win32.
  3. Check the linking: right-click the project -> Properties -> Linker -> Input -> Additional Dependencies. It must be:

sfile95.lib prepr.lib exprint.lib TMCIndan.lib TMCLibError.lib

  1. Build -> Clean Solution, then Build -> Build Solution.
  2. Result: dist\win32\bin\tmc_rth.exe.
Linker -> Input for the kernel (5 libraries)
Linker -&gt; Input for the kernel (5 libraries)

5.2 tmc_rtx.exe — X-mode (SET the 6 macros FIRST!)

The X-mode is built from the same sources, but requires 6 preprocessor macros. They are set only in the X-mode project via its settings — NOT in the shared headers. This is essential: the shared headers (Typerth.h, Tmcgrviw.h) are also used by the H-mode and the viewers, and editing them would break the other builds.

Step A — set the macros

  1. Open the X project — the file PlanRT_X.vcxproj from the folder src\kernels\PlanarRT_X (the project name is PlanRT_X, the build target is tmc_rtx.exe). This file was previously named PlanRT_H.vcxproj; it was renamed to PlanRT_X.vcxproj to match the project name and the combined solution tamic.slnx (see the "Building everything at once via the solution" section).
  2. Right-click the project -> Properties.
  3. Section C/C++ -> Preprocessor -> Preprocessor Definitions.
  4. Add the six macros (separated by semicolons), keeping the existing %(PreprocessorDefinitions) value at the end:

ELECTRON_Q___;ELECTRON_M___;CTMCRTH_INDANBLCK_FILEY;CTMCRTH_INDANBLCK_RECTSTATY;CTMCRTH_INDANBLCK_CIRCSTATY;CTMCRTH_INDANBLCK_POLYGSTTY;%(PreprocessorDefinitions)

  1. Click OK.

These macros are already set in all 4 configurations of the X-mode project. Step A is needed if you open a "bare" project without them.

Preprocessor Definitions with the six X-mode macros
Preprocessor Definitions with the six X-mode macros

Purpose of the macros

Macro What it enables
ELECTRON_Q___ use of the electron charge in the X-mode computation
ELECTRON_M___ use of the electron mass in the X-mode computation
CTMCRTH_INDANBLCK_FILEY block for defining a structure from a file
CTMCRTH_INDANBLCK_RECTSTATY block of rectangular inclusions
CTMCRTH_INDANBLCK_CIRCSTATY block of circular inclusions
CTMCRTH_INDANBLCK_POLYGSTTY block of polygonal inclusions

Step B — build

  1. Configuration Release, platform Win32.
  2. Linking — the same 5 libraries as the H-mode (see 5.1).
  3. Build -> Clean Solution, then Build -> Build Solution.
  4. Result: dist\win32\bin\tmc_rtx.exe.

A sign that the macros were applied: tmc_rtx.exe is noticeably larger than tmc_rth.exe — the macros enable additional block-type code.


5.3 Verifying Phase 3

In <ROOT>\dist\win32\bin the following were added:

tmc_rth.exe
tmc_rtx.exe

Run both kernels on the test sets from samples\SAMPLE_R.

Historical note about the "Statistics" button: previously in the H and X modes, pressing "View statistics" (Shift+F4) silently closed the program (Bug #1). This bug is fixed by a code change — details in 07-troubleshooting.md. If your source lacks this fix, the bug will appear; the solution is there too.

If both kernels are built, proceed to 06-build-fieldview.md (Phase 4 — FieldView).