Giter Club home page Giter Club logo

lean-vtk's Introduction

Lean-VTK build and test

A barebones VTK writer for C++. It is implemented as a single header and source file for easy integration with other projects and only requires the C++ standard library as a dependency.

Example usage

Writing a single triangle to a vtk file:

    vector<double> points = {
             1.,  1., -1.,
             1., -1., 1.,
            -1., -1., 0.
        };
    vector<int> elements = { 0, 1, 2 };
    vector<double> scalar_field = { 0., 1., 2.  };
    vector<double> vector_field = points;;

    const int dim = 3;
    const int cell_size = 3;
    std::string filename = "single_tri.vtu";
    VTUWriter writer;
    
    writer.add_scalar_field("scalar_field", scalar_field);
    writer.add_vector_field("vector_field", vector_field, dim);

    writer.write_surface_mesh(filename, dim, cell_size, points, elements);

Other small examples for triangles, quads, hex and tet elements exist in tests/test_lean_vtk.cpp.

Prerequisites

  • CMake >=3.1
  • A C/C++ compiler with C++11 (tested with gcc 7.5.0)

Installation

Copy and paste

The easiest way to use Lean-VTK is to simply copy and paste include/lean-vtk.hpp and src/lean-vtk.cpp into your project source code explicitly. If you don't mind checking for updates periodically, this is the best way to go.

Subrepository

  1. Add Lean-VTK as a submodule of your project and update the submodules:
git submodule add https://github.com/mmorse1217/lean-vtk
git submodule init

2a. If you are using CMake in your project already, add the following to your root-level CMakeLists.txt:

add_subdirectory(lean-vtk)

and appropriate link Lean-VTK to the project's targets:

target_link_libraries(target LeanVTK)

2b. If your project uses make, see the compilation steps below to compile the project, then appropriately link the library.

Compiling, installing and running

To compile the project, run the following in the project root:

    mkdir build
    cd build
    cmake ..
    make

To install the project in /usr/local/, run the following in the build/ directory created above:

    make install

To run unit tests via CTest, again run the following in the build/ directory:

    make test

or

    ctest

Contributing

Please fork the repo and make a pull request for any future changes.

lean-vtk's People

Contributors

mmorse1217 avatar dtozoni avatar imperators79 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.