本文整理汇总了C++中Number::imag方法的典型用法代码示例。如果您正苦于以下问题:C++ Number::imag方法的具体用法?C++ Number::imag怎么用?C++ Number::imag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::imag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_global_data
void ExodusII_IO::write_global_data (const std::vector<Number> & soln,
const std::vector<std::string> & names)
{
if(MeshOutput<MeshBase>::mesh().processor_id())
return;
if (!exio_helper->opened_for_writing)
libmesh_error_msg("ERROR, ExodusII file must be initialized before outputting global variables.");
#ifdef LIBMESH_USE_COMPLEX_NUMBERS
std::vector<std::string> complex_names = exio_helper->get_complex_names(names);
exio_helper->initialize_global_variables(complex_names);
unsigned int num_values = soln.size();
unsigned int num_vars = names.size();
unsigned int num_elems = num_values / num_vars;
// This will contain the real and imaginary parts and the magnitude
// of the values in soln
std::vector<Real> complex_soln(3*num_values);
for (unsigned i=0; i<num_vars; ++i)
{
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + j] = value.real();
}
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + num_elems +j] = value.imag();
}
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + 2*num_elems + j] = std::abs(value);
}
}
exio_helper->write_global_values(complex_soln, _timestep);
#else
exio_helper->initialize_global_variables(names);
exio_helper->write_global_values(soln, _timestep);
#endif
}
示例2: write_element_data
void ExodusII_IO::write_element_data (const EquationSystems & es)
{
// Be sure the file has been opened for writing!
if (MeshOutput<MeshBase>::mesh().processor_id() == 0 && !exio_helper->opened_for_writing)
libmesh_error_msg("ERROR, ExodusII file must be initialized before outputting element variables.");
// This function currently only works on SerialMeshes. We rely on
// having a reference to a non-const MeshBase object from our
// MeshInput parent class to construct a MeshSerializer object,
// similar to what is done in ExodusII_IO::write(). Note that
// calling ExodusII_IO::write_timestep() followed by
// ExodusII_IO::write_element_data() when the underlying Mesh is a
// ParallelMesh will result in an unnecessary additional
// serialization/re-parallelization step.
MeshSerializer serialize(MeshInput<MeshBase>::mesh(), !MeshOutput<MeshBase>::_is_parallel_format);
// To be (possibly) filled with a filtered list of variable names to output.
std::vector<std::string> names;
// If _output_variables is populated, only output the monomials which are
// also in the _output_variables vector.
if (_output_variables.size() > 0)
{
std::vector<std::string> monomials;
const FEType type(CONSTANT, MONOMIAL);
// Create a list of monomial variable names
es.build_variable_names(monomials, &type);
// Filter that list against the _output_variables list. Note: if names is still empty after
// all this filtering, all the monomial variables will be gathered
std::vector<std::string>::iterator it = monomials.begin();
for (; it!=monomials.end(); ++it)
if (std::find(_output_variables.begin(), _output_variables.end(), *it) != _output_variables.end())
names.push_back(*it);
}
// If we pass in a list of names to "get_solution" it'll filter the variables coming back
std::vector<Number> soln;
es.get_solution(soln, names);
if(soln.empty()) // If there is nothing to write just return
return;
// The data must ultimately be written block by block. This means that this data
// must be sorted appropriately.
if(MeshOutput<MeshBase>::mesh().processor_id())
return;
const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
#ifdef LIBMESH_USE_COMPLEX_NUMBERS
std::vector<std::string> complex_names = exio_helper->get_complex_names(names);
exio_helper->initialize_element_variables(complex_names);
unsigned int num_values = soln.size();
unsigned int num_vars = names.size();
unsigned int num_elems = num_values / num_vars;
// This will contain the real and imaginary parts and the magnitude
// of the values in soln
std::vector<Real> complex_soln(3*num_values);
for (unsigned i=0; i<num_vars; ++i)
{
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + j] = value.real();
}
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + num_elems +j] = value.imag();
}
for (unsigned int j=0; j<num_elems; ++j)
{
Number value = soln[i*num_vars + j];
complex_soln[3*i*num_elems + 2*num_elems + j] = std::abs(value);
}
}
exio_helper->write_element_values(mesh, complex_soln, _timestep);
#else
exio_helper->initialize_element_variables(names);
exio_helper->write_element_values(mesh, soln, _timestep);
#endif
}