00001 #ifndef _FIELD_H_
00002 #define _FIELD_H_
00003
00004 #include "fv_float.h"
00005 #include "fv_config.h"
00006 #include "../../utils/fv_assert.h"
00007 #include "../../include/BaseField.h"
00008 #include"CutPlane.h"
00009 #include "Mesh.h"
00010
00011 #ifdef _USE_FV_EXT_MOD
00012 #include "../../include/ApproxModule.h"
00013 #endif
00014 #include "GraphicElem.hpp"
00015 #include <utility>
00016 #include <vector>
00017 #include <string>
00018
00019
00020
00021 #define FV_DEF_P 101
00022 #define FV_DEF_MIN_P_STD 1
00023 #define FV_DEF_MAX_P_STD 9
00024 #define FV_DEF_MIN_P_DG 101
00025 #define FV_DEF_MAX_P_DG 909
00026
00027
00028 namespace FemViewer {
00029
00030 class ModelControler;
00031 class Mesh;
00032 class Object;
00033 class RenderParams;
00034 class CutPlane;
00035 class Legend;
00036
00037
00038
00039
00040 class Field : public BaseField
00041 {
00042 friend class ModelControler;
00043
00044 public:
00045 explicit Field(Mesh& pmesh_,const std::string& name_ = "");
00046 ~Field();
00047
00048 int Init(const int parent_id_,const char* file_name_);
00049
00050 void CalculateMinMaxValues(double& min_value, double& max_value,
00051 std::vector<double>& vec_values,const int ctrl =1) const;
00052
00053 size_t CountCoeffs(std::vector<int>* degree_ptr = nullptr) const ;
00054 size_t PackCoeffs(std::vector<mfvFloat_t>& Coeffs,std::vector<int>& Degree);
00055 static uint32_t FillArrayWithCoeffs(const Field *pField,CoordType Coeffs[]);
00056 int Free();
00057 void Reset();
00058 void Clear();
00059
00060 void Render() const;
00061
00062 int GetMinimalDegree() const { return m_min_deg; }
00063 int GetMaximalDegree() const { return m_max_deg; }
00064
00065 double GetMinimalValue() const { return m_min_val; }
00066 double GetMaximalValue() const { return m_max_val; }
00067
00068
00069
00070 int RenderDG(std::vector<Vertex>& out_vertices,std::vector<unsigned>& out_indices,
00071 std::vector<int>& out_counts,std::vector<int64_t>& out_offsets);
00072
00073 int RenderDGCutted(const std::vector<CutPlane>& vplanes, std::vector<Vertex>& out_vertices,std::vector<unsigned>& out_indices
00074
00075 );
00076 int RenderSTD(
00077 std::vector<Vertex>& out_vertices,
00078 std::vector<unsigned>& out_indices
00079 );
00080
00081
00082
00083 public:
00084 template<typename T = double>
00085 int GetElementDofs(int nel,T Dofs[]) const {
00086 return get_element_dofs(this->idx(),nel,this->_solution.currSolution,Dofs);
00087 }
00088 int GetElementDegree(int nel) const {
00089 return get_el_pdeg(this->idx(), nel, NULL);
00090 }
00091 int GetElementBaseType(int nel) const {
00092 return get_base_type(this->idx(), nel);
00093 }
00094 int GetNumberOfShapeFunc(int nel,int* degree) const {
00095 (void)get_el_pdeg(this->idx(),nel,degree);
00096 return get_el_pdeg_numshap(this->idx(), nel, degree);
00097 }
00098 int GetDegreeVector(int nel, int Pdeg[]) const;
00099 int CalculateSolution(int control, int pdeg, int base,
00100 double* ElCoords,
00101 double* Ploc,
00102 double* Coeffs,
00103 double* Sol,
00104 double* DSolx = NULL,
00105 double* DSoly = NULL,
00106 double* DSolz = NULL) const;
00107
00108
00109 #ifdef FV_DEBUG
00110 void dumpField () const;
00111 #endif
00112 private:
00114 const Mesh& m_mesh;
00116 std::string m_name;
00117
00118 int m_min_deg;
00119 int m_max_deg;
00121 mutable double m_min_val;
00122 mutable double m_max_val;
00124 std::vector<int> m_elem_degs;
00125 std::vector<double> m_elem_values;
00126 };
00127
00128 template<>
00129 inline int Field::GetElementDofs<float>(int nel,float Dofs[]) const
00130 {
00131 double lDofs[1024];
00132 int nr_dofs = get_element_dofs(this->idx(),nel,this->_solution.currSolution,lDofs);
00133 for (int i(0); i<nr_dofs; ++i) Dofs[i] = static_cast<float>(lDofs[i]);
00134 return nr_dofs;
00135 }
00136
00137 }
00138
00139 #endif
00140