Nektar++
Functions
Field.cpp File Reference
#include <FieldUtils/Field.hpp>
#include <FieldUtils/FieldConvertComm.hpp>
#include <LibUtilities/Python/NekPyConfig.hpp>

Go to the source code of this file.

Functions

void NewPartition (FieldSharedPtr f, py::list &py_argv, int part)
 
FieldSharedPtr Field_Init (py::list &argv, int nparts=0, int output_points=0, int output_points_hom_z=0, bool error=false, bool force_output=false, bool no_equispaced=false, int npz=0, std::string onlyshape="", int part_only=0, int part_only_overlapping=0, bool useSessionVariables=false, bool useSessionExpansion=false, bool verbose=false, std::string domain="")
 
const Array< OneD, const NekDoubleField_GetPts (FieldSharedPtr f, const int i)
 
void Field_SetPts (FieldSharedPtr f, const int i, const Array< OneD, const NekDouble > &inarray)
 
Array< OneD, MultiRegions::ExpListSharedPtrPyListToOneDArray (py::list &pyExpList)
 
void Field_SetupFromExpList (FieldSharedPtr f, py::list &explists)
 
void export_Field ()
 

Function Documentation

◆ export_Field()

void export_Field ( )

Definition at line 221 of file Field.cpp.

222{
223 py::class_<Field, std::shared_ptr<Field>>("Field", py::no_init)
224 .def("__init__",
225 py::make_constructor(
226 &Field_Init, py::default_call_policies(),
227 (py::arg("argv") = py::list(), py::arg("nparts") = 0,
228 py::arg("output_points") = 0,
229 py::arg("output_points_hom_z") = 0, py::arg("error") = false,
230 py::arg("force_output") = false,
231 py::arg("no_equispaced") = false, py::arg("npz") = 0,
232 py::arg("onlyshape") = "", py::arg("part_only") = 0,
233 py::arg("part_only_overlapping") = 0,
234 py::arg("use_session_variables") = false,
235 py::arg("use_session_expansion") = false,
236 py::arg("verbose") = false, py::arg("domain") = "")))
237
238 .def("GetPts", &Field_GetPts)
239 .def("SetPts", &Field_SetPts)
240 .def("ClearField", &Field::ClearField)
241 .def("NewPartition", &NewPartition)
242 .def("ReadFieldDefs", &Field::ReadFieldDefs)
243
244 .def("SetupFromExpList", Field_SetupFromExpList)
245
246 .def_readwrite("graph", &Field::m_graph)
247 .def_readwrite("session", &Field::m_session)
248 .def_readwrite("verbose", &Field::m_verbose)
249 .def_readwrite("comm", &Field::m_comm);
250}
void Field_SetupFromExpList(FieldSharedPtr f, py::list &explists)
Definition: Field.cpp:214
void NewPartition(FieldSharedPtr f, py::list &py_argv, int part)
Definition: Field.cpp:47
void Field_SetPts(FieldSharedPtr f, const int i, const Array< OneD, const NekDouble > &inarray)
Definition: Field.cpp:189
const Array< OneD, const NekDouble > Field_GetPts(FieldSharedPtr f, const int i)
Definition: Field.cpp:179
FieldSharedPtr Field_Init(py::list &argv, int nparts=0, int output_points=0, int output_points_hom_z=0, bool error=false, bool force_output=false, bool no_equispaced=false, int npz=0, std::string onlyshape="", int part_only=0, int part_only_overlapping=0, bool useSessionVariables=false, bool useSessionExpansion=false, bool verbose=false, std::string domain="")
Definition: Field.cpp:63

References Field_GetPts(), Field_Init(), Field_SetPts(), Field_SetupFromExpList(), and NewPartition().

Referenced by BOOST_PYTHON_MODULE().

◆ Field_GetPts()

const Array< OneD, const NekDouble > Field_GetPts ( FieldSharedPtr  f,
const int  i 
)

Definition at line 179 of file Field.cpp.

180{
181 return f->m_fieldPts->GetPts(i);
182}

Referenced by export_Field().

◆ Field_Init()

FieldSharedPtr Field_Init ( py::list &  argv,
int  nparts = 0,
int  output_points = 0,
int  output_points_hom_z = 0,
bool  error = false,
bool  force_output = false,
bool  no_equispaced = false,
int  npz = 0,
std::string  onlyshape = "",
int  part_only = 0,
int  part_only_overlapping = 0,
bool  useSessionVariables = false,
bool  useSessionExpansion = false,
bool  verbose = false,
std::string  domain = "" 
)

Definition at line 63 of file Field.cpp.

