Commit 877222fe authored by Simon Spannagel's avatar Simon Spannagel
Browse files

MeshConverter: be smart: determine dimensions from mesh, cross-check rotation

parent 2223d509
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -197,21 +197,10 @@ int main(int argc, char** argv) {
        const auto units = config.get<std::string>("observable_units");
        const auto vector_field = config.get<bool>("vector_field", (observable == "ElectricField"));

        XYZVectorUInt divisions;
        const auto dimension = config.get<size_t>("dimension", 3);
        if(dimension == 2) {
            auto divisions_yz = config.get<XYVectorUInt>("divisions", XYVectorUInt(100, 100));
            divisions = XYZVectorUInt(1, divisions_yz.x(), divisions_yz.y());
        } else if(dimension == 3) {
            divisions = config.get<XYZVectorUInt>("divisions", XYZVectorUInt(100, 100, 100));
        } else {
            throw allpix::InvalidValueError(config, "dimension", "only two or three dimensional fields are supported");
        }

        // Swapping elements
        auto rot = config.getArray<std::string>("xyz", {"x", "y", "z"});
        if(rot.size() != 3) {
            throw allpix::InvalidValueError(config, "xyz", "three entries required");
            throw allpix::InvalidValueError(config, "xyz", "Three entries required");
        }

        auto start = std::chrono::system_clock::now();
@@ -219,6 +208,22 @@ int main(int argc, char** argv) {
        std::string grid_file = file_prefix + ".grd";
        std::vector<Point> points = parser->getMesh(grid_file, regions);

        // Obtain number of mesh dimensions from mesh point:
        XYZVectorUInt divisions;
        const auto dimension = points.front().dim;
        LOG(STATUS) << "Determined dimensionality of input mesh to be " << dimension << "D";
        if(dimension == 2) {
            auto divisions_yz = config.get<XYVectorUInt>("divisions", XYVectorUInt(100, 100));
            divisions = XYZVectorUInt(1, divisions_yz.x(), divisions_yz.y());
        } else if(dimension == 3) {
            divisions = config.get<XYZVectorUInt>("divisions", XYZVectorUInt(100, 100, 100));
        }

        // If we are looking at a 2D mesh, we force x to be the coordinate out of range:
        if(dimension == 2 && rot.at(0) != "-x" && rot.at(0) != "x") {
            throw allpix::InvalidValueError(config, "xyz", "For 2D meshes the first coordinate has to remain 'x'");
        }

        std::string data_file = file_prefix + ".dat";
        std::vector<Point> field = parser->getField(data_file, observable, regions);

+1 −1
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ It should be noted that the Mesh Converter depends on the core utilities of the

## Features
- TCAD DF-ISE file format parser.
- Automatic determination of the input mesh dimensionality (2D/3D).
- Fast radius neighbor search for three-dimensional point clouds.
- Barycentric interpolation between non-regular mesh points.
- Several cuts available on the interpolation algorithm variables.
@@ -69,7 +70,6 @@ It should be noted that the Mesh Converter depends on the core utilities of the
### Parameters
* `model`: Field file format to use, can be **INIT** or **APF**, defaults to **APF** (binary format).
* `parser`: Parser class to interpret input data in. Currently, only **DF-ISE** is supported and used as default.
* `dimension`: Specify mesh dimensionality (defaults to 3).
* `region`: Region name or list of region names to be meshed, such as for example `bulk` or `"bulk","epi"` (No default value; required parameter).
* `observable`: Observable to be interpolated, such as for example `ElectricField` (No default value; required parameter).
* `observable_units`: Units in which the observable is stored in the input file (No default value; required parameter).