FiniteElementMethod Class Reference

#include <FiniteElementMethod.hpp>

Inheritance diagram for FiniteElementMethod:

Inheritance graph
[legend]
Collaboration diagram for FiniteElementMethod:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void Discretize (ConstReferenceCounting< Problem > Pb)
void Compute (Solution &u)
const Problemproblem () const
const Meshmesh () const
 FiniteElementMethod (const DiscretizationType &discretizationType, ConstReferenceCounting< Mesh > mesh, const DegreeOfFreedomSet &dOfFreedom)
 ~FiniteElementMethod ()

Protected Attributes

DiscretizationType __discretizationType

Private Member Functions

template<typename MeshType, ScalarDiscretizationTypeBase::Type TypeOfDiscretization>
void __discretizeOnMesh ()
template<ScalarDiscretizationTypeBase::Type TypeOfDiscretization>
void __discretize ()

Private Attributes

ReferenceCounting< BaseMatrix__A
ReferenceCounting< BaseVector__b
ConstReferenceCounting< Mesh__mesh
ConstReferenceCounting< Problem__problem
const DegreeOfFreedomSet__degreeOfFreedomSet


Detailed Description

Definition at line 45 of file FiniteElementMethod.hpp.


Constructor & Destructor Documentation

FiniteElementMethod::FiniteElementMethod ( const DiscretizationType discretizationType,
ConstReferenceCounting< Mesh mesh,
const DegreeOfFreedomSet dOfFreedom 
)

Definition at line 187 of file FiniteElementMethod.cpp.

References StaticBase< SolverInformationCenter >::instance(), SolverInformationCenter::pushDiscretizationType(), and SolverInformationCenter::pushMesh().

00190   : Method(discretizationType),
00191     __mesh(mesh),
00192     __degreeOfFreedomSet(dOfFreedom)
00193 {
00194   SolverInformationCenter::instance().pushMesh(mesh);
00195   SolverInformationCenter::instance().pushDiscretizationType(&discretizationType);
00196 }

Here is the call graph for this function:

FiniteElementMethod::~FiniteElementMethod (  ) 

Definition at line 199 of file FiniteElementMethod.cpp.

References StaticBase< SolverInformationCenter >::instance(), and SolverInformationCenter::pop().

00200 {
00201   SolverInformationCenter::instance().pop();
00202 }

Here is the call graph for this function:


Member Function Documentation

template<typename MeshType, ScalarDiscretizationTypeBase::Type TypeOfDiscretization>
void FiniteElementMethod::__discretizeOnMesh (  )  [inline, private]

Definition at line 52 of file FiniteElementMethod.cpp.

References __A, __b, __degreeOfFreedomSet, Method::__discretizationType, BaseMatrix::doubleHashedMatrix, ffout(), mesh(), problem(), MemoryManager::ReserveMatrix(), MemoryManager::ReserveVector(), DegreeOfFreedomSet::size(), Timer::start(), and Timer::stop().

00053 {
00054   MemoryManager MM;
00055 
00056   bool performAssembling =MM.ReserveMatrix(__A,
00057                                            problem().numberOfUnknown(),
00058                                            __degreeOfFreedomSet.size());
00059 
00060   MM.ReserveVector(__b,
00061                    problem().numberOfUnknown(),
00062                    __degreeOfFreedomSet.size());
00063 
00064   ffout(2) << "Finite element method: disretization...\n";
00065 
00066   ReferenceCounting<FEMDiscretization<MeshType,
00067                                       TypeOfDiscretization> > FEM
00068     = new FEMDiscretization<MeshType,
00069                             TypeOfDiscretization>(problem(),
00070                                                   dynamic_cast<const MeshType&>(mesh()),
00071                                                   __discretizationType,
00072                                                   *__A,*__b, __degreeOfFreedomSet);
00073 
00074   if (performAssembling) {
00075     FEM->assembleMatrix();
00076   } else {
00077     ffout(2) << "- keeping previous operator discretization\n";
00078   }
00079 
00080   FEM->assembleSecondMember();
00081 
00082 
00083   ffout(2) << "- discretizing boundary conditions\n";
00084 
00085   BoundaryConditionDiscretizationFEM<MeshType,
00086                                      TypeOfDiscretization>* bcd
00087     = new BoundaryConditionDiscretizationFEM<MeshType,
00088                                              TypeOfDiscretization>(problem(),
00089                                                                    dynamic_cast<const MeshType&>(mesh()),
00090                                                                    __degreeOfFreedomSet);
00091   bcd->associatesMeshesToBoundaryConditions();
00092   ReferenceCounting<BoundaryConditionDiscretization> bcDiscretization = bcd;
00093 
00094   // Set Dirichlet information to the matrix
00095   FEM->setDirichletList(bcDiscretization->getDirichletList());
00096 
00097   ffout(2) << "- second member modification\n";
00098   bcDiscretization->setSecondMember(__A,__b);
00099 
00100   ffout(2) << "- matrix modification\n";
00101   bcDiscretization->setMatrix(__A,__b);
00102 
00103   ffout(2) << "Finite element method: disretization done\n";
00104 
00105   if (__A->type() == BaseMatrix::doubleHashedMatrix) {
00106     Timer t;
00107     t.start();
00108 
00109 #warning temporary implementation
00110 #ifdef    HAVE_PETSC
00111     PETScMatrix* aa
00112       = new PETScMatrix(static_cast<DoubleHashedMatrix&>(*__A));
00113     __A = aa; // now use sparse matrix
00114 #else  // HAVE_PETSC
00115     SparseMatrix* aa
00116       = new SparseMatrix(static_cast<DoubleHashedMatrix&>(*__A));
00117     
00118     __A = aa; // now use sparse matrix
00119 #endif // HAVE_PETSC
00120 
00121     t.stop();
00122     ffout(2) << "Matrix copy: " << t << '\n';
00123   }
00124 }

