FictitiousDomainMethod Class Reference

#include <FictitiousDomainMethod.hpp>

Inheritance diagram for FictitiousDomainMethod:

Inheritance graph
[legend]
Collaboration diagram for FictitiousDomainMethod:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void Discretize (ConstReferenceCounting< Problem > P)
void Compute (Solution &u)
const Problemproblem () const
const Meshmesh () const
 FictitiousDomainMethod (const DiscretizationType &discretization, ConstReferenceCounting< Mesh > mesh, const DegreeOfFreedomSet &dof)
virtual ~FictitiousDomainMethod ()
template<>
real_t __integrateCharacteristicFunction (const CartesianHexahedron &k, const Domain &d)

Protected Member Functions

virtual ReferenceCounting
< BoundaryConditionDiscretization
discretizeBoundaryConditions ()=0
void computesDegreesOfFreedom (ConstReferenceCounting< Problem > givenProblem)

Protected Attributes

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

Private Member Functions

template<typename MeshType>
void __computesDegreesOfFreedom (ConstReferenceCounting< Problem > givenProblem)
template<typename CellType>
real_t __integrateCharacteristicFunction (const CellType &e, const Domain &D)
template<typename MeshType, ScalarDiscretizationTypeBase::Type TypeOfDiscretization>
void __discretizeOnMesh ()
template<ScalarDiscretizationTypeBase::Type TypeOfDiscretization>
void __discretize ()


Detailed Description

Definition at line 49 of file FictitiousDomainMethod.hpp.


Constructor & Destructor Documentation

FictitiousDomainMethod::FictitiousDomainMethod ( const DiscretizationType discretization,
ConstReferenceCounting< Mesh mesh,
const DegreeOfFreedomSet dof 
) [inline]

Constructs a FictitiousDomainMethod using a mesh and a given degree of freedom set.

Parameters:
discretization a discretization type
mesh a given mesh
dof a given degree of freedom set

Definition at line 150 of file FictitiousDomainMethod.hpp.

00153     : Method(discretization),
00154       __mesh(mesh),
00155       __degreeOfFreedomSet(dof)
00156   {
00157     ;
00158   }

virtual FictitiousDomainMethod::~FictitiousDomainMethod (  )  [inline, virtual]

Virtual Destructor

Definition at line 164 of file FictitiousDomainMethod.hpp.

00165   {
00166     ;
00167   }


Member Function Documentation

template<typename MeshType>
void FictitiousDomainMethod::__computesDegreesOfFreedom ( ConstReferenceCounting< Problem givenProblem  )  [inline, private]

Computes the degrees of freedom set and modifies the problem. The problem is modified to take into account the domain geometry. This template version use a specific MeshType.

Parameters:
givenProblem will be modified and stored in __problem

Definition at line 87 of file FictitiousDomainMethod.cpp.

References __integrateCharacteristicFunction(), __mesh, __problem, FEMFunctionBuilder::build(), ffout(), FEMFunctionBuilder::getBuiltScalarFunction(), Domain::inside(), ScalarDiscretizationTypeBase::lagrangianFEM0, mesh(), Mesh::numberOfVertices(), and Vector< T >::resize().

00088 {
00089   ffout(2) << "Adding Characteristic function of the domain to PDEs\n";
00090   Vector<bool> dofVertices;
00091 
00092   dofVertices.resize(mesh().numberOfVertices());
00093   dofVertices = false;
00094 
00095   const Domain& domain = *givenProblem->domain();
00096 
00097   for (size_t i=0; i<mesh().numberOfVertices(); ++i) {
00098     dofVertices[i] = domain.inside(mesh().vertex(i));
00099   }
00100 
00101   Vector<real_t> kiValues(mesh().numberOfCells()); // "mean" value of the characteristic function
00102 
00103   const MeshType& m = static_cast<const MeshType&>(*__mesh);
00104 
00105   for (size_t i=0; i<m.numberOfCells();++i) {
00106     const typename MeshType::CellType& k = m.cell(i);
00107     unsigned numberIn = 0;
00108 
00109     // Computation of the caracteristic function
00110     for (unsigned j=0; j<MeshType::CellType::NumberOfVertices; ++j) {
00111       numberIn += (dofVertices(m.vertexNumber(k(j))))?1:0;
00112     }
00113 
00114     switch (numberIn) {
00115     case 0: {
00116       k.setFictitious(true);
00117       kiValues[i] = 0;
00118       break;
00119     }
00120     case MeshType::CellType::NumberOfVertices: {
00121       kiValues[i] = 1;
00122       break;
00123     }
00124     default:{
00125       kiValues[i] = __integrateCharacteristicFunction(k, domain);
00126     }
00127     }
00128   }
00129 
00130   ScalarDiscretizationTypeFEM discretizationType(ScalarDiscretizationTypeBase::lagrangianFEM0);
00131 
00132   FEMFunctionBuilder femBuilder;
00133   femBuilder.build(discretizationType,
00134                    __mesh,
00135                    kiValues);
00136   ConstReferenceCounting<ScalarFunctionBase> u = femBuilder.getBuiltScalarFunction();
00137 
00138   __problem = (*givenProblem) * u;
00139   ffout(2) << "Adding Characteristic function of the domain to PDEs: done\n";
00140 
00141 //   ffout(2) << "Using "<< this->__degreeOfFreedomSet.numberOfUsedDOFPositions()
00142 //         << " DOF over "
00143 //         << this->__degreeOfFreedomSet.positionsSet(0).number() << " available!\n";
00144 }