71{
72 // Construct shared pointer to a Field object.
73 std::shared_ptr<Field> f = MemoryManager<Field>::AllocateSharedPtr();
74
75 if (py::len(argv) > 0)
76 {
77 // Get argc and argv from the Python command line.
78 CppCommandLine cpp(argv);
79
80 // Define the MPI Communicator.
82 "Serial", cpp.GetArgc(), cpp.GetArgv());
83
84 if (nparts)
85 {
86 f->m_vm.insert(
87 std::make_pair("nparts", po::variable_value(nparts, false)));
88 if (nparts > 1)
89 {
90 f->m_nParts = nparts;
91 f->m_defComm = f->m_comm;
92 }
93 }
94 }
95
96 // Populate m_vm.
97 if (output_points)
98 {
99 f->m_vm.insert(std::make_pair(
100 "output-points", po::variable_value(output_points, false)));
101 }
102
103 if (output_points_hom_z)
104 {
105 f->m_vm.insert(
106 std::make_pair("output-points-hom-z",
107 po::variable_value(output_points_hom_z, false)));
108 }
109
110 if (error)
111 {
112 f->m_vm.insert(std::make_pair("error", po::variable_value()));
113 }
114
115 if (force_output)
116 {
117 f->m_vm.insert(std::make_pair("force-output", po::variable_value()));
118 }
119
120 if (domain.size())
121 {
122 NEKERROR(ErrorUtil::efatal,
123 "The doamin option in field is deprecated. Please use "
124 "the xml option range=\"xmax,xmin,ymax,ymin\", \n\t i.e."
125 "InputModule.Create(\"xml\", field, \"myfile.xml\", "
126 "range=\"-1,1,-1,1\").Run()");
127 }
128
129 if (no_equispaced)
130 {
131 f->m_vm.insert(std::make_pair("no-equispaced", po::variable_value()));
132 }
133
134 if (npz)
135 {
136 f->m_vm.insert(std::make_pair("npz", po::variable_value(npz, false)));
137 }
138
139 if (onlyshape.size())
140 {
141 f->m_vm.insert(
142 std::make_pair("onlyshape", po::variable_value(onlyshape, false)));
143 }
144
145 if (part_only)
146 {
147 f->m_vm.insert(
148 std::make_pair("part-only", po::variable_value(part_only, false)));
149 }
150
151 if (part_only_overlapping)
152 {
153 f->m_vm.insert(
154 std::make_pair("part-only-overlapping",
155 po::variable_value(part_only_overlapping, false)));
156 }
157
158 if (useSessionVariables)
159 {
160 f->m_vm.insert(
161 std::make_pair("use_session_variables", po::variable_value()));
162 }
163
164 if (useSessionExpansion)
165 {
166 f->m_vm.insert(
167 std::make_pair("use_session_expansion", po::variable_value()));
168 }
169
170 if (verbose)
171 {
172 f->m_vm.insert(std::make_pair("verbose", po::variable_value()));
173 }
174
175 return f;
176}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
CommFactory & GetCommFactory()
Helper structure to construct C++ command line argc and argv variables from a Python list.

References Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), CppCommandLine::GetArgc(), CppCommandLine::GetArgv(), Nektar::LibUtilities::GetCommFactory(), and NEKERROR.

Referenced by export_Field().

◆ Field_SetPts()

void Field_SetPts ( FieldSharedPtr  f,
const int  i,
const Array< OneD, const NekDouble > &  inarray 
)

Definition at line 189 of file Field.cpp.

191{
192 f->m_fieldPts->SetPts(i, inarray);
193}

Referenced by export_Field().

◆ Field_SetupFromExpList()

void Field_SetupFromExpList ( FieldSharedPtr  f,
py::list &  explists 
)

Definition at line 214 of file Field.cpp.

215{
217 PyListToOneDArray(explists);
218 f->SetupFromExpList(exp);
219}
Array< OneD, MultiRegions::ExpListSharedPtr > PyListToOneDArray(py::list &pyExpList)
Definition: Field.cpp:195

References PyListToOneDArray().

Referenced by export_Field().

◆ NewPartition()

void NewPartition ( FieldSharedPtr  f,
py::list &  py_argv,
int  part 
)

Definition at line 47 of file Field.cpp.

48{
49 std::cout << std::endl << "Processing partition: " << part << std::endl;
50 f->ClearField();
51
52 CppCommandLine cpp(py_argv);
53
54 f->m_partComm = std::shared_ptr<FieldConvertComm>(
55 new FieldConvertComm(cpp.GetArgc(), cpp.GetArgv(), f->m_nParts, part));
56}

References CppCommandLine::GetArgc(), and CppCommandLine::GetArgv().

Referenced by export_Field().

◆ PyListToOneDArray()

Array< OneD, MultiRegions::ExpListSharedPtr > PyListToOneDArray ( py::list &  pyExpList)
inline

Definition at line 195 of file Field.cpp.

197{
199 Array<OneD, MultiRegions::ExpListSharedPtr> expLists(py::len(pyExpList));
200
201 for (int i = 0; i < expLists.size(); ++i)
202 {
203 if (!py::extract<MultiRegions::ExpListSharedPtr>(pyExpList[i]).check())
204 {
205 throw NekError("List should contain only ExpList objects.");
206 }
207
208 expLists[i] = py::extract<MultiRegions::ExpListSharedPtr>(pyExpList[i]);
209 }
210
211 return expLists;
212}
Nektar::ErrorUtil::NekError NekError

Referenced by Field_SetupFromExpList().