Nektar++
ProcessLoadCAD.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: ProcessLoadCAD.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 CAD module
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #include "ProcessLoadCAD.h"
37 
38 #include <boost/filesystem.hpp>
39 #include <boost/algorithm/string.hpp>
40 
41 using namespace std;
42 namespace Nektar
43 {
44 namespace NekMeshUtils
45 {
46 
47 ModuleKey ProcessLoadCAD::className = GetModuleFactory().RegisterCreatorFunction(
48  ModuleKey(eProcessModule, "loadcad"),
49  ProcessLoadCAD::create,
50  "Loads cad into m_mesh");
51 
52 ProcessLoadCAD::ProcessLoadCAD(MeshSharedPtr m) : ProcessModule(m)
53 {
54  m_config["filename"] =
55  ConfigOption(false, "", "Generate prisms on these surfs");
56  m_config["2D"] =
57  ConfigOption(true, "", "allow 2d loading");
58  m_config["CFIMesh"] =
59  ConfigOption(true, "", "specifies that the CAD can be multibody");
60  m_config["NACA"] =
61  ConfigOption(false, "", "naca domain");
62  m_config["verbose"] =
63  ConfigOption(true, "", "verbose output from cadsystem");
64 }
65 
67 {
68 }
69 
71 {
72  string name = m_config["filename"].as<string>();
73 
74  if (m_mesh->m_verbose)
75  {
76  cout << "Loading CAD for " << name << endl;
77  }
78 
79  string ext = boost::filesystem::extension(name);
80 
81  if(boost::iequals(ext,".fbm"))
82  {
83  m_mesh->m_cad = GetEngineFactory().CreateInstance("cfi",name);
84  }
85  else
86  {
87  m_mesh->m_cad = GetEngineFactory().CreateInstance("oce",name);
88  }
89 
90  if(m_config["2D"].beenSet)
91  {
92  m_mesh->m_cad->Set2D();
93  }
94 
95  if(m_config["NACA"].beenSet)
96  {
97  m_mesh->m_cad->SetNACA(m_config["NACA"].as<string>());
98  }
99 
100  if(m_config["CFIMesh"].beenSet)
101  {
102  m_mesh->m_cad->SetCFIMesh();
103  }
104 
105  if(m_config["verbose"].beenSet)
106  {
107  m_mesh->m_cad->SetVerbose();
108  }
109 
110  ASSERTL0(m_mesh->m_cad->LoadCAD(), "Failed to load CAD");
111 }
112 }
113 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
STL namespace.
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:156
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:144
std::pair< ModuleType, std::string > ModuleKey
Represents a command-line configuration option.
std::map< std::string, ConfigOption > m_config
List of configuration values.
Abstract base class for processing modules.
EngineFactory & GetEngineFactory()
Definition: CADSystem.cpp:47
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
ModuleFactory & GetModuleFactory()