00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <DGFunctionBase.hpp>
00021
00022 #include <DGFunctionBuilder.hpp>
00023 #include <FiniteElementTraits.hpp>
00024
00025 #include <Structured3DMesh.hpp>
00026 #include <SpectralMesh.hpp>
00027 #include <MeshOfTetrahedra.hpp>
00028 #include <MeshOfHexahedra.hpp>
00029
00030 #include <MeshOfTriangles.hpp>
00031
00032 #include <DGFunction.hpp>
00033
00034 template <typename MeshType>
00035 void
00036 DGFunctionBuilder::
00037 __build(const ScalarDiscretizationTypeDG& d,
00038 const MeshType* mesh)
00039 {
00040 typedef typename MeshType::CellType CellType;
00041
00042 switch(d.type()) {
00043 case ScalarDiscretizationTypeBase::DGFEM0: {
00044 typedef
00045 FiniteElementTraits<CellType,ScalarDiscretizationTypeBase::lagrangianFEM0>
00046 FETraits;
00047
00048 __builtFunction
00049 = new DGFunction<MeshType, FETraits>(mesh);
00050 break;
00051 }
00052 case ScalarDiscretizationTypeBase::DGFEM1: {
00053 typedef
00054 FiniteElementTraits<CellType,ScalarDiscretizationTypeBase::lagrangianFEM1>
00055 FETraits;
00056
00057 __builtFunction
00058 = new DGFunction<MeshType, FETraits>(mesh);
00059 break;
00060 }
00061 case ScalarDiscretizationTypeBase::DGFEM2: {
00062 typedef
00063 FiniteElementTraits<CellType,ScalarDiscretizationTypeBase::lagrangianFEM2>
00064 FETraits;
00065
00066 __builtFunction
00067 = new DGFunction<MeshType, FETraits>(mesh);
00068 break;
00069
00070 }
00071 default: {
00072 throw ErrorHandler(__FILE__,__LINE__,
00073 "unknown discretization type",
00074 ErrorHandler::unexpected);
00075 }
00076 }
00077 }
00078
00079
00080 void
00081 DGFunctionBuilder::
00082 build(const ScalarDiscretizationTypeDG& d,
00083 const Mesh* mesh)
00084 {
00085 switch (mesh->type()) {
00086 case Mesh::cartesianHexahedraMesh: {
00087 const Structured3DMesh* m
00088 = dynamic_cast<const Structured3DMesh*>(mesh);
00089 this->__build(d, m);
00090 break;
00091 }
00092 case Mesh::hexahedraMesh: {
00093 const MeshOfHexahedra* m
00094 = dynamic_cast<const MeshOfHexahedra*>(mesh);
00095 this->__build(d, m);
00096 break;
00097 }
00098 case Mesh::spectralMesh: {
00099 const SpectralMesh* m
00100 = dynamic_cast<const SpectralMesh*>(mesh);
00101 this->__build(d, m);
00102 break;
00103 }
00104 case Mesh::tetrahedraMesh: {
00105 const MeshOfTetrahedra* m
00106 = dynamic_cast<const MeshOfTetrahedra*>(mesh);
00107 this->__build(d, m);
00108 break;
00109 }
00110 case Mesh::trianglesMesh: {
00111 const MeshOfTriangles* m
00112 = dynamic_cast<const MeshOfTriangles*>(mesh);
00113 this->__build(d, m);
00114 break;
00115 }
00116 default: {
00117 throw ErrorHandler(__FILE__,__LINE__,
00118 "not supported mesh type",
00119 ErrorHandler::unexpected);
00120 }
00121 }
00122 }
00123
00124 void
00125 DGFunctionBuilder::
00126 build(const ScalarDiscretizationTypeDG& d,
00127 const Mesh* mesh,
00128 const ScalarFunctionBase& u)
00129 {
00130 this->build(d,mesh);
00131 DGFunctionBase& dgFunctionView = dynamic_cast<DGFunctionBase&>(*__builtFunction);
00132 dgFunctionView = u;
00133 }
00134
00135
00136 void
00137 DGFunctionBuilder::
00138 build(const ScalarDiscretizationTypeDG& d,
00139 const Mesh* mesh,
00140 const Vector<real_t>& values,
00141 const real_t& outsideValue)
00142 {
00143 this->build(d,mesh);
00144 DGFunctionBase& dgFunctionView = dynamic_cast<DGFunctionBase&>(*__builtFunction);
00145 dgFunctionView = values;
00146 dgFunctionView.setOutsideValue(outsideValue);
00147 }
00148
00149 ReferenceCounting<DGFunctionBase>
00150 DGFunctionBuilder::
00151 getBuiltDGFunction()
00152 {
00153 return __builtFunction;
00154 }
00155
00156 ConstReferenceCounting<ScalarFunctionBase>
00157 DGFunctionBuilder::
00158 getBuiltScalarFunction() const
00159 {
00160 return static_cast<const DGFunctionBase*>(__builtFunction);
00161 }
00162
00163 DGFunctionBuilder::
00164 DGFunctionBuilder()
00165 {
00166 ;
00167 }
00168
00169 DGFunctionBuilder::
00170 ~DGFunctionBuilder()
00171 {
00172 ;
00173 }