Electromagnetic Template Library (EMTL)
Loading...
Searching...
No Matches
Windows installation

Building for Windows

Contents of the sources

To build EMTL from source you will need the emtl sources (./newfdtd directory) and ivutils library sources (./ivutils directory). The utility library ivutils provides geometrical primitives and other useful functions. Optionally, you may also have tutorial sources (./emtl_doc directory) and high-performance core sources (./hipercone directory). All mentioned directories should be placed in a directory at the same level.

Dependecies

  • CMake >= 3.13
  • C++17 compatibale compiler wich also supports OpenMP

Optional:

  • libfftw3
  • MPI
  • Python3 for python modules
  • swig for python modules (install swig through the distribution from the official website, not through python pip)
  • Doxygen for documentation
  • graphviz for documentation

Building emtl and ivutils in the same project

The easiest way to build emtl is to build it together with ivutils. Put emtl and ivutils in directories at the same level. Then run the following comands:

mkdir build
cd build
cmake -DDEVELOPMENT=ON
cmake --build .

Portable installation

Portable installation allows you to install the emtl library binaries and include files at a specific location. You may then compile your projects with emtl without further need for the EMTL source codes. If the portable installation is required you should provide an install prefix -DCMAKE_INSTALL_PREFIX=~/emtl/. The following command will install all needed files into a prefix:

cmake --install . --prefix=./install

Build via cmake-gui

The cmake-gui program allows you to visually control the options of your EMTL build and the locations of dependency components. Run the following command:

mkdir build
cd build

To launch the GUI, enter the command in the "newfdtd" directory:

cmake-gui

In the window that opens:

  • Select source directory("newfdtd" dir)
  • Select build directory ("build" dir)

Set configuration options

You can use configuration options to fine-tune the build:

  • -DDEVELOPMENT=ON forces cmake to search for ivutils sources at ../ivutils (and hipercone sources at ../hipercone if hipercone is enabled). Paths are given relative to emtl's main CMakeLists. Default value is OFF.
  • -DSINGLE_PRECISION=OFF sets the default floating type to double instead of float. Default value is ON.
  • -DBUILD_STATIC=ON enables static libraries. Default value is OFF for Linux and ON for Windows.
  • -DBUILD_SHARED=ON enables shared libraries. Default value is ON for Windows and OFF for Linux. At least one of library types should be enabled. On Linux, it is possible to build both
  • -DDOCUMENTATION=ON builds documentation. The main page path is doc/emtl/<LANGUAGE>/html/index.html. Available languages are English and Russian, however English documentation has better coverage. Default value is OFF.
  • -DPYTHON=ON builds python modules. Default value is ON.
  • -DMPI_PARALLEL=ON enables mpi support for the library. Default value is OFF
  • -DUSE_HIPERCONE=ON use proprietary module with faster solvers. To indicate the module location use --Dhipercone_ROOT=<PATH_TO_MODULE_DIR> (and disable DEVELOPMENT) or place sources in the directory hipercone on the same level with ivutils.
  • -DFORCE_STATIC=ON forces executables and libraries to be completely static. It requires all dependencies to have static libraries too. The main purpose of this option is to build completely static executables which can be easily launched on different systems. Incompatible with BUILD_SHARED. Default value is OFF.

Important! In GUI you should add var EMTL_ROOT_DIR=<PATH_TO_EMTl_DIR>.

Push the button Configure. A dialog box will appear that offers you to select the compiler and build mode (32 or 64 bit).

In some cases 'Configure' will tell you about what components are missing and you may give a hint to cmake of where to find them. For example, if you are configuring with -DPYTHON=ON the paths to swig directories may be needed:

  • SWIG_DIR=the directory where swig is located%, for example SWIG_DIR=../programs/swigwin-4.1.1/Lib
  • SWIG_EXECUTABLE=the directory where swig.exe is located%, for example SWIG_DIR=../programs/swigwin-4.1.1/Lib/swig.exe

Fill these paths in in the red prompts that would appear after running 'Configure'

After 'Configure' is successful, push the button Generate. Now all the necessary dependencies are installed, it remains to build the project. After generating the makefiles, you will be able to open the project in the IDE. Let's use Visual studio 17 2022 as an example. Let's build:

To build, select Build in the dialog box. For installation of the portable library run the following command in the build directory:

cmake --install . --prefix=./install

or build INSTALL project from the IDE.

Testing the build

Testing the executables

To test the build you can run one of the provided codes. Run folowing command:

.\tests\test_mie\Debug\test_mie.exe

If everything goes right and the calculation starts you'll see these lines:

...
Estimated calculation time for 3200 steps is 0:00:31
Performing 32 time steps
Performing 32 time steps
...

Testing custom experiment build

To test building you need an example code file, like test_dipole.cpp here:

# include "uiextexp.h"

int main(int argc,char **argv){
  emInit(argc,argv);
  uiPyExperiment task;
  task.SetInternalSpace(Vector_3(-32, -32, -32), Vector_3(32, 32, 32));
  task.SetFirstUpdatedField(1);
  task.SetBC(BC_PER, BC_PER, BC_PER);
  task.SetResolution(1);
  task.AddPointDipole(Vector_3(0,0,0),Vector_3(0,0,1),0,1,true);
  task.SetSignal(new Berenger(1,25,5,125));
  task.BuildDimensions();
  task.AddDetectorSet("fc",Vector_3(),Vector_3(),iVector_3(1));
  task.Calculate(64);
  task.Analyze();
  return 0;
}

And you also should create corresponding CMakeLists.txt:

cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(test_dipole)

find_package(emtl REQUIRED COMPONENTS lib dev)
add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cpp)
target_link_libraries(${PROJECT_NAME} emtl::emtl)

In the directory containing both, you can build this test with:

mkdir build
cd build
cmake -Demtl_ROOT=<PATH TO EMTL INSTALL PREFIX> ../
cmake --build .

A successful build will produce the test_dipole executable. You can omit the emtl_ROOT if emtl is installed to the standard paths.

Testing Python module

To test the python module it's enough to load emtl module:

python -m "emtl"

Python module works as long as this command finishes without an error.