Here is the call graph for this function:

template<typename CellType>
real_t FictitiousDomainMethod::__integrateCharacteristicFunction ( const CellType &  e,
const Domain D 
) [inline, private]

Definition at line 69 of file FictitiousDomainMethod.cpp.

References ErrorHandler::unexpected.

Referenced by __computesDegreesOfFreedom().

00070 {
00071   throw ErrorHandler(__FILE__,__LINE__,
00072                      "not implemented",
00073                        ErrorHandler::unexpected);
00074   return 0;
00075 }

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

Effectively discretizes the problem

Definition at line 165 of file FictitiousDomainMethod.cpp.

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

00166 {
00167   MemoryManager MM;
00168 
00169   bool performAssembling =MM.ReserveMatrix(__A,
00170                                            problem().numberOfUnknown(),
00171                                            __degreeOfFreedomSet.size());
00172 
00173   MM.ReserveVector(__b,
00174                    problem().numberOfUnknown(), 
00175                    __degreeOfFreedomSet.size());
00176 
00177   ffout(2) << "Fictitious domain method: discretization...\n";
00178 
00179   ReferenceCounting<FEMDiscretization<MeshType, TypeOfDiscretization> > FEM
00180     = new FEMDiscretization<MeshType,
00181                             TypeOfDiscretization>(problem(),
00182                                                   dynamic_cast<const MeshType&>(*__mesh),
00183                                                   __discretizationType,
00184                                                   *__A,*__b, __degreeOfFreedomSet);
00185 
00186   if (performAssembling) {
00187     FEM->assembleMatrix();
00188   } else {
00189     ffout(2) << "keeping previous operator discretization\n";
00190   }
00191 
00192   FEM->assembleSecondMember();
00193 
00194   ffout(2) << "- discretizing boundary conditions\n";
00195 
00196   ReferenceCounting<BoundaryConditionDiscretization> bcDiscretization
00197     = this->discretizeBoundaryConditions();
00198 
00199   // Set Dirichlet information to the matrix
00200   FEM->setDirichletList(bcDiscretization->getDirichletList());
00201 
00202   ffout(2) << "- second member modification\n";
00203 
00204   bcDiscretization->setSecondMember(__A,__b);
00205 
00206   ffout(2) << "- matrix modification\n";
00207 
00208   bcDiscretization->setMatrix(__A,__b);
00209 
00210   ffout(2) << "Fictitious domain method: discretization done\n";
00211 
00212   if (__A->type() == BaseMatrix::doubleHashedMatrix) {
00213     Timer t;
00214     t.start();
00215 
00216 #warning temporary implementation
00217 #ifdef    HAVE_PETSC
00218     PETScMatrix* aa
00219       = new PETScMatrix(static_cast<DoubleHashedMatrix&>(*__A));
00220     __A = aa; // now use sparse matrix
00221 #else  // HAVE_PETSC
00222     SparseMatrix* aa
00223       = new SparseMatrix(static_cast<DoubleHashedMatrix&>(*__A));
00224     __A = aa; // now use sparse matrix
00225 #endif // HAVE_PETSC
00226 
00227     t.stop();
00228     ffout(2) << "- matrix copy time: " << t << '\n';
00229   }
00230 }

Here is the call graph for this function:

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

Effectively discretizes the problem

Definition at line 233 of file FictitiousDomainMethod.cpp.

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

00234 {
00235 
00236   switch (this->mesh().type()) {
00237   case Mesh::cartesianHexahedraMesh: {
00238     this->__discretizeOnMesh<Structured3DMesh, TypeOfDiscretization>();
00239     break;
00240   }
00241   default: {
00242     throw ErrorHandler(__FILE__,__LINE__,
00243                        "this mesh type is not supported by FDM",
00244                        ErrorHandler::normal);
00245   }
00246   }
00247 
00248 }

Here is the call graph for this function:

virtual ReferenceCounting<BoundaryConditionDiscretization> FictitiousDomainMethod::discretizeBoundaryConditions (  )  [protected, pure virtual]

