00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <FunctionExpressionConvection.hpp>
00021
00022 #include <MeshOfHexahedra.hpp>
00023 #include <Information.hpp>
00024
00025 #include <Convection.hpp>
00026
00027 std::ostream& FunctionExpressionConvection::
00028 put(std::ostream& os) const
00029 {
00030 if (__scalarFunction != 0) {
00031 os << *__scalarFunction;
00032 } else {
00033 os << "convect(" << *__field << ','
00034 << *__timeStep << ',' << *__convectedFunction << ')';
00035 }
00036 return os;
00037 }
00038
00039 void FunctionExpressionConvection::
00040 execute()
00041 {
00042 __convectedFunction->execute();
00043
00044 __field->execute();
00045 __timeStep->execute();
00046
00047 if (Information::instance().usesMesh()) {
00048
00049 const Mesh& mesh = *Information::instance().getMesh();
00050
00051 if (__field->numberOfComponents() != 3) {
00052 throw ErrorHandler(__FILE__,__LINE__,
00053 "convection needs a 3 component field:\n"
00054 +stringify(*__field)+" has "+stringify(__field->numberOfComponents())+" components",
00055 ErrorHandler::normal);
00056 }
00057
00058 switch (mesh.type()) {
00059 case Mesh::cartesianHexahedraMesh: {
00060 __scalarFunction
00061 = new Convection<Structured3DMesh>(*__convectedFunction->function(),
00062 *__field->field(),
00063 __timeStep->realValue(),
00064 static_cast<const Structured3DMesh&>(mesh));
00065 break;
00066 }
00067 case Mesh::tetrahedraMesh: {
00068 __scalarFunction
00069 = new Convection<MeshOfTetrahedra>(*__convectedFunction->function(),
00070 *__field->field(),
00071 __timeStep->realValue(),
00072 static_cast<const MeshOfTetrahedra&>(mesh));
00073 break;
00074 }
00075 case Mesh::hexahedraMesh: {
00076 __scalarFunction
00077 = new Convection<MeshOfHexahedra>(*__convectedFunction->function(),
00078 *__field->field(),
00079 __timeStep->realValue(),
00080 static_cast<const MeshOfHexahedra&>(mesh));
00081 break;
00082 }
00083 default: {
00084 throw ErrorHandler(__FILE__,__LINE__,
00085 "convection is not implemented for this kind of mesh",
00086 ErrorHandler::unexpected);
00087 }
00088 }
00089
00090 __isToEvaluate = false;
00091 } else {
00092 __isToEvaluate = true;
00093 }
00094 }
00095
00096
00097 FunctionExpressionConvection::
00098 FunctionExpressionConvection(ReferenceCounting<FieldExpression> field,
00099 ReferenceCounting<RealExpression> dt,
00100 ReferenceCounting<FunctionExpression> phi)
00101 : FunctionExpression(FunctionExpression::convection),
00102 __isToEvaluate(true),
00103 __field(field),
00104 __timeStep(dt),
00105 __convectedFunction(phi)
00106 {
00107 ;
00108 }
00109
00110
00111 FunctionExpressionConvection::
00112 FunctionExpressionConvection(const FunctionExpressionConvection& f)
00113 : FunctionExpression(f),
00114 __isToEvaluate(f.__isToEvaluate),
00115 __field(f.__field),
00116 __timeStep(f.__timeStep),
00117 __convectedFunction(f.__convectedFunction)
00118 {
00119 ;
00120 }
00121
00122 FunctionExpressionConvection::~FunctionExpressionConvection()
00123 {
00124 ;
00125 }
00126