本文整理汇总了C++中hermes::vector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::size方法的具体用法?C++ vector::size怎么用?C++ vector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hermes::vector
的用法示例。
在下文中一共展示了vector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool NeighborSearch<Scalar>::is_inter_edge(const int& edge, const Hermes::vector<unsigned int>& transformations)
{
_F_;
// No subelements => of course this edge is an inter-element one.
if(transformations.size() == 0)
return true;
// Triangles.
for(unsigned int i = 0; i < transformations.size(); i++)
if(central_el->get_mode() == HERMES_MODE_TRIANGLE)
{
if ((edge == 0 && (transformations[i] == 2 || transformations[i] == 3)) ||
(edge == 1 && (transformations[i] == 0 || transformations[i] == 3)) ||
(edge == 2 && (transformations[i] == 1 || transformations[i] == 3)))
return false;
}
// Quads.
else
{
if ((edge == 0 && (transformations[i] == 2 || transformations[i] == 3 || transformations[i] == 5)) ||
(edge == 1 && (transformations[i] == 0 || transformations[i] == 3 || transformations[i] == 6)) ||
(edge == 2 && (transformations[i] == 0 || transformations[i] == 1 || transformations[i] == 4)) ||
(edge == 3 && (transformations[i] == 1 || transformations[i] == 2 || transformations[i] == 7)))
return false;
}
return true;
}
示例2: dp
void OGProjection<Scalar>::project_internal(Hermes::vector<Space<Scalar>*> spaces, WeakForm<Scalar>* wf,
Scalar* target_vec, Hermes::MatrixSolverType matrix_solver_type)
{
_F_;
// Instantiate a class with global functions.
Global<Scalar> hermes2d;
unsigned int n = spaces.size();
// sanity checks
if (n <= 0 || n > 10) error("Wrong number of projected functions in project_internal().");
for (unsigned int i = 0; i < n; i++) if(spaces[i] == NULL) error("this->spaces[%d] == NULL in project_internal().", i);
if (spaces.size() != n) error("Number of spaces must match number of projected functions in project_internal().");
// this is needed since spaces may have their DOFs enumerated only locally.
int ndof = Space<Scalar>::assign_dofs(spaces);
// Initialize DiscreteProblem.
DiscreteProblem<Scalar> dp(wf, spaces);
// Initial coefficient vector for the Newton's method.
Scalar* coeff_vec = new Scalar[ndof];
memset(coeff_vec, 0, ndof*sizeof(Scalar));
// Perform Newton's iteration.
NewtonSolver<Scalar> newton(&dp, matrix_solver_type);
if (!newton.solve(coeff_vec))
error("Newton's iteration failed.");
delete [] coeff_vec;
if (target_vec != NULL)
for (int i = 0; i < ndof; i++)
target_vec[i] = newton.get_sln_vector()[i];
}
示例3: error
void OGProjection<Scalar>::project_global(Hermes::vector<Space<Scalar>*> spaces,
Hermes::vector<MatrixFormVol<Scalar> *> mfvol,
Hermes::vector<VectorFormVol<Scalar> *> vfvol,
Hermes::vector<MeshFunction<Scalar>*> source_meshfns,
Scalar* target_vec, Hermes::MatrixSolverType matrix_solver_type)
{
_F_;
unsigned int n = spaces.size();
unsigned int n_biforms = mfvol.size();
if (n_biforms == 0)
error("Please use the simpler version of project_global with the argument Hermes::vector<ProjNormType> proj_norms if you do not provide your own projection norm.");
if (n_biforms != vfvol.size())
error("Mismatched numbers of projection forms in project_global().");
if (n != n_biforms)
error("Mismatched numbers of projected functions and projection forms in project_global().");
// This is needed since spaces may have their DOFs enumerated only locally
// when they come here.
int ndof = Space<Scalar>::assign_dofs(spaces);
// Define projection weak form.
WeakForm<Scalar>* proj_wf = new WeakForm<Scalar>(n);
for (unsigned int i = 0; i < n; i++)
{
proj_wf->add_matrix_form(mfvol[i]);
// FIXME
// proj_wf->add_vector_form(i, proj_liforms[i].first, proj_liforms[i].second, HERMES_ANY, source_meshfns[i]);
}
project_internal(spaces, proj_wf, target_vec, matrix_solver_type);
}
示例4: 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());
}
}
}
示例5: 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;
}
}
}
示例6: 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];
}
}
示例7: 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]);
}
示例8: LengthException
void Continuity<Scalar>::Record::load_solutions(Hermes::vector<Solution<Scalar>*> solutions, Hermes::vector<Space<Scalar>*> spaces)
{
if(solutions.size() != spaces.size())
throw Exceptions::LengthException(1, 2, solutions.size(), spaces.size());
for(unsigned int i = 0; i < solutions.size(); i++)
{
std::stringstream filename;
filename << Continuity<Scalar>::solutionFileName << i << '_' << (std::string)"t = " << this->time << (std::string)"n = " << this->number << (std::string)".h2d";
solutions[i]->load(filename.str().c_str(), spaces[i]->get_mesh());
solutions[i]->space = spaces[i];
solutions[i]->space_type = spaces[i]->get_type();
solutions[i]->space_seq = spaces[i]->get_seq();
}
}
示例9: while
void NeighborSearch<Scalar>::clear_initial_sub_idx()
{
_F_;
if(neighborhood_type != H2D_DG_GO_DOWN)
return;
// Obtain the transformations sequence.
Hermes::vector<unsigned int> transformations = get_transforms(original_central_el_transform);
// Test for active element.
if(transformations.empty())
return;
for(unsigned int i = 0; i < n_neighbors; i++)
{
// Find the index where the additional subelement mapping (on top of the initial one from assembling) starts.
unsigned int j = 0;
// Note that we do not have to test if central_transformations is empty or how long it is, because it has to be
// longer than transformations (and that is tested).
// Also the function compatible_transformations() does not have to be used, as now the array central_transformations
// has been adjusted so that it contains the array transformations.
while(central_transformations.get(i)->transf[j] == transformations[j])
if(++j > transformations.size() - 1)
break;
central_transformations.get(i)->strip_initial_transformations(j);
}
}
示例10:
void DiscreteProblemIntegrationOrderCalculator<Scalar>::deinit_ext_orders(Hermes::vector<MeshFunctionSharedPtr<Scalar> >& ext, Hermes::vector<UExtFunctionSharedPtr<Scalar> >& u_ext_fns, Func<Hermes::Ord>** ext_func)
{
if (ext_func)
{
for (int ext_i = 0; ext_i < u_ext_fns.size(); ext_i++)
delete ext_func[ext_i];
for (int ext_i = 0; ext_i < ext.size(); ext_i++)
{
if (ext[ext_i] && ext[ext_i]->get_active_element())
delete ext_func[u_ext_fns.size() + ext_i];
}
delete[] ext_func;
}
}
示例11:
int Space<Scalar>::get_num_dofs(Hermes::vector<Space<Scalar>*> spaces)
{
int ndof = 0;
for (unsigned int i = 0; i<spaces.size(); i++)
ndof += spaces[i]->get_num_dofs();
return ndof;
}
示例12: if
void NeighborSearch<Scalar>::update_according_to_sub_idx(const Hermes::vector<unsigned int>& transformations)
{
_F_;
if(neighborhood_type == H2D_DG_NO_TRANSF || neighborhood_type == H2D_DG_GO_UP)
{
if (!neighbor_transformations.present(0)) // in case of neighborhood_type == H2D_DG_NO_TRANSF
neighbor_transformations.add(new Transformations, 0);
Transformations *tr = neighbor_transformations.get(0);
for(unsigned int i = 0; i < transformations.size(); i++)
// Triangles.
if(central_el->get_mode() == HERMES_MODE_TRIANGLE)
if ((active_edge == 0 && transformations[i] == 0) ||
(active_edge == 1 && transformations[i] == 1) ||
(active_edge == 2 && transformations[i] == 2))
tr->transf[tr->num_levels++] = (!neighbor_edge.orientation ? neighbor_edge.local_num_of_edge : (neighbor_edge.local_num_of_edge + 1) % 3);
else
tr->transf[tr->num_levels++] = (neighbor_edges[0].orientation ? neighbor_edge.local_num_of_edge : (neighbor_edge.local_num_of_edge + 1) % 3);
// Quads.
else
if ((active_edge == 0 && (transformations[i] == 0 || transformations[i] == 6)) ||
(active_edge == 1 && (transformations[i] == 1 || transformations[i] == 4)) ||
(active_edge == 2 && (transformations[i] == 2 || transformations[i] == 7)) ||
(active_edge == 3 && (transformations[i] == 3 || transformations[i] == 5)))
tr->transf[tr->num_levels++] = (!neighbor_edge.orientation ? neighbor_edge.local_num_of_edge : (neighbor_edge.local_num_of_edge + 1) % 4);
else if ((active_edge == 0 && (transformations[i] == 1 || transformations[i] == 7)) ||
(active_edge == 1 && (transformations[i] == 2 || transformations[i] == 5)) ||
(active_edge == 2 && (transformations[i] == 3 || transformations[i] == 6)) ||
(active_edge == 3 && (transformations[i] == 0 || transformations[i] == 4)))
tr->transf[tr->num_levels++] = (neighbor_edge.orientation ? neighbor_edge.local_num_of_edge : (neighbor_edge.local_num_of_edge + 1) % 4);
}
else handle_sub_idx_way_down(transformations);
}
示例13:
void OGProjection<Scalar>::project_global(Hermes::vector<Space<Scalar>*> spaces, Hermes::vector<Solution<Scalar>*> source_sols,
Scalar* target_vec, Hermes::MatrixSolverType matrix_solver_type, Hermes::vector<ProjNormType> proj_norms)
{
Hermes::vector<MeshFunction<Scalar>*> mesh_fns;
for(unsigned int i = 0; i < source_sols.size(); i++)
mesh_fns.push_back(source_sols[i]);
project_global(spaces, mesh_fns, target_vec, matrix_solver_type, proj_norms);
}
示例14: filter_fn
void filter_fn(int n, Hermes::vector<scalar*> values, scalar* result)
{
for (int i = 0; i < n; i++) {
result[i] = 0;
for (unsigned int j = 0; j < values.size(); j++)
result[i] += nu[j] * Sigma_f[j] * values.at(j)[i];
}
}
示例15:
void OGProjection<Scalar>::project_global(const Hermes::vector<SpaceSharedPtr<Scalar> >& spaces,
const Hermes::vector<MatrixFormVol<Scalar>*>& custom_projection_jacobians,
const Hermes::vector<VectorFormVol<Scalar>*>& custom_projection_residuals,
const Hermes::vector<MeshFunctionSharedPtr<Scalar> >& target_slns)
{
int n = spaces.size();
// Sanity checks.
if (n != target_slns.size()) throw Exceptions::LengthException(1, 2, n, target_slns.size());
if (n != custom_projection_jacobians.size()) throw Exceptions::LengthException(1, 2, n, custom_projection_residuals.size());
if (n != custom_projection_residuals.size()) throw Exceptions::LengthException(1, 2, n, custom_projection_residuals.size());
for (int i = 0; i < n; i++)
{
project_global(spaces[i], custom_projection_jacobians[i], custom_projection_residuals[i], target_slns[i]);
}
}