proteus  1.8.1
C/C++/Fortran libraries
MeshAdaptPUMI.h
Go to the documentation of this file.
1 #include "mesh.h"
2 #include <apf.h>
3 #include <apfMesh2.h>
4 #include <apfNumbering.h>
5 #include <queue>
6 #include "PyEmbeddedFunctions.h"
7 
20 
21  public:
24 
25  int loadModelAndMesh(const char* modelFile, const char* meshFile); //load the model and mesh
26  int loadMeshForAnalytic(const char* meshFile,double* boxDim, double* sphereCenter, double radius); //mesh and construct analytic geometry
27  void writeMesh(const char* meshFile);
28  void cleanMesh();
29 
30  //Functions to construct proteus mesh data structures
31  int reconstructFromProteus(Mesh& mesh, Mesh& globalMesh,int hasModel);
32  int reconstructFromProteus2(Mesh& mesh, int* isModelVert, int* bFaces);
34  int constructFromParallelPUMIMesh(Mesh& mesh, Mesh& subdomain_mesh);
35  int updateMaterialArrays(Mesh& mesh,int dim, int bdryID, int GeomTag);
36  int updateMaterialArrays(Mesh& mesh);
37  int updateMaterialArrays2(Mesh& mesh);
38  void numberLocally();
39  int localNumber(apf::MeshEntity* e);
40  int dumpMesh(Mesh& mesh);
41 
42  //Functions used to transfer proteus model data structures
43  int transferModelInfo(int*numGeomEntities,int*edges,int*faces,int*mVertex2Model,int*mEdgeVertex2Model,int*mBoundary2Model,int nMaxSegments);
45  int* edgeList;
46  int* faceList;
49 
50  //Functions used to transfer information between PUMI and proteus
51  int transferFieldToPUMI(const char* name, double const* inArray, int nVar, int nN);
52  int transferFieldToProteus(const char* name, double* outArray, int nVar, int nN);
53  int transferElementFieldToProteus(const char* name, double* outArray, int nVar, int nN);
54  int transferPropertiesToPUMI(double* rho_p, double* nu_p,double* g_p, double deltaT, double deltaT_next,double T_simulation,double interfaceBandSize);
55  //int setAdaptProperties(std::vector<std::string> sizeInputs,double hmax);
56  int setAdaptProperties(std::vector<std::string> sizeInputs,bool in_adapt, double in_hmax,double in_hmin,double in_hphi, int in_numAdaptSteps, double in_targetError, double in_gradingFactor, bool in_logging, int in_numIterations);
57  //int transferBCtagsToProteus(int* tagArray, int idx, int* ebN, int* eN_global, double* fluxBC);
58  //int transferBCsToProteus();
59 
60  //MeshAdapt functions
61  int willAdapt();
62  int willErrorAdapt();
64  int willInterfaceAdapt();
65  int adaptPUMIMesh(const char* input);
66  int setSphereSizeField();
67  int calculateSizeField(double L_band);
69 
72  int getERMSizeField(double err_total);
73  int gradeMesh(double gradationFactor);
74 
75  //analytic geometry
76  gmi_model* createSphereInBox(double* boxDim, double*sphereCenter,double radius);
77  void updateSphereCoordinates(double*sphereCenter);
78 
79  //Quality Check Functions
80  double getMinimumQuality();
81  double getTotalMass();
82 
83  //Functions that help facilitate computations
84  double getMPvalue(double field_val,double val_0, double val_1); //get the multiphase value of physical properties
85  apf::Field* getViscosityField(apf::Field* voff); //derive a field of viscosity based on VOF field
86 
87  //needed for checkpointing/restart
88  void set_nAdapt(int numberAdapt);
89 
90  //Public Variables
91  double hmax, hmin, hPhi; //bounds on mesh size
92  int numIter; //number of iterations for MeshAdapt
93  int nAdapt; //counter for number of adapt steps
94  int nTriggers; //counter for number of triggers
95  int nEstimate; //counter for number of error estimator calls
96  int nsd; //number of spatial dimensions
97  int maxAspect; //maximum aspect ratio
98  int adaptMesh; //is adaptivity turned on?
99  int numAdaptSteps; //Number adaptivity
100  double N_interface_band; //number of elements in half-band around interface
102  bool hasIBM;
104  bool hasVMS;
105  bool hasERM;
106  bool hasAniso;
108  bool useProteus;
110 
111 
112 
113  //User Inputs
114  std::string size_field_config; //What type of size field: interface, ERM, isotropic
115  std::string adapt_type_config; //What type of adapt for ERM: isotropic or anisotropic
116  std::string logging_config; // Logging on or off
117 
118  //Element Residual Method
119  void get_local_error(double& total_error);
120  void computeDiffusiveFlux(apf::Mesh*m,apf::Field* voff, apf::Field* visc,apf::Field* pref, apf::Field* velf);
121  void getBoundaryFlux(apf::Mesh* m, apf::MeshEntity* ent, double * endflux);
122  int getSimmetrixBC();
123  void removeBCData();
125 
126  //VMS
127  void get_VMS_error(double& total_error_out);
128 
129  //tags used to identify types of BC
130  apf::MeshTag* BCtag;
131  apf::MeshTag* DBCtag[4];
132  apf::MeshTag* fluxtag[4];
133 
135 
136  //Approximation/Integration order
137  int approximation_order; //what order polynomial (hierarchic is 2nd order)
138  int integration_order; //determines number of integration points
141  double total_error;
142  double errRho_max;
144 
145  //Mesh Reconstruction
153 
154  private:
155  apf::Mesh2* m;
156  int comm_size, comm_rank;
157 
158  //double rho[2];
159  //nu[2];
160  double* rho;
161  double* nu;
162 
163  double g[3];
164  double delta_T;
165  double delta_T_next;
166  double T_current; //for error trigger
167  double T_reference; //for error trigger
168 
169  apf::MeshTag* diffFlux;
170  apf::GlobalNumbering* global[4];
171  apf::Numbering* local[4];
172  apf::Field* err_reg; //error field from ERM
173  apf::Field* vmsErrH1; //error field for VMS
174  apf::Field* errRho_reg; //error-density field from ERM
175  apf::Field* errRel_reg; //relative error field from ERM
176  apf::Field* error_reference;
177 
178  /* this field stores isotropic size */
179  apf::Field* size_iso;
180  /* these fields store anisotropic size and metric tensor */
181  apf::Field* size_scale;
182  apf::Field* size_frame;
183 
184  //queue for size fields
185  std::queue<apf::Field*> sizeFieldList;
186  void isotropicIntersect();
187 
188  int constructGlobalNumbering(Mesh& mesh);
189  int constructGlobalStructures(Mesh& mesh);
190 
191  int constructElements(Mesh& mesh);
192  int constructNodes(Mesh& mesh);
193  int constructBoundaries(Mesh& mesh);
194  int constructEdges(Mesh& mesh);
195  int constructMaterialArrays(Mesh& mesh);
196 
197  void freeField(apf::Field*& f);
198  void freeNumbering(apf::Numbering*& n);
199 
200  static void averageToEntity(apf::Field* ef, apf::Field* vf,
201  apf::MeshEntity* ent);
202  void volumeAverageToEntity(apf::Field* ef, apf::Field* vf,
203  apf::MeshEntity* ent);
204  static void minToEntity(apf::Field* ef, apf::Field* vf,
205  apf::MeshEntity* ent);
206 
207  bool has_gBC; //boolean for having global boundary conditions
208  double target_error; //computed from get_local_error()
209  int target_element_count; //How many elements in the mesh are desired?
210  double domainVolume; //Volume of the domain
211  double THRESHOLD; //threshold of error before adapt
212 };
213 
214 
MeshAdaptPUMIDrvr::~MeshAdaptPUMIDrvr
~MeshAdaptPUMIDrvr()
Definition: cMeshAdaptPUMI.cpp:89
MeshAdaptPUMIDrvr::modelVertexMaterial
int * modelVertexMaterial
Definition: MeshAdaptPUMI.h:148
MeshAdaptPUMIDrvr::hasERM
bool hasERM
Definition: MeshAdaptPUMI.h:105
MeshAdaptPUMIDrvr::updateMaterialArrays
int updateMaterialArrays(Mesh &mesh, int dim, int bdryID, int GeomTag)
Definition: MeshConverter.cpp:400
MeshAdaptPUMIDrvr::constructFromSerialPUMIMesh
int constructFromSerialPUMIMesh(Mesh &mesh)
Definition: MeshConverter.cpp:47
MeshAdaptPUMIDrvr::hPhi
double hPhi
Definition: MeshAdaptPUMI.h:91
MeshAdaptPUMIDrvr::hmin
double hmin
Definition: MeshAdaptPUMI.h:91
MeshAdaptPUMIDrvr::numberLocally
void numberLocally()
Definition: MeshConverter.cpp:95
MeshAdaptPUMIDrvr::total_error
double total_error
Definition: MeshAdaptPUMI.h:141
MeshAdaptPUMIDrvr::MeshAdaptPUMIDrvr
MeshAdaptPUMIDrvr()
Definition: cMeshAdaptPUMI.cpp:41
MeshAdaptPUMIDrvr::updateSphereCoordinates
void updateSphereCoordinates(double *sphereCenter)
Definition: createAnalyticGeometry.cpp:690
MeshAdaptPUMIDrvr::predictiveInterfacePropagation
void predictiveInterfacePropagation()
Definition: SizeField.cpp:297
MeshAdaptPUMIDrvr::meshBoundary2Model
int * meshBoundary2Model
Definition: MeshAdaptPUMI.h:47
MeshAdaptPUMIDrvr::setSphereSizeField
int setSphereSizeField()
Definition: SizeField.cpp:61
MeshAdaptPUMIDrvr::get_local_error
void get_local_error(double &total_error)
This function aims to compute error at each element via an Element Residual Method.
Definition: ErrorResidualMethod.cpp:664
MeshAdaptPUMIDrvr::nsd
int nsd
Definition: MeshAdaptPUMI.h:96
MeshAdaptPUMIDrvr::willErrorAdapt_reference
int willErrorAdapt_reference()
Definition: cMeshAdaptPUMI.cpp:416
MeshAdaptPUMIDrvr::getSimmetrixBC
int getSimmetrixBC()
Function used to read in diffusive flux BC from Simmetrix Model.
Definition: cMeshAdaptPUMI.cpp:181
MeshAdaptPUMIDrvr::transferFieldToPUMI
int transferFieldToPUMI(const char *name, double const *inArray, int nVar, int nN)
Convert Proteus fields to something PUMI can understand.
Definition: MeshFields.cpp:40
Mesh
Definition: mesh.h:28
MeshAdaptPUMIDrvr::hmax
double hmax
Definition: MeshAdaptPUMI.h:91
f
Double f
Definition: Headers.h:64
MeshAdaptPUMIDrvr::calculateAnisoSizeField
int calculateAnisoSizeField()
Definition: SizeField.cpp:1055
MeshAdaptPUMIDrvr::initialReconstructed
int initialReconstructed
Definition: MeshAdaptPUMI.h:147
MeshAdaptPUMIDrvr
Class that handles the interface between SCOREC tools and Proteus.
Definition: MeshAdaptPUMI.h:19
MeshAdaptPUMIDrvr::localNumber
int localNumber(apf::MeshEntity *e)
Definition: MeshConverter.cpp:105
MeshAdaptPUMIDrvr::hasIBM
bool hasIBM
Definition: MeshAdaptPUMI.h:102
MeshAdaptPUMIDrvr::hasAniso
bool hasAniso
Definition: MeshAdaptPUMI.h:106
MeshAdaptPUMIDrvr::dumpMesh
int dumpMesh(Mesh &mesh)
Definition: ParallelMeshConverter.cpp:242
MeshAdaptPUMIDrvr::getMPvalue
double getMPvalue(double field_val, double val_0, double val_1)
Function primarily used to get the VOF-weighted average of physical properties at a given point.
Definition: ErrorResidualMethod.cpp:35
MeshAdaptPUMIDrvr::getERMSizeField
int getERMSizeField(double err_total)
Definition: SizeField.cpp:1195
MeshAdaptPUMIDrvr::hasAnalyticSphere
bool hasAnalyticSphere
Definition: MeshAdaptPUMI.h:107
n
Int n
Definition: Headers.h:28
MeshAdaptPUMIDrvr::createSphereInBox
gmi_model * createSphereInBox(double *boxDim, double *sphereCenter, double radius)
Definition: createAnalyticGeometry.cpp:602
MeshAdaptPUMIDrvr::getMinimumQuality
double getMinimumQuality()
Function used to get the worst element quality in the mesh.
Definition: cMeshAdaptPUMI.cpp:855
MeshAdaptPUMIDrvr::modelBoundaryMaterial
int * modelBoundaryMaterial
Definition: MeshAdaptPUMI.h:149
MeshAdaptPUMIDrvr::writeMesh
void writeMesh(const char *meshFile)
Definition: cMeshAdaptPUMI.cpp:912
MeshAdaptPUMIDrvr::hasVMS
bool hasVMS
Definition: MeshAdaptPUMI.h:104
MeshAdaptPUMIDrvr::getViscosityField
apf::Field * getViscosityField(apf::Field *voff)
Function used to derive a viscosity field from a VOF field.
Definition: ErrorResidualMethod.cpp:579
MeshAdaptPUMIDrvr::maxAspect
int maxAspect
Definition: MeshAdaptPUMI.h:97
MeshAdaptPUMIDrvr::getTotalMass
double getTotalMass()
Function to track total mass of the domain.
Definition: cMeshAdaptPUMI.cpp:874
MeshAdaptPUMIDrvr::rel_err_total
double rel_err_total
Definition: MeshAdaptPUMI.h:143
MeshAdaptPUMIDrvr::nEstimate
int nEstimate
Definition: MeshAdaptPUMI.h:95
MeshAdaptPUMIDrvr::N_interface_band
double N_interface_band
Definition: MeshAdaptPUMI.h:100
MeshAdaptPUMIDrvr::exteriorGlobaltoLocalElementBoundariesArray
int * exteriorGlobaltoLocalElementBoundariesArray
Definition: MeshAdaptPUMI.h:134
MeshAdaptPUMIDrvr::set_nAdapt
void set_nAdapt(int numberAdapt)
Definition: cMeshAdaptPUMI.cpp:994
MeshAdaptPUMIDrvr::loadModelAndMesh
int loadModelAndMesh(const char *modelFile, const char *meshFile)
Load the mesh and model for SCOREC libraries.
Definition: cMeshAdaptPUMI.cpp:136
MeshAdaptPUMIDrvr::transferModelInfo
int transferModelInfo(int *numGeomEntities, int *edges, int *faces, int *mVertex2Model, int *mEdgeVertex2Model, int *mBoundary2Model, int nMaxSegments)
Definition: MeshConverter.cpp:855
MeshAdaptPUMIDrvr::gradingFactor
double gradingFactor
Definition: MeshAdaptPUMI.h:101
MeshAdaptPUMIDrvr::loadMeshForAnalytic
int loadMeshForAnalytic(const char *meshFile, double *boxDim, double *sphereCenter, double radius)
Definition: cMeshAdaptPUMI.cpp:158
MeshAdaptPUMIDrvr::nTriggers
int nTriggers
Definition: MeshAdaptPUMI.h:94
MeshAdaptPUMIDrvr::integration_order
int integration_order
Definition: MeshAdaptPUMI.h:138
MeshAdaptPUMIDrvr::adaptPUMIMesh
int adaptPUMIMesh(const char *input)
Function used to trigger adaptation.
Definition: cMeshAdaptPUMI.cpp:670
MeshAdaptPUMIDrvr::constructFromParallelPUMIMesh
int constructFromParallelPUMIMesh(Mesh &mesh, Mesh &subdomain_mesh)
Definition: ParallelMeshConverter.cpp:25
MeshAdaptPUMIDrvr::approximation_order
int approximation_order
Definition: MeshAdaptPUMI.h:137
MeshAdaptPUMIDrvr::edgeList
int * edgeList
Definition: MeshAdaptPUMI.h:45
MeshAdaptPUMIDrvr::useProteusAniso
bool useProteusAniso
Definition: MeshAdaptPUMI.h:109
MeshAdaptPUMIDrvr::modelFileName
char * modelFileName
Definition: MeshAdaptPUMI.h:124
MeshAdaptPUMIDrvr::willErrorAdapt
int willErrorAdapt()
Looks at the estimated error and determines if mesh adaptation is necessary.
Definition: cMeshAdaptPUMI.cpp:317
MeshAdaptPUMIDrvr::transferFieldToProteus
int transferFieldToProteus(const char *name, double *outArray, int nVar, int nN)
Convert PUMI fields to something Proteus can understand.
Definition: MeshFields.cpp:86
MeshAdaptPUMIDrvr::computeDiffusiveFlux
void computeDiffusiveFlux(apf::Mesh *m, apf::Field *voff, apf::Field *visc, apf::Field *pref, apf::Field *velf)
Function used to compute the diffusive flux at interelement boundaries and stores the values as tags ...
Definition: ErrorResidualMethod.cpp:297
MeshAdaptPUMIDrvr::hasInterface
bool hasInterface
Definition: MeshAdaptPUMI.h:103
MeshAdaptPUMIDrvr::errRho_max
double errRho_max
Definition: MeshAdaptPUMI.h:142
mesh.h
MeshAdaptPUMIDrvr::numIter
int numIter
Definition: MeshAdaptPUMI.h:92
MeshAdaptPUMIDrvr::faceList
int * faceList
Definition: MeshAdaptPUMI.h:46
MeshAdaptPUMIDrvr::size_field_config
std::string size_field_config
Definition: MeshAdaptPUMI.h:114
MeshAdaptPUMIDrvr::numModelEntities
int numModelEntities[4]
Definition: MeshAdaptPUMI.h:48
MeshAdaptPUMIDrvr::willInterfaceAdapt
int willInterfaceAdapt()
Definition: cMeshAdaptPUMI.cpp:612
MeshAdaptPUMIDrvr::transferPropertiesToPUMI
int transferPropertiesToPUMI(double *rho_p, double *nu_p, double *g_p, double deltaT, double deltaT_next, double T_simulation, double interfaceBandSize)
Transfer material properties to the MeshAdaptPUMI class.
Definition: MeshFields.cpp:119
MeshAdaptPUMIDrvr::meshEdge2Model
int * meshEdge2Model
Definition: MeshAdaptPUMI.h:47
MeshAdaptPUMIDrvr::BCtag
apf::MeshTag * BCtag
Definition: MeshAdaptPUMI.h:130
MeshAdaptPUMIDrvr::numModelOffsets
int numModelOffsets[4]
Definition: MeshAdaptPUMI.h:151
MeshAdaptPUMIDrvr::useProteus
bool useProteus
Definition: MeshAdaptPUMI.h:108
MeshAdaptPUMIDrvr::get_VMS_error
void get_VMS_error(double &total_error_out)
Definition: VMS.cpp:70
MeshAdaptPUMIDrvr::DBCtag
apf::MeshTag * DBCtag[4]
Definition: MeshAdaptPUMI.h:131
MeshAdaptPUMIDrvr::numAdaptSteps
int numAdaptSteps
Definition: MeshAdaptPUMI.h:99
MeshAdaptPUMIDrvr::setAdaptProperties
int setAdaptProperties(std::vector< std::string > sizeInputs, bool in_adapt, double in_hmax, double in_hmin, double in_hphi, int in_numAdaptSteps, double in_targetError, double in_gradingFactor, bool in_logging, int in_numIterations)
Definition: cMeshAdaptPUMI.cpp:1000
MeshAdaptPUMIDrvr::adaptMesh
int adaptMesh
Definition: MeshAdaptPUMI.h:98
MeshAdaptPUMIDrvr::calculateSizeField
int calculateSizeField(double L_band)
Definition: SizeField.cpp:84
MeshAdaptPUMIDrvr::nAdapt
int nAdapt
Definition: MeshAdaptPUMI.h:93
MeshAdaptPUMIDrvr::willAdapt
int willAdapt()
Definition: cMeshAdaptPUMI.cpp:582
MeshAdaptPUMIDrvr::updateMaterialArrays2
int updateMaterialArrays2(Mesh &mesh)
Definition: MeshConverter.cpp:509
MeshAdaptPUMIDrvr::fluxtag
apf::MeshTag * fluxtag[4]
Definition: MeshAdaptPUMI.h:132
MeshAdaptPUMIDrvr::cleanMesh
void cleanMesh()
Definition: cMeshAdaptPUMI.cpp:920
MeshAdaptPUMIDrvr::isReconstructed
int isReconstructed
Definition: MeshAdaptPUMI.h:146
MeshAdaptPUMIDrvr::logging_config
std::string logging_config
Definition: MeshAdaptPUMI.h:116
MeshAdaptPUMIDrvr::transferElementFieldToProteus
int transferElementFieldToProteus(const char *name, double *outArray, int nVar, int nN)
Convert PUMI fields to something Proteus can understand.
Definition: MeshFields.cpp:158
MeshAdaptPUMIDrvr::testIsotropicSizeField
int testIsotropicSizeField()
Definition: SizeField.cpp:1497
MeshAdaptPUMIDrvr::num_quadrature
int num_quadrature
Definition: MeshAdaptPUMI.h:139
MeshAdaptPUMIDrvr::numModelTotals
int numModelTotals[4]
Definition: MeshAdaptPUMI.h:152
MeshAdaptPUMIDrvr::num_quadrature_boundary
int num_quadrature_boundary
Definition: MeshAdaptPUMI.h:140
MeshAdaptPUMIDrvr::getBoundaryFlux
void getBoundaryFlux(apf::Mesh *m, apf::MeshEntity *ent, double *endflux)
This function reads in the stored tags and computes the boundary flux according to the RHS formulatio...
Definition: ErrorResidualMethod.cpp:494
MeshAdaptPUMIDrvr::adapt_type_config
std::string adapt_type_config
Definition: MeshAdaptPUMI.h:115
MeshAdaptPUMIDrvr::meshVertex2Model
int * meshVertex2Model
Definition: MeshAdaptPUMI.h:47
MeshAdaptPUMIDrvr::reconstructFromProteus
int reconstructFromProteus(Mesh &mesh, Mesh &globalMesh, int hasModel)
Definition: MeshConverter.cpp:872
MeshAdaptPUMIDrvr::modelRegionMaterial
int * modelRegionMaterial
Definition: MeshAdaptPUMI.h:150
MeshAdaptPUMIDrvr::numSegments
int numSegments
Definition: MeshAdaptPUMI.h:44
MeshAdaptPUMIDrvr::gradeMesh
int gradeMesh(double gradationFactor)
Definition: SizeField.cpp:1660
MeshAdaptPUMIDrvr::reconstructFromProteus2
int reconstructFromProteus2(Mesh &mesh, int *isModelVert, int *bFaces)
Definition: MeshConverter.cpp:1334
PyEmbeddedFunctions.h
MeshAdaptPUMIDrvr::removeBCData
void removeBCData()
Function used to remove the BC tags that were created during the computeDiffusiveFlux() function.
Definition: ErrorResidualMethod.cpp:626