First steps with Rodin
Build a small program and identify the objects used in a finite element solve.
This guide starts with an installed Rodin library. A small program constructs a triangular mesh and a scalar finite element space, then prints their sizes. The program establishes the objects needed to build a variational problem.
Create an application
A minimal application needs a source file, main.cpp, and a CMakeLists.txt. Mesh data can be generated by the program or loaded from a file. This example generates its mesh and therefore needs no external data.
Configure the build
The imported CMake targets provide Rodin's include directories and link dependencies. The application requests C++20 explicitly.
cmake_minimum_required(VERSION 3.16) project(FirstRodinProgram LANGUAGES CXX) find_package(Rodin REQUIRED) add_executable(first_rodin main.cpp) target_compile_features(first_rodin PRIVATE cxx_std_20) target_link_libraries(first_rodin PRIVATE Rodin::Geometry Rodin::Variational )
If Rodin is installed outside the standard search paths, pass its installation prefix through CMAKE_PREFIX_PATH when configuring the application. The installation guide explains the setup.
Construct a mesh and a space
The mesh describes the domain; P1 describes scalar functions that are continuous across triangles and affine within each triangle.
#include <iostream> #include <Rodin/Geometry.h> #include <Rodin/Variational.h> using namespace Rodin; using namespace Rodin::Geometry; using namespace Rodin::Variational; int main() { Mesh mesh = Mesh().UniformGrid(Polytope::Type::Triangle, {8, 8}); mesh.scale(1.0 / 7.0); P1 vh(mesh); std::cout << "Vertices: " << mesh.getVertexCount() << '\n'; std::cout << "Triangles: " << mesh.getCellCount() << '\n'; std::cout << "Dimension: " << mesh.getDimension() << '\n'; std::cout << "P1 degrees of freedom: " << vh.getSize() << '\n'; return 0; }
UniformGrid takes the vertex count in each direction. Eight vertices per direction give seven intervals, so scaling by places the mesh on the unit square. There are vertices and triangles. Scalar P1 has one degree of freedom per vertex.
Build and run
Run these commands in the directory containing the two files.
cmake -S . -B build cmake --build build ./build/first_rodin
The program produces the following output.
Vertices: 64 Triangles: 98 Dimension: 2 P1 degrees of freedom: 64
From geometry to equations
Meshes
A mesh separates topological dimension from ambient dimension. A triangular surface embedded in three-dimensional space has topological dimension two and ambient dimension three. getDimension() and getSpaceDimension() expose these two quantities. See Meshes for creation, loading, and traversal.
Connectivity
Connectivity records incidence relations between geometric entities. For example, the Poisson tutorial computes edge-to-cell connectivity with mesh.getConnectivity().compute(1, 2) to identify exterior edges in a two-dimensional mesh. See Mesh connectivity.
Finite element fields
A finite element space defines the approximation and the distribution of degrees of freedom. A GridFunction stores a particular field in that space. Scalar P1 is the starting point here; other spaces have different continuity and numbering rules. See Finite element spaces.
Trial and test functions
Trial and test functions are symbolic objects used to construct equations.
TrialFunction u(vh); TestFunction v(vh);
u represents the unknown field. v represents the test function used to form the discrete equations. Operators and integrals combine them into a variational problem. After a solve, u.getSolution() provides the computed grid function.
Finding the relevant API
The module reference groups interfaces by their responsibilities. Geometry describes the domain, Variational describes fields and forms, Assembly constructs algebraic systems, Solver solves those systems, and IO exports the results. Optional models and integrations are listed there alongside their public headers.
Continue with a solve
Proceed to A first problem to build and run a Poisson solve. The Poisson tutorial explains the mathematical formulation and each stage of the code.