Permalink
Browse files

Merge branch 'additions' of github.com:mhanus/hermes

  • Loading branch information...
2 parents 45df2be + dd87f0b commit b3d91895b873644e7ffd2cd6b82b48d6d325c391 @l-korous l-korous committed Mar 3, 2013
@@ -581,6 +581,8 @@ namespace Hermes
friend class Views::ScalarView;
friend class Views::Orderizer;
public:
+ const ElementMarkersConversion &get_element_markers_conversion() const;
+ const BoundaryMarkersConversion &get_boundary_markers_conversion() const;
ElementMarkersConversion &get_element_markers_conversion();
BoundaryMarkersConversion &get_boundary_markers_conversion();
@@ -89,7 +89,7 @@ namespace Hermes
/// Solve.
/// \param[in] coeff_vec Ceofficient vector to start from.
- void solve(Scalar* coeff_vec = NULL);
+ virtual void solve(Scalar* coeff_vec = NULL);
/// Solve.
/// \param[in] initial_guess Solution to start from (which is projected to obtain the initial coefficient vector.
@@ -124,8 +124,11 @@ namespace Hermes
/// Set the weak forms.
void set_weak_formulation(const WeakForm<Scalar>* wf);
- private:
+ protected:
void init();
+
+ static void calculate_anderson_coeffs(Scalar** previous_vectors, Scalar* anderson_coeffs, int num_last_vectors_used, int ndof);
+
bool verbose_output_linear_solver;
/// Matrix.
@@ -37,12 +37,31 @@ namespace Hermes
OGProjection();
/// Main functionality is in the protected method project_internal().
- /// This is a wrapper that delivers a Solution instead of a coefficient vector.
+
+ /// This method allows to specify your own OG-projection form.
void project_global(const Space<Scalar>* space,
MatrixFormVol<Scalar>* custom_projection_jacobian,
VectorFormVol<Scalar>* custom_projection_residual,
Scalar* target_vec);
+ /// Wrapper that delivers a Solution instead of a coefficient vector.
+ void project_global(const Space<Scalar>* space,
+ MatrixFormVol<Scalar>* custom_projection_jacobian,
+ VectorFormVol<Scalar>* custom_projection_residual,
+ Solution<Scalar>* target_sln);
+
+ /// This method allows to specify your own multiple OG-projection forms.
+ void project_global(const Hermes::vector<const Space<Scalar>*>& spaces,
+ const Hermes::vector<MatrixFormVol<Scalar>*>& custom_projection_jacobian,
+ const Hermes::vector<VectorFormVol<Scalar>*>& custom_projection_residual,
+ Scalar* target_vec);
+
+ /// Wrapper that delivers a vector of Solutions instead of a coefficient vector.
+ void project_global(const Hermes::vector<const Space<Scalar>*>& spaces,
+ const Hermes::vector<MatrixFormVol<Scalar>*>& custom_projection_jacobian,
+ const Hermes::vector<VectorFormVol<Scalar>*>& custom_projection_residual,
+ const Hermes::vector<Solution<Scalar>*>& target_slns);
+
/**
\fn static void OGProjection::project_global(Space<Scalar>* space,
MeshFunction<Scalar>* source_meshfn, Scalar* target_vec,
@@ -2217,6 +2217,16 @@ namespace Hermes
return HERMES_BOUNDARY_MARKERS_CONVERSION;
}
+ const Mesh::ElementMarkersConversion &Mesh::get_element_markers_conversion() const
+ {
+ return element_markers_conversion;
+ }
+
+ const Mesh::BoundaryMarkersConversion &Mesh::get_boundary_markers_conversion() const
+ {
+ return boundary_markers_conversion;
+ }
+
Mesh::ElementMarkersConversion &Mesh::get_element_markers_conversion()
{
return element_markers_conversion;
@@ -136,7 +136,7 @@ namespace Hermes
}
template<typename Scalar>
- void calculate_anderson_coeffs(Scalar** previous_vectors, Scalar* anderson_coeffs, int num_last_vectors_used, int ndof)
+ void PicardSolver<Scalar>::calculate_anderson_coeffs(Scalar** previous_vectors, Scalar* anderson_coeffs, int num_last_vectors_used, int ndof)
{
if(num_last_vectors_used <= 1) throw Hermes::Exceptions::Exception("Picard: Anderson acceleration makes sense only if at least two last iterations are used.");
@@ -67,7 +67,68 @@ namespace Hermes
// Clean up.
delete proj_wf;
}
+
+ template<typename Scalar>
+ void OGProjection<Scalar>::project_global(const Space<Scalar>* space,
+ MatrixFormVol<Scalar>* custom_projection_jacobian,
+ VectorFormVol<Scalar>* custom_projection_residual,
+ Solution<Scalar>* target_sln)
+ {
+ // Calculate the coefficient vector.
+ int ndof = space->get_num_dofs();
+ Scalar* target_vec = new Scalar[ndof];
+
+ project_global(space, custom_projection_jacobian, custom_projection_residual, target_vec);
+
+ // Translate coefficient vector into a Solution.
+ Solution<Scalar>::vector_to_solution(target_vec, space, target_sln);
+ // Clean up.
+ delete [] target_vec;
+ }
+
+ template<typename Scalar>
+ void OGProjection<Scalar>::project_global(const Hermes::vector<const Space<Scalar>*>& spaces,
+ const Hermes::vector<MatrixFormVol<Scalar>*>& custom_projection_jacobians,
+ const Hermes::vector<VectorFormVol<Scalar>*>& custom_projection_residuals,
+ Scalar* target_vec)
+ {
+ int n = spaces.size();
+
+ // Sanity checks.
+ if(target_vec == NULL) throw Exceptions::NullException(3);
+ 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());
+
+ int start_index = 0;
+ for (int i = 0; i < n; i++)
+ {
+
+ project_global(spaces[i], custom_projection_jacobians[i], custom_projection_residuals[i], target_vec + start_index);
+
+ start_index += spaces[i]->get_num_dofs();
+ }
+ }
+
+ template<typename Scalar>
+ void OGProjection<Scalar>::project_global(const Hermes::vector<const Space<Scalar>*>& spaces,
+ const Hermes::vector<MatrixFormVol<Scalar>*>& custom_projection_jacobians,
+ const Hermes::vector<VectorFormVol<Scalar>*>& custom_projection_residuals,
+ const Hermes::vector<Solution<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]);
+ }
+ }
+
template<typename Scalar>
void OGProjection<Scalar>::project_global(const Space<Scalar>* space,
MeshFunction<Scalar>* source_meshfn, Scalar* target_vec,
@@ -71,6 +71,12 @@ namespace Hermes
bool operator>(std::complex<double> d);
bool operator<(const Ord &o);
bool operator>(const Ord &o);
+
+ friend std::ostream & operator<< (std::ostream& os, const Ord& ord)
+ {
+ os << "Integration order: " << ord.get_order() << std::endl;
+ return os;
+ }
protected:
int order;

0 comments on commit b3d9189

Please sign in to comment.