Specific call to the boundary condition discretization

Returns:
the boundary condition discretization

Implemented in EliminatedFictitiousDomain, and PenalizedFictitousDomain.

Referenced by __discretizeOnMesh().

void FictitiousDomainMethod::computesDegreesOfFreedom ( ConstReferenceCounting< Problem givenProblem  )  [protected]

Computes the degrees of freedom set and modifies the problem. The problem is modified to take into account the domain geometry

Parameters:
givenProblem will be modified and stored in __problem

Definition at line 147 of file FictitiousDomainMethod.cpp.

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

Referenced by Discretize().

00148 {
00149   switch (mesh().type()) {
00150   case Mesh::cartesianHexahedraMesh: {
00151     this->__computesDegreesOfFreedom<Structured3DMesh>(givenProblem);
00152     break;
00153   }
00154   default: {
00155     throw ErrorHandler(__FILE__,__LINE__,
00156                        "mesh type not supported by FDM",
00157                        ErrorHandler::normal);
00158   }
00159   }
00160 }

Here is the call graph for this function:

void FictitiousDomainMethod::Discretize ( ConstReferenceCounting< Problem P  )  [virtual]

Discretizes the problem P

Parameters:
P the problem to discretize

Implements Method.

Definition at line 250 of file FictitiousDomainMethod.cpp.

References Method::__discretizationType, computesDegreesOfFreedom(), ScalarDiscretizationTypeBase::lagrangianFEM1, ScalarDiscretizationTypeBase::lagrangianFEM2, and ErrorHandler::normal.

00251 {
00252   this->computesDegreesOfFreedom(givenProblem);
00253 
00254   switch(__discretizationType[0].type()) {
00255   case ScalarDiscretizationTypeBase::lagrangianFEM1: {
00256     this->__discretize<ScalarDiscretizationTypeBase::lagrangianFEM1>();
00257     return;
00258   }
00259   case ScalarDiscretizationTypeBase::lagrangianFEM2: {
00260     this->__discretize<ScalarDiscretizationTypeBase::lagrangianFEM2>();
00261     return;
00262   }
00263   default: {
00264     throw ErrorHandler(__FILE__,__LINE__,
00265                        "Discretization type not implemented",
00266                        ErrorHandler::normal);
00267   }
00268   }
00269 }

Here is the call graph for this function:

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

Computes the solution u of the problem

Parameters:
u the solution

Implements Method.

Definition at line 51 of file FictitiousDomainMethod.cpp.

References __A, __b, __degreeOfFreedomSet, Structured3DMesh::cell(), mesh(), Structured3DMesh::numberOfCells(), problem(), Cell::setFictitious(), KrylovSolver::solve(), and PDESolution::values().

00052 {
00053   const Structured3DMesh& m = dynamic_cast<const Structured3DMesh&>(mesh());
00054 
00055   KrylovSolver K(*__A, *__b, __degreeOfFreedomSet);
00056   
00057   PDESolution& u = static_cast<PDESolution&>(U);
00058 
00059   K.solve(problem(), u.values());
00060   for (size_t i=0; i<m.numberOfCells();++i) {
00061     const Cell& k = m.cell(i);
00062     k.setFictitious(false); // reset fictitious state!
00063  }
00064 }

Here is the call graph for this function:

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

Read only access to the problem

Returns:
the problem

Definition at line 126 of file FictitiousDomainMethod.hpp.

References __problem.

Referenced by PenalizedFictitousDomain::__discretizeBoundaryConditionsOnMesh(), EliminatedFictitiousDomain::__discretizeBoundaryConditionsOnMesh(), __discretizeOnMesh(), and Compute().

00127   {
00128     return *__problem;
00129   }

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

template<>
real_t FictitiousDomainMethod::__integrateCharacteristicFunction ( const CartesianHexahedron k,
const Domain d 
) [inline]

Definition at line 79 of file FictitiousDomainMethod.cpp.

References ConformTransformationQ1CartesianHexahedron::integrateCharacteristic().

00080 {
00081   ConformTransformationQ1CartesianHexahedron T(k);
00082   return T.integrateCharacteristic(d);
00083 }

Here is the call graph for this function:


Member Data Documentation

The matrix

Definition at line 53 of file FictitiousDomainMethod.hpp.

Referenced by __discretizeOnMesh(), and Compute().

The second member

Definition at line 54 of file FictitiousDomainMethod.hpp.

Referenced by __discretizeOnMesh(), and Compute().

The discretization mesh

Definition at line 56 of file FictitiousDomainMethod.hpp.

Referenced by __computesDegreesOfFreedom(), and mesh().

The problem to discretze

Definition at line 58 of file FictitiousDomainMethod.hpp.

Referenced by __computesDegreesOfFreedom(), and problem().


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

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