Nektar++
Functions
Field.cpp File Reference
#include <FieldUtils/Field.hpp>
#include <FieldUtils/FieldConvertComm.hpp>
#include <LibUtilities/Python/BasicUtils/SharedArray.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)
 
void export_Field (py::module &m)
 

Function Documentation

◆ export_Field()

void export_Field ( py::module &  m)

Definition at line 196 of file Field.cpp.

197{
198 py::class_<Field, std::shared_ptr<Field>>(m, "Field")
199 .def(py::init<>(&Field_Init), py::arg("argv") = py::list(),
200 py::arg("nparts") = 0, py::arg("output_points") = 0,
201 py::arg("output_points_hom_z") = 0, py::arg("error") = false,
202 py::arg("force_output") = false, py::arg("no_equispaced") = false,
203 py::arg("npz") = 0, py::arg("onlyshape") = "",
204 py::arg("part_only") = 0, py::arg("part_only_overlapping") = 0,
205 py::arg("use_session_variables") = false,
206 py::arg("use_session_expansion") = false,
207 py::arg("verbose") = false, py::arg("domain") = "")
208
209 .def("GetPts", &Field_GetPts)
210 .def("SetPts", &Field_SetPts)
211 .def("ClearField", &Field::ClearField)
212 .def("NewPartition", &NewPartition)
213 .def("ReadFieldDefs", &Field::ReadFieldDefs)
214
215 .def("SetupFromExpList", &Field::SetupFromExpList)
216
217 .def_readwrite("graph", &Field::m_graph)
218 .def_readwrite("session", &Field::m_session)
219 .def_readwrite("verbose", &Field::m_verbose)
220 .def_readwrite("comm", &Field::m_comm);
221}
void NewPartition(FieldSharedPtr f, py::list &py_argv, int part)
Definition: Field.cpp:48
void Field_SetPts(FieldSharedPtr f, const int i, const Array< OneD, const NekDouble > &inarray)
Definition: Field.cpp:190
const Array< OneD, const NekDouble > Field_GetPts(FieldSharedPtr f, const int i)
Definition: Field.cpp:180
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:64

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

Referenced by PYBIND11_MODULE().

◆ Field_GetPts()

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

Definition at line 180 of file Field.cpp.

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

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 64 of file Field.cpp.

72{
73 // Construct shared pointer to a Field object.
74 std::shared_ptr<Field> f = MemoryManager<Field>::AllocateSharedPtr();
75
76 if (py::len(argv) > 0)
77 {
78 // Get argc and argv from the Python command line.
79 CppCommandLine cpp(argv);
80
81 // Define the MPI Communicator.
83 "Serial", cpp.GetArgc(), cpp.GetArgv());
84
85 if (nparts)
86 {
87 f->m_vm.insert(
88 std::make_pair("nparts", po::variable_value(nparts, false)));
89 if (nparts > 1)
90 {
91 f->m_nParts = nparts;
92 f->m_defComm = f->m_comm;
93 }
94 }
95 }
96
97 // Populate m_vm.
98 if (output_points)
99 {
100 f->m_vm.insert(std::make_pair(
101 "output-points", po::variable_value(output_points, false)));
102 }
103
104 if (output_points_hom_z)
105 {
106 f->m_vm.insert(
107 std::make_pair("output-points-hom-z",
108 po::variable_value(output_points_hom_z, false)));
109 }
110
111 if (error)
112 {
113 f->m_vm.insert(std::make_pair("error", po::variable_value()));
114 }
115
116 if (force_output)
117 {
118 f->m_vm.insert(std::make_pair("force-output", po::variable_value()));
119 }
120
121 if (domain.size())
122 {
123 NEKERROR(ErrorUtil::efatal,
124 "The doamin option in field is deprecated. Please use "
125 "the xml option range=\"xmax,xmin,ymax,ymin\", \n\t i.e."
126 "InputModule.Create(\"xml\", field, \"myfile.xml\", "
127 "range=\"-1,1,-1,1\").Run()");
128 }
129
130 if (no_equispaced)
131 {
132 f->m_vm.insert(std::make_pair("no-equispaced", po::variable_value()));
133 }
134
135 if (npz)
136 {
137 f->m_vm.insert(std::make_pair("npz", po::variable_value(npz, false)));
138 }
139
140 if (onlyshape.size())
141 {
142 f->m_vm.insert(
143 std::make_pair("onlyshape", po::variable_value(onlyshape, false)));
144 }
145
146 if (part_only)
147 {
148 f->m_vm.insert(
149 std::make_pair("part-only", po::variable_value(part_only, false)));
150 }
151
152 if (part_only_overlapping)
153 {
154 f->m_vm.insert(
155 std::make_pair("part-only-overlapping",
156 po::variable_value(part_only_overlapping, false)));
157 }
158
159 if (useSessionVariables)
160 {
161 f->m_vm.insert(
162 std::make_pair("use_session_variables", po::variable_value()));
163 }
164
165 if (useSessionExpansion)
166 {
167 f->m_vm.insert(
168 std::make_pair("use_session_expansion", po::variable_value()));
169 }
170
171 if (verbose)
172 {
173 f->m_vm.insert(std::make_pair("verbose", po::variable_value()));
174 }
175
176 return f;
177}
#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.
Definition: NekPyConfig.hpp:89

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 190 of file Field.cpp.

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

Referenced by export_Field().

◆ NewPartition()

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

Definition at line 48 of file Field.cpp.

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

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

Referenced by export_Field().