本文整理汇总了C++中hermes::vector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::push_back方法的具体用法?C++ vector::push_back怎么用?C++ vector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hermes::vector
的用法示例。
在下文中一共展示了vector::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IOCalculationContinuityException
Hermes::vector<Space<Scalar>*> CalculationContinuity<Scalar>::Record::load_spaces(Hermes::vector<Mesh*> meshes, Hermes::vector<Shapeset*> shapesets)
{
Hermes::vector<Space<Scalar>*> spaces;
if(shapesets == Hermes::vector<Shapeset*>())
for(unsigned int i = 0; i < meshes.size(); i++)
shapesets.push_back(NULL);
for(unsigned int i = 0; i < meshes.size(); i++)
{
std::stringstream filename;
filename << CalculationContinuity<Scalar>::space_file_name << i << '_' << (std::string)"t = " << this->time << (std::string)"n = " << this->number << (std::string)".h2d";
try
{
spaces.push_back(Space<Scalar>::load(filename.str().c_str(), meshes[i], false, NULL, shapesets[i]));
}
catch(Hermes::Exceptions::SpaceLoadFailureException& e)
{
throw IOCalculationContinuityException(CalculationContinuityException::spaces, IOCalculationContinuityException::input, filename.str().c_str(), e.what());
}
catch(std::exception& e)
{
throw IOCalculationContinuityException(CalculationContinuityException::spaces, IOCalculationContinuityException::input, filename.str().c_str(), e.what());
}
}
}
示例2: spaces
Adapt<Scalar>::Adapt(Hermes::vector<Space<Scalar>*> spaces,
Hermes::vector<ProjNormType> proj_norms) :
spaces(spaces),
num_act_elems(-1),
have_errors(false),
have_coarse_solutions(false),
have_reference_solutions(false)
{
// sanity check
if (proj_norms.size() > 0 && spaces.size() != proj_norms.size())
error("Mismatched numbers of spaces and projection types in Adapt<Scalar>::Adapt().");
this->num = spaces.size();
// sanity checks
error_if(this->num <= 0, "Too few components (%d), only %d supported.", this->num, H2D_MAX_COMPONENTS);
error_if(this->num > H2D_MAX_COMPONENTS, "Too many components (%d), only %d supported.", this->num, H2D_MAX_COMPONENTS);
// reset values
memset(errors, 0, sizeof(errors));
memset(sln, 0, sizeof(sln));
memset(rsln, 0, sizeof(rsln));
// if norms were not set by the user, set them to defaults
// according to spaces
if (proj_norms.size() == 0)
{
for (int i = 0; i < this->num; i++)
{
switch (spaces[i]->get_type())
{
case HERMES_H1_SPACE: proj_norms.push_back(HERMES_H1_NORM); break;
case HERMES_HCURL_SPACE: proj_norms.push_back(HERMES_HCURL_NORM); break;
case HERMES_HDIV_SPACE: proj_norms.push_back(HERMES_HDIV_NORM); break;
case HERMES_L2_SPACE: proj_norms.push_back(HERMES_L2_NORM); break;
default: error("Unknown space type in Adapt<Scalar>::Adapt().");
}
}
}
// assign norm weak forms according to norms selection
for (int i = 0; i < this->num; i++)
for (int j = 0; j < this->num; j++)
{
error_form[i][j] = NULL;
norm_form[i][j] = NULL;
}
for (int i = 0; i < this->num; i++)
{
error_form[i][i] = new MatrixFormVolError(proj_norms[i]);
norm_form[i][i] = error_form[i][i];
}
}
示例3: FilterVectorPotential
MeshFunction<double>* FilterVectorPotential::clone()
{
Hermes::vector<MeshFunction<double>*> fns;
Hermes::vector<int> items;
for(int i = 0; i < this->num; i++)
{
fns.push_back(this->sln[i]->clone());
items.push_back(item[i]);
}
return new FilterVectorPotential(fns, items);
}
示例4: set_dirichlet_values
// Set Dirichlet boundary values.
void ModuleBasic::set_dirichlet_values(const std::vector<int> &bdy_markers_dirichlet,
const std::vector<double> &bdy_values_dirichlet)
{
Hermes::vector<int> tm;
for (unsigned int i = 0; i < bdy_markers_dirichlet.size(); i++) {
tm.push_back(bdy_markers_dirichlet[i]);
}
Hermes::vector<double> tv;
for (unsigned int i = 0; i < bdy_values_dirichlet.size(); i++) {
tv.push_back(bdy_values_dirichlet[i]);
}
if (tm.size() != tv.size()) error("Mismatched numbers of Dirichlet boundary markers and values.");
for (unsigned int i = 0; i < tm.size(); i++) this->bc_values.add_const(tm[i], tv[i]);
}
示例5: precalculate
void SimpleFilter::precalculate(int order, int mask)
{
if (mask & (H2D_FN_DX | H2D_FN_DY | H2D_FN_DXX | H2D_FN_DYY | H2D_FN_DXY))
error("Filter not defined for derivatives.");
Quad2D* quad = quads[cur_quad];
int np = quad->get_num_points(order);
Node* node = new_node(H2D_FN_VAL, np);
// precalculate all solutions
for (int i = 0; i < num; i++)
sln[i]->set_quad_order(order, item[i]);
for (int j = 0; j < num_components; j++)
{
// obtain corresponding tables
scalar* tab[10];
for (int i = 0; i < num; i++)
{
int a = 0, b = 0, mask = item[i];
if (mask >= 0x40) { a = 1; mask >>= 6; }
while (!(mask & 1)) { mask >>= 1; b++; }
tab[i] = sln[i]->get_values(num_components == 1 ? a : j, b);
if (tab[i] == NULL) error("Value of 'item%d' is incorrect in filter definition.", i+1);
}
Hermes::vector<scalar*> values;
for(int i = 0; i < this->num; i++)
values.push_back(tab[i]);
// apply the filter
filter_fn(np, values, node->values[j][0]);
}
示例6: FilterFluxDensity
MeshFunction<double>* FilterFluxDensity::clone()
{
Hermes::vector<MeshFunction<double>*> fns;
for(int i = 0; i < this->num; i++)
fns.push_back(this->sln[i]->clone());
return new FilterFluxDensity(fns);
}
示例7: while
void SimpleFilter<Scalar>::precalculate(int order, int mask)
{
if(mask & (H2D_FN_DX | H2D_FN_DY | H2D_FN_DXX | H2D_FN_DYY | H2D_FN_DXY))
throw Hermes::Exceptions::Exception("Filter not defined for derivatives.");
Quad2D* quad = this->quads[this->cur_quad];
int np = quad->get_num_points(order, this->element->get_mode());
struct Function<Scalar>::Node* node = this->new_node(H2D_FN_VAL, np);
// precalculate all solutions
for (int i = 0; i < this->num; i++)
this->sln[i]->set_quad_order(order, item[i]);
for (int j = 0; j < this->num_components; j++)
{
// obtain corresponding tables
Scalar* tab[H2D_MAX_COMPONENTS];
for (int i = 0; i < this->num; i++)
{
int a = 0, b = 0, mask = item[i];
if(mask >= 0x40) { a = 1; mask >>= 6; }
while (!(mask & 1)) { mask >>= 1; b++; }
tab[i] = this->sln[i]->get_values(this->num_components == 1 ? a : j, b);
if(tab[i] == nullptr) throw Hermes::Exceptions::Exception("Value of 'item%d' is incorrect in filter definition.", i + 1);
}
Hermes::vector<Scalar*> values;
for(int i = 0; i < this->num; i++)
values.push_back(tab[i]);
// apply the filter
filter_fn(np, values, node->values[j][0]);
}
示例8: switch
void Continuity<Scalar>::Record::load_spaces(Hermes::vector<Space<Scalar>*> spaces, Hermes::vector<SpaceType> space_types, Hermes::vector<Mesh*> meshes, Hermes::vector<Shapeset*> shapesets)
{
if(shapesets == Hermes::vector<Shapeset*>())
for(unsigned int i = 0; i < spaces.size(); i++)
shapesets.push_back(NULL);
for(unsigned int i = 0; i < spaces.size(); i++)
{
std::stringstream filename;
filename << Continuity<Scalar>::spaceFileName << i << '_' << (std::string)"t = " << this->time << (std::string)"n = " << this->number << (std::string)".h2d";
spaces[i]->free();
switch(space_types[i])
{
case HERMES_H1_SPACE:
dynamic_cast<H1Space<Scalar>*>(spaces[i])->load(filename.str().c_str(), meshes[i], shapesets[i]);
break;
case HERMES_HCURL_SPACE:
dynamic_cast<HcurlSpace<Scalar>*>(spaces[i])->load(filename.str().c_str(), meshes[i], shapesets[i]);
break;
case HERMES_HDIV_SPACE:
dynamic_cast<HdivSpace<Scalar>*>(spaces[i])->load(filename.str().c_str(), meshes[i], shapesets[i]);
break;
case HERMES_L2_SPACE:
dynamic_cast<L2Space<Scalar>*>(spaces[i])->load(filename.str().c_str(), meshes[i], shapesets[i]);
break;
}
}
}
示例9: set_material_markers
// Set material markers, and check compatibility with mesh file.
void ModuleBasic::set_material_markers(const std::vector<int> &m_markers)
{
this->mat_markers = m_markers;
// FIXME: these global arrays need to be removed.
for (unsigned int i = 0; i < m_markers.size(); i++) {
_global_mat_markers.push_back(m_markers[i]);;
}
}
示例10: set_dirichlet_markers
// Set Dirichlet boundary markers.
void ModuleBasic::set_dirichlet_markers(const std::vector<int> &bdy_markers_dirichlet)
{
//this->bdy_markers_dirichlet = bdy_markers_dirichlet;
Hermes::vector<int> t;
for (unsigned int i = 0; i < bdy_markers_dirichlet.size(); i++) {
t.push_back(bdy_markers_dirichlet[i]);
}
this->bc_types.add_bc_dirichlet(t);
}
示例11: set_newton_markers
// Set Newton boundary markers.
void ModuleBasic::set_newton_markers(const std::vector<int> &bdy_markers_newton)
{
this->bdy_markers_newton = bdy_markers_newton;
Hermes::vector<int> t;
for (unsigned int i = 0; i < bdy_markers_newton.size(); i++) {
t.push_back(bdy_markers_newton[i]);
}
this->bc_types.add_bc_newton(t);
}
示例12:
void WeakForm<Scalar>::cloneMembers(const WeakForm<Scalar>* otherWf)
{
this->mfvol.clear();
this->mfsurf.clear();
this->mfDG.clear();
this->vfvol.clear();
this->vfsurf.clear();
this->vfDG.clear();
this->forms.clear();
this->ext.clear();
for(unsigned int i = 0; i < otherWf->forms.size(); i++)
{
if(dynamic_cast<MatrixFormVol<Scalar>*>(otherWf->forms[i]) != NULL)
this->forms.push_back((dynamic_cast<MatrixFormVol<Scalar>*>(otherWf->forms[i]))->clone());
if(dynamic_cast<MatrixFormSurf<Scalar>*>(otherWf->forms[i]) != NULL)
this->forms.push_back((dynamic_cast<MatrixFormSurf<Scalar>*>(otherWf->forms[i]))->clone());
if(dynamic_cast<MatrixFormDG<Scalar>*>(otherWf->forms[i]) != NULL)
this->forms.push_back((dynamic_cast<MatrixFormDG<Scalar>*>(otherWf->forms[i]))->clone());
if(dynamic_cast<VectorFormVol<Scalar>*>(otherWf->forms[i]) != NULL)
this->forms.push_back((dynamic_cast<VectorFormVol<Scalar>*>(otherWf->forms[i]))->clone());
if(dynamic_cast<VectorFormSurf<Scalar>*>(otherWf->forms[i]) != NULL)
this->forms.push_back((dynamic_cast<VectorFormSurf<Scalar>*>(otherWf->forms[i]))->clone());
if(dynamic_cast<VectorFormDG<Scalar>*>(otherWf->forms[i]) != NULL)
this->forms.push_back((dynamic_cast<VectorFormDG<Scalar>*>(otherWf->forms[i]))->clone());
Hermes::vector<MeshFunction<Scalar>*> newExt;
for(unsigned int ext_i = 0; ext_i < otherWf->forms[i]->ext.size(); ext_i++)
newExt.push_back(otherWf->forms[i]->ext[ext_i]->clone());
this->forms.back()->set_ext(newExt);
this->forms.back()->wf = this;
if(dynamic_cast<MatrixFormVol<Scalar>*>(otherWf->forms[i]) != NULL)
this->mfvol.push_back(dynamic_cast<MatrixFormVol<Scalar>*>(this->forms.back()));
if(dynamic_cast<MatrixFormSurf<Scalar>*>(otherWf->forms[i]) != NULL)
this->mfsurf.push_back(dynamic_cast<MatrixFormSurf<Scalar>*>(this->forms.back()));
if(dynamic_cast<MatrixFormDG<Scalar>*>(otherWf->forms[i]) != NULL)
this->mfDG.push_back(dynamic_cast<MatrixFormDG<Scalar>*>(this->forms.back()));
if(dynamic_cast<VectorFormVol<Scalar>*>(otherWf->forms[i]) != NULL)
this->vfvol.push_back(dynamic_cast<VectorFormVol<Scalar>*>(this->forms.back()));
if(dynamic_cast<VectorFormSurf<Scalar>*>(otherWf->forms[i]) != NULL)
this->vfsurf.push_back(dynamic_cast<VectorFormSurf<Scalar>*>(this->forms.back()));
if(dynamic_cast<VectorFormDG<Scalar>*>(otherWf->forms[i]) != NULL)
this->vfDG.push_back(dynamic_cast<VectorFormDG<Scalar>*>(this->forms.back()));
}
for(unsigned int i = 0; i < otherWf->ext.size(); i++)
{
this->ext.push_back(otherWf->ext[i]->clone());
if(dynamic_cast<Solution<Scalar>*>(otherWf->ext[i]) != NULL)
{
dynamic_cast<Solution<Scalar>*>(this->ext.back())->set_type(dynamic_cast<Solution<Scalar>*>(otherWf->ext[i])->get_type());
}
}
}
示例13: calc_norms
// Calculate norm of a (possibly vector-valued) solution.
// Take norm from spaces where these solutions belong.
double calc_norms(Hermes::vector<Solution*> slns)
{
// Calculate norms for all solutions.
Hermes::vector<double> norms;
int n = slns.size();
for (int i=0; i<n; i++) {
switch (slns[i]->get_space_type()) {
case HERMES_H1_SPACE: norms.push_back(calc_norm(slns[i], HERMES_H1_NORM)); break;
case HERMES_HCURL_SPACE: norms.push_back(calc_norm(slns[i], HERMES_HCURL_NORM)); break;
case HERMES_HDIV_SPACE: norms.push_back(calc_norm(slns[i], HERMES_HDIV_NORM)); break;
case HERMES_L2_SPACE: norms.push_back(calc_norm(slns[i], HERMES_L2_NORM)); break;
default: error("Internal in calc_norms(): unknown space type.");
}
}
// Calculate the resulting norm.
double result = 0;
for (int i=0; i<n; i++) result += norms[i]*norms[i];
return sqrt(result);
}
示例14: switch
Hermes::vector<Cand> create_candidates(Element* e, int quad_order)
{
Hermes::vector<Cand> candidates;
// Get the current order range.
int current_min_order, current_max_order;
this->get_current_order_range(e, current_min_order, current_max_order);
int order_h = H2D_GET_H_ORDER(quad_order), order_v = H2D_GET_V_ORDER(quad_order);
if(current_max_order < std::max(order_h, order_v))
current_max_order = std::max(order_h, order_v);
int last_order_h = std::min(current_max_order, order_h + 1), last_order_v = std::min(current_max_order, order_v + 1);
int last_order = H2D_MAKE_QUAD_ORDER(last_order_h, last_order_v);
switch(strategy)
{
case(hORpSelectionBasedOnDOFs):
{
candidates.push_back(Cand(H2D_REFINEMENT_P, quad_order));
}
case(hXORpSelectionBasedOnError):
{
candidates.push_back(Cand(H2D_REFINEMENT_P, last_order));
candidates.push_back(Cand(H2D_REFINEMENT_H, quad_order, quad_order, quad_order, quad_order));
return candidates;
}
break;
case(isoHPSelectionBasedOnDOFs):
{
this->cand_list = H2D_HP_ISO;
return H1ProjBasedSelector<complex>::create_candidates(e, quad_order);
}
break;
case(anisoHPSelectionBasedOnDOFs):
{
this->cand_list = H2D_HP_ANISO;
return H1ProjBasedSelector<complex>::create_candidates(e, quad_order);
}
break;
}
}
示例15: solution
MeshFunctionSharedPtr<Scalar> Limiter<Scalar>::get_solution()
{
// A check.
warn_if(this->component_count > 1, "One solution asked from a Limiter, but multiple solutions exist for limiting.");
MeshFunctionSharedPtr<Scalar> solution(new Solution<Scalar>());
Hermes::vector<MeshFunctionSharedPtr<Scalar> > solutions;
solutions.push_back(solution);
this->get_solutions(solutions);
return solutions.back();
}