MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
nurbs_printfunc.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11//
12// MFEM NURBS knot vector example
13//
14// Compile with: make nurbs_curveint
15//
16// Sample runs: nurbs_curveint
17//
18// Description: This example code demonstrates the use of MFEM to define a
19// simple KnotVector and print its corresponding shape functions.
20
21#include <iostream>
22#include "mfem.hpp"
23
24using namespace std;
25using namespace mfem;
26
27int main(int argc, char *argv[])
28{
29 OptionsParser args(argc, argv);
30 bool visualization;
31
32 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
33 "--no-visualization",
34 "Enable or disable GLVis visualization. Dummy option to allow testing.");
35 args.Parse();
36 if (!args.Good())
37 {
38 args.PrintUsage(cout);
39 return 1;
40 }
41
42 KnotVector kv(2, 7);
43
44 kv[0] = 0;
45 kv[1] = 0;
46 kv[2] = 0;
47 kv[3] = 0.25;
48 kv[4] = 0.5;
49 kv[5] = 0.5; // Repeated knot
50 kv[6] = 0.75;
51 kv[7] = 1;
52 kv[8] = 1;
53 kv[9] = 1;
54
55 cout << "Printing knotvector:" << endl;
56 kv.Print(cout);
57
58 // Count number of elements, required for printing of shapes
59 kv.GetElements();
60
61 cout << "\nPrinting shapefunctions:" << endl;
62 kv.PrintFunctions(cout);
63}
void PrintFunctions(std::ostream &os, int samples=11) const
Definition nurbs.cpp:260
void GetElements()
Count the number of elements.
Definition nurbs.cpp:229
void Print(std::ostream &os) const
Definition nurbs.cpp:254
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
Definition optparser.hpp:82
bool Good() const
Return true if the command line options were parsed successfully.
int main()