FuncViz examples
Generalized bitree/quadtree/octree library
Loading...
Searching...
No Matches
hello_world.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file hello_world.cpp
5 @author Mitch Richling http://www.mitchr.me/
6 @date 2024-07-13
7 @brief Minimal example for MR_rect_tree/MR_cell_cplx/MR_rt_to_cc.@EOL
8 @keywords surface plot 2d 3d
9 @std C++23
10 @see
11 @copyright
12 @parblock
13 Copyright (c) 2024, Mitchell Jay Richling <http://www.mitchr.me/> All rights reserved.
14
15 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
16
17 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
18
19 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
20 and/or other materials provided with the distribution.
21
22 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
30 DAMAGE.
31 @endparblock
32*/
33/*******************************************************************************************************************************************************.H.E.**/
34/** @cond exj */
35
36////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
37#include "MR_rect_tree.hpp"
38#include "MR_cell_cplx.hpp"
39#include "MR_rt_to_cc.hpp"
40
41////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42typedef mjr::tree15b2d1rT tt_t;
43typedef mjr::MRccT5 cc_t;
44typedef mjr::MR_rt_to_cc<tt_t, cc_t> tc_t;
45
46////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
47tt_t::rrpt_t damp_cos_wave(tt_t::drpt_t xvec) {
48 double x = xvec[0];
49 double y = xvec[1];
50 double d = x*x+y*y;
51 double z = std::exp(-d/4)*std::cos(4*std::sqrt(d));
52 return z;
53}
54
55////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
56int main() {
57 tt_t tree({-2.1, -2.1},
58 { 2.1, 2.1});
59 cc_t ccplx;
60
61 tree.refine_grid(7, damp_cos_wave);
62 tree.dump_tree(5);
63
64 tc_t::construct_geometry_fans(ccplx,
65 tree,
66 2,
67 {{tc_t::val_src_spc_t::FDOMAIN, 0},
68 {tc_t::val_src_spc_t::FDOMAIN, 1},
69 {tc_t::val_src_spc_t::FRANGE, 0}});
70 ccplx.create_named_datasets({"x", "y", "f(x,y)"});
71
72 ccplx.write_xml_vtk("hello_world.vtu", "hello_world");
73}
74/** @endcond */
int main()