Here is the call graph for this function:

template<ScalarDiscretizationTypeBase::Type TypeOfDiscretization>
void FiniteElementMethod::__discretize (  )  [inline, private]

Definition at line 127 of file FiniteElementMethod.cpp.

References Mesh::cartesianHexahedraMesh, Mesh::hexahedraMesh, mesh(), ErrorHandler::normal, Mesh::spectralMesh, and Mesh::tetrahedraMesh.

00128 {
00129   switch (mesh().type()) {
00130   case Mesh::cartesianHexahedraMesh: {
00131     this->__discretizeOnMesh<Structured3DMesh, TypeOfDiscretization>();
00132     break;
00133   }
00134   case Mesh::hexahedraMesh: {
00135     this->__discretizeOnMesh<MeshOfHexahedra, TypeOfDiscretization>();
00136     break;
00137   }
00138   case Mesh::tetrahedraMesh: {
00139     this->__discretizeOnMesh<MeshOfTetrahedra, TypeOfDiscretization>();
00140     break;
00141   }
00142   case Mesh::spectralMesh: {
00143     this->__discretizeOnMesh<SpectralMesh, TypeOfDiscretization>();
00144     break;
00145   }
00146   default: {
00147     throw ErrorHandler(__FILE__, __LINE__,
00148                        "Cannot use '"+mesh().typeName()+"' for finite element computations",
00149                        ErrorHandler::normal);
00150   }
00151   }
00152 }

Here is the call graph for this function:

void FiniteElementMethod::Discretize ( ConstReferenceCounting< Problem Pb  )  [virtual]

Implements Method.

Definition at line 154 of file FiniteElementMethod.cpp.

References Method::__discretizationType, __problem, ScalarDiscretizationTypeBase::lagrangianFEM0, ScalarDiscretizationTypeBase::lagrangianFEM1, ScalarDiscretizationTypeBase::lagrangianFEM2, and ErrorHandler::normal.

00155 {
00156   __problem = Pb;
00157 
00158   switch(__discretizationType[0].type()) {
00159   case ScalarDiscretizationTypeBase::lagrangianFEM0: {
00160     this->__discretize<ScalarDiscretizationTypeBase::lagrangianFEM0>();
00161     return;
00162   }
00163   case ScalarDiscretizationTypeBase::lagrangianFEM1: {
00164     this->__discretize<ScalarDiscretizationTypeBase::lagrangianFEM1>();
00165     return;
00166   }
00167   case ScalarDiscretizationTypeBase::lagrangianFEM2: {
00168     this->__discretize<ScalarDiscretizationTypeBase::lagrangianFEM2>();
00169     return;
00170   }
00171   default: {
00172     throw ErrorHandler(__FILE__,__LINE__,
00173                        "Discretization type not implemented",
00174                        ErrorHandler::normal);
00175   }
00176   }
00177 }

void FiniteElementMethod::Compute ( Solution u  )  [virtual]

Implements Method.

Definition at line 179 of file FiniteElementMethod.cpp.

References __A, __b, __degreeOfFreedomSet, problem(), KrylovSolver::solve(), and PDESolution::values().

00180 {
00181   PDESolution& u = static_cast<PDESolution&>(U);
00182   KrylovSolver K(*__A, *__b, __degreeOfFreedomSet);
00183   K.solve(problem(), u.values());
00184 }

Here is the call graph for this function:

const Problem& FiniteElementMethod::problem (  )  const [inline]

Definition at line 71 of file FiniteElementMethod.hpp.

References __problem.

Referenced by __discretizeOnMesh(), and Compute().

00072   {
00073     return *__problem;
00074   }

const Mesh& FiniteElementMethod::mesh (  )  const [inline]

Definition at line 76 of file FiniteElementMethod.hpp.

References __mesh.

Referenced by __discretize(), and __discretizeOnMesh().

00077   {
00078     return *__mesh;
00079   }


Member Data Documentation

Definition at line 49 of file FiniteElementMethod.hpp.

Referenced by __discretizeOnMesh(), and Compute().

Definition at line 50 of file FiniteElementMethod.hpp.

Referenced by __discretizeOnMesh(), and Compute().

Definition at line 52 of file FiniteElementMethod.hpp.

Referenced by mesh().

Definition at line 54 of file FiniteElementMethod.hpp.

Referenced by Discretize(), and problem().

Definition at line 56 of file FiniteElementMethod.hpp.

Referenced by __discretizeOnMesh(), and Compute().


The documentation for this class was generated from the following files:

Generated on Wed Nov 19 00:06:46 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6