Nektar++
ProcessLoadOctree.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: ProcessLoadOctree.cpp
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Load octree.
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #include "ProcessLoadOctree.h"
37 
38 using namespace std;
39 namespace Nektar
40 {
41 namespace NekMeshUtils
42 {
43 
44 ModuleKey ProcessLoadOctree::className = GetModuleFactory().RegisterCreatorFunction(
45  ModuleKey(eProcessModule, "loadoctree"),
46  ProcessLoadOctree::create,
47  "Loads octree into m_mesh");
48 
49 ProcessLoadOctree::ProcessLoadOctree(MeshSharedPtr m) : ProcessModule(m)
50 {
51  m_config["mindel"] =
52  ConfigOption(false, "0", "mindelta.");
53  m_config["maxdel"] =
54  ConfigOption(false, "0", "mindelta.");
55  m_config["eps"] =
56  ConfigOption(false, "0", "mindelta.");
57  m_config["refinement"] =
58  ConfigOption(false, "", "mindelta.");
59  m_config["writeoctree"] =
60  ConfigOption(true, "0", "dump octree as xml mesh");
61 }
62 
64 {
65 }
66 
68 {
69  NekDouble minDelta, maxDelta, eps;
70 
71  minDelta = m_config["mindel"].as<NekDouble>();
72  maxDelta = m_config["maxdel"].as<NekDouble>();
73  eps = m_config["eps"].as<NekDouble>();
74 
75  if (m_mesh->m_verbose)
76  {
77  cout << endl << "Loading Octree with parameters:" << endl;
78  cout << "\tmin delta: " << minDelta << endl
79  << "\tmax delta: " << maxDelta << endl
80  << "\tesp: " << eps << endl << endl;
81  }
82 
83  ASSERTL0(minDelta > 0 && maxDelta > 0 && eps > 0, "invalid parameters");
84 
86 
87  m_mesh->m_octree->SetParameters(minDelta, maxDelta, eps);
88 
89  if(m_config["refinement"].beenSet)
90  {
91  m_mesh->m_octree->Refinement(m_config["refinement"].as<string>());
92  }
93 
94  m_mesh->m_octree->Process();
95 
96  if(m_config["writeoctree"].beenSet)
97  {
98  m_mesh->m_octree->WriteOctree(m_config["writeoctree"].as<string>());
99  }
100 }
101 }
102 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
STL namespace.
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:156
std::pair< ModuleType, std::string > ModuleKey
Represents a command-line configuration option.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
double NekDouble
std::map< std::string, ConfigOption > m_config
List of configuration values.
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
ModuleFactory & GetModuleFactory()