From: guido Date: Tue, 9 Feb 1999 10:37:59 +0000 (+0000) Subject: Approaching systems of equations X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d1e96ad6ea862772ff714592dd1f5ac41220534;p=dealii-svn.git Approaching systems of equations More ANSI conformance (math.h) git-svn-id: https://svn.dealii.org/trunk@768 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/fe/fe.h b/deal.II/deal.II/include/fe/fe.h index 9833e96bfd..9864d3dd4a 100644 --- a/deal.II/deal.II/include/fe/fe.h +++ b/deal.II/deal.II/include/fe/fe.h @@ -64,6 +64,11 @@ struct FiniteElementData<1> { */ const unsigned int n_transform_functions; + /** + * Number of components. + */ + const unsigned int n_components; + /** * Default constructor. Constructs an element * which is not so useful. Checking @@ -78,7 +83,8 @@ struct FiniteElementData<1> { */ FiniteElementData (const unsigned int dofs_per_vertex, const unsigned int dofs_per_line, - const unsigned int n_transform_functions); + const unsigned int n_transform_functions, + const unsigned int n_components = 1); /** * Another frequently used useful @@ -152,6 +158,11 @@ struct FiniteElementData<2> { */ const unsigned int n_transform_functions; + /** + * Number of components. + */ + const unsigned int n_components; + /** * Default constructor. Constructs an element * which is not so useful. Checking @@ -167,7 +178,8 @@ struct FiniteElementData<2> { FiniteElementData (const unsigned int dofs_per_vertex, const unsigned int dofs_per_line, const unsigned int dofs_per_quad, - const unsigned int n_transform_functions); + const unsigned int n_transform_functions, + const unsigned int n_components = 1); /** * Another frequently used useful @@ -1121,6 +1133,17 @@ class FiniteElement : public FiniteElementBase { virtual void get_local_mass_matrix (const DoFHandler::cell_iterator &cell, const Boundary &boundary, dFMatrix &local_mass_matrix) const =0; + + /** + * Compute system index from components. + */ + virtual unsigned component_to_system_index (unsigned component, + unsigned component_index) const; + + /** + * Compute component and index from system index. + */ + virtual pair system_to_component_index (unsigned index) const; /** * Exception diff --git a/deal.II/deal.II/include/fe/fe_lib.criss_cross.h b/deal.II/deal.II/include/fe/fe_lib.criss_cross.h index bda4a68a04..c703a736c9 100644 --- a/deal.II/deal.II/include/fe/fe_lib.criss_cross.h +++ b/deal.II/deal.II/include/fe/fe_lib.criss_cross.h @@ -8,7 +8,7 @@ #include #include - +#include /** * This class implements a rather unusual macro element, the so-called diff --git a/deal.II/deal.II/include/fe/fe_lib.lagrange.h b/deal.II/deal.II/include/fe/fe_lib.lagrange.h index 8eff486657..c44d72be05 100644 --- a/deal.II/deal.II/include/fe/fe_lib.lagrange.h +++ b/deal.II/deal.II/include/fe/fe_lib.lagrange.h @@ -9,7 +9,6 @@ #include - /** * Define a (bi-, tri-, etc)linear finite element in #dim# space dimensions, * along with (bi-, tri-)linear (therefore isoparametric) transforms from the diff --git a/deal.II/deal.II/include/fe/fe_linear_mapping.h b/deal.II/deal.II/include/fe/fe_linear_mapping.h index 68250cd016..4a489b7aba 100644 --- a/deal.II/deal.II/include/fe/fe_linear_mapping.h +++ b/deal.II/deal.II/include/fe/fe_linear_mapping.h @@ -6,6 +6,7 @@ /*---------------------------- fe_linear_mapping.h ---------------------------*/ +#include #include diff --git a/deal.II/deal.II/include/fe/fe_system.h b/deal.II/deal.II/include/fe/fe_system.h index 3f83f4df39..01651fdfb4 100644 --- a/deal.II/deal.II/include/fe/fe_system.h +++ b/deal.II/deal.II/include/fe/fe_system.h @@ -21,9 +21,8 @@ * shape functions. These #N# shape functions for each degree of freedom * of the basic finite element are numbered consecutively, i.e. for * the common case of a velocity #(u,v,w)#, the sequence of basis functions - * would be #u1, v1, w1, u2, v2, w2, ..., uN, vN, wN#. The other possibility - * would have been #u1, ..., uN, v1, ..., vN, w1, ...wN#, but we chose the - * first way. + * will be #u1, v1, w1, u2, v2, w2, ..., uN, vN, wN# compared to + * #u1, ..., uN, v1, ..., vN, w1, ...wN#. * * Using this scheme, the overall numbering of degrees of freedom is as * follows: for each subobject (vertex, line, quad, or hex), the degrees @@ -42,7 +41,7 @@ * \end{itemize} * * In the most cases, the composed element behaves as if it were a usual element - * with more degrees of freedom. Howeverm the underlying structure is visible in + * with more degrees of freedom. However the underlying structure is visible in * the restriction, prolongation and interface constraint matrices, which do not * couple the degrees of freedom of the subobject. E.g. the continuity requirement * is imposed for the shape functions of the subobjects separately; no requirement @@ -66,7 +65,14 @@ * @author Wolfgang Bangerth, 1999 */ template -class FESystem : public FiniteElement { +class FESystem : public FiniteElement +{ + /** + * Copy constructor prohibited. + */ + FESystem(const FESystem&); + + public: /** @@ -298,23 +304,55 @@ class FESystem : public FiniteElement { const unsigned int subface_no, const vector > &unit_points, vector > &normal_vectors) const; - - private: - /** - * Pointer to an object of the underlying - * finite element class. This object is - * created by the constructor. - */ - const FiniteElement *const base_element; /** * Number of subelements of this object. - * Since these objects may have + * Since these objects can have * subobjects themselves, this may be * smaller than the total number of finite * elements composed into this structure. + * This is definitely not what you'd + * usally intend, so don't do it! */ const unsigned int n_sub_elements; + + /** + * Access to the single valued element. + * + * If you assemble your system + * matrix, you usually will not + * want to have an FEValues object + * with a lot of equal entries. Ok, + * so initialize your FEValues with + * the #base_element# yuo get by + * this function. + * + */ + const FiniteElement& get_base_element() const; + + /** + * Calculate the actual position. + * + * For a given #component# + * (e.g. u,v,w in the example + * above) of the #base# function of + * the #base_element#, return the + * actual index in the local + * degrees of freedom vector of the + * system. + * + */ + unsigned index(unsigned component, unsigned base) const; + + private: + + /** + * Pointer to an object of the underlying + * finite element class. This object is + * created by the constructor. + */ + const FiniteElement *const base_element; + /** * Helper function used in the constructor: @@ -351,12 +389,26 @@ class FESystem : public FiniteElement { /* ------------------------- template functions ------------------------- */ +template +inline const FiniteElement& +FESystem::get_base_element() const +{ + return *base_element; +} + +template +inline unsigned +FESystem::index(unsigned component, unsigned base) const +{ + return n_sub_elements * base + component; +} + template template FESystem::FESystem (const FE &fe, const unsigned int n_elements) : FiniteElement (multiply_dof_numbers(fe, n_elements)), - base_element (new FE()), - n_sub_elements (n_elements) + n_sub_elements (n_elements), + base_element (new FE()) { base_element->subscribe (); initialize_matrices (); diff --git a/deal.II/deal.II/include/fe/fe_values.h b/deal.II/deal.II/include/fe/fe_values.h index 35c15b2f76..06c5d119b6 100644 --- a/deal.II/deal.II/include/fe/fe_values.h +++ b/deal.II/deal.II/include/fe/fe_values.h @@ -286,13 +286,31 @@ class FEValuesBase { * of the derived class was called, * at the quadrature points. * + * To get values of + * multi-component elements, + * there is another + * #get_function_values# + * returning a vector of vectors of + * results. + * * The function assumes that the * #values# object already has the - * right size. + * right size. */ void get_function_values (const dVector &fe_function, vector &values) const; + /** + * Access to vector valued finite element functions. + * + * This function does the same as + * the other #get_function_values#, + * but applied to multi-component + * elements. + */ + void get_function_values (const dVector &fe_function, + vector > &values) const; + /** * Return the gradient of the #i#th shape * function at the #j# quadrature point. @@ -471,6 +489,10 @@ class FEValuesBase { /** * Exception */ + DeclException0 (ExcWrongNoOfComponents); + /** + * Exception. + */ DeclException2 (ExcWrongVectorSize, int, int, << "Vector has wrong size " << arg1 diff --git a/deal.II/deal.II/include/grid/tria_boundary.h b/deal.II/deal.II/include/grid/tria_boundary.h index c110ee46a7..834991ce8c 100644 --- a/deal.II/deal.II/include/grid/tria_boundary.h +++ b/deal.II/deal.II/include/grid/tria_boundary.h @@ -7,6 +7,7 @@ #include #include +#include diff --git a/deal.II/deal.II/source/fe/fe.cc b/deal.II/deal.II/source/fe/fe.cc index 283e08b23d..7a619ebde6 100644 --- a/deal.II/deal.II/source/fe/fe.cc +++ b/deal.II/deal.II/source/fe/fe.cc @@ -21,7 +21,9 @@ FiniteElementData<1>::FiniteElementData () : dofs_per_line(0), dofs_per_face(0), total_dofs(0), - n_transform_functions(0) { + n_transform_functions(0), + n_components(0) +{ Assert (false, ExcInternalError()); }; @@ -29,12 +31,14 @@ FiniteElementData<1>::FiniteElementData () : FiniteElementData<1>::FiniteElementData (const unsigned int dofs_per_vertex, const unsigned int dofs_per_line, - const unsigned int n_transform_functions) : + const unsigned int n_transform_functions, + const unsigned int n_components) : dofs_per_vertex(dofs_per_vertex), dofs_per_line(dofs_per_line), dofs_per_face(dofs_per_vertex), total_dofs (2*dofs_per_vertex+dofs_per_line), - n_transform_functions(n_transform_functions) + n_transform_functions(n_transform_functions), + n_components(n_components) {}; @@ -44,7 +48,8 @@ FiniteElementData<1>::FiniteElementData (const FiniteElementData<1> &fe_data) : dofs_per_line(fe_data.dofs_per_line), dofs_per_face(fe_data.dofs_per_face), total_dofs (fe_data.total_dofs), - n_transform_functions(fe_data.n_transform_functions) + n_transform_functions(fe_data.n_transform_functions), + n_components(fe_data.n_components) {}; @@ -52,7 +57,8 @@ FiniteElementData<1>::FiniteElementData (const FiniteElementData<1> &fe_data) : bool FiniteElementData<1>::operator== (const FiniteElementData<1> &f) const { return ((dofs_per_vertex == f.dofs_per_vertex) && (dofs_per_line == f.dofs_per_line) && - (total_dofs == f.total_dofs)); + (total_dofs == f.total_dofs) && + (n_components == f.n_components)); }; #endif @@ -68,7 +74,9 @@ FiniteElementData<2>::FiniteElementData () : dofs_per_quad(0), dofs_per_face(0), total_dofs(0), - n_transform_functions(0) { + n_transform_functions(0), + n_components(0) +{ Assert (false, ExcInternalError()); }; @@ -77,7 +85,8 @@ FiniteElementData<2>::FiniteElementData () : FiniteElementData<2>::FiniteElementData (const unsigned int dofs_per_vertex, const unsigned int dofs_per_line, const unsigned int dofs_per_quad, - const unsigned int n_transform_functions) : + const unsigned int n_transform_functions, + const unsigned int n_components) : dofs_per_vertex(dofs_per_vertex), dofs_per_line(dofs_per_line), dofs_per_quad(dofs_per_quad), @@ -86,7 +95,8 @@ FiniteElementData<2>::FiniteElementData (const unsigned int dofs_per_vertex, total_dofs (4*dofs_per_vertex+ 4*dofs_per_line+ dofs_per_quad), - n_transform_functions (n_transform_functions) + n_transform_functions (n_transform_functions), + n_components(n_components) {}; @@ -97,7 +107,8 @@ FiniteElementData<2>::FiniteElementData (const FiniteElementData<2> &fe_data) : dofs_per_quad(fe_data.dofs_per_quad), dofs_per_face(fe_data.dofs_per_face), total_dofs (fe_data.total_dofs), - n_transform_functions (fe_data.n_transform_functions) + n_transform_functions (fe_data.n_transform_functions), + n_components(fe_data.n_components) {}; @@ -106,7 +117,8 @@ bool FiniteElementData<2>::operator== (const FiniteElementData<2> &f) const { return ((dofs_per_vertex == f.dofs_per_vertex) && (dofs_per_line == f.dofs_per_line) && (dofs_per_quad == f.dofs_per_quad) && - (total_dofs == f.total_dofs)); + (total_dofs == f.total_dofs) && + (n_components == f.n_components)); }; #endif diff --git a/deal.II/deal.II/source/fe/fe_system.cc b/deal.II/deal.II/source/fe/fe_system.cc index f8ba397cb9..1a43388b42 100644 --- a/deal.II/deal.II/source/fe/fe_system.cc +++ b/deal.II/deal.II/source/fe/fe_system.cc @@ -9,7 +9,8 @@ template -FESystem::~FESystem () { +FESystem::~FESystem () +{ base_element->unsubscribe (); delete base_element; }; @@ -17,11 +18,12 @@ FESystem::~FESystem () { template -void FESystem::initialize_matrices () { +void FESystem::initialize_matrices () +{ // distribute the matrices of the base // finite element to the matrices of // this object - for (unsigned int i=0; itotal_dofs; ++i) +/* for (unsigned int i=0; itotal_dofs; ++i) for (unsigned int j=0; jtotal_dofs; ++j) for (unsigned int n=0; n::initialize_matrices () { j*n_sub_elements + n) = base_element->constraints()(i,j); }; -}; +*/}; @@ -53,7 +55,8 @@ FESystem<1>::multiply_dof_numbers (const FiniteElementData<1> &fe_data, const unsigned int N) { return FiniteElementData<1> (fe_data.dofs_per_vertex * N, fe_data.dofs_per_line * N, - fe_data.n_transform_functions); + fe_data.n_transform_functions, + fe_data.n_components * N); }; #endif @@ -68,7 +71,8 @@ FESystem<2>::multiply_dof_numbers (const FiniteElementData<2> &fe_data, return FiniteElementData<2> (fe_data.dofs_per_vertex * N, fe_data.dofs_per_line * N, fe_data.dofs_per_quad * N, - fe_data.n_transform_functions); + fe_data.n_transform_functions, + fe_data.n_components * N); }; #endif diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc index 37e60ea2cc..9921778feb 100644 --- a/deal.II/deal.II/source/fe/fe_values.cc +++ b/deal.II/deal.II/source/fe/fe_values.cc @@ -62,7 +62,10 @@ double FEValuesBase::shape_value (const unsigned int i, template void FEValuesBase::get_function_values (const dVector &fe_function, - vector &values) const { + vector &values) const +{ + Assert (fe.n_components == 1, + ExcWrongNoOfComponents()); Assert (selected_dataset #include #include +#include /* Note: explicit instantiations at the end of the different sections! */ diff --git a/deal.II/deal.II/source/numerics/error_estimator.cc b/deal.II/deal.II/source/numerics/error_estimator.cc index b25f34be0e..784da34e8e 100644 --- a/deal.II/deal.II/source/numerics/error_estimator.cc +++ b/deal.II/deal.II/source/numerics/error_estimator.cc @@ -14,6 +14,7 @@ #include #include +#include