proteus 1.9.0
C/C++/Fortran libraries
Loading...
Searching...
No Matches
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>
7// SCOREC/core >= 3.0.0 replaced PCU's global-state API with an explicit
8// pcu::PCU object; every PCU_* free function now takes a PCU_t handle as
9// its first argument, obtained from a live pcu::PCU via GetCHandle(). See
10// pcu/PCU.h (the pcu::PCU class) and pcu/PCU_C.h (the C shim that keeps
11// the existing PCU_* call sites below working with a threaded handle,
12// rather than rewriting them to the pcu::PCU member-function API).
13#include <PCU.h>
14#include <PCU_C.h>
15
22
26
28
29 public:
32
33 int loadModelAndMesh(const char* modelFile, const char* meshFile); //load the model and mesh
34 int loadMeshForAnalytic(const char* meshFile,double* boxDim, double* sphereCenter, double radius); //mesh and construct analytic geometry
35 void writeMesh(const char* meshFile);
36 void cleanMesh();
37
38 //Functions to construct proteus mesh data structures
39 int reconstructFromProteus(Mesh& mesh, Mesh& globalMesh,int hasModel);
40 int reconstructFromProteus2(Mesh& mesh, int* isModelVert, int* bFaces);
42 int constructFromParallelPUMIMesh(Mesh& mesh, Mesh& subdomain_mesh);
43 int updateMaterialArrays(Mesh& mesh,int dim, int bdryID, int GeomTag);
44 int updateMaterialArrays(Mesh& mesh);
45 int updateMaterialArrays2(Mesh& mesh);
46 void numberLocally();
47 int localNumber(apf::MeshEntity* e);
48 int dumpMesh(Mesh& mesh);
49
50 //Functions used to transfer proteus model data structures
51 int transferModelInfo(int*numGeomEntities,int*edges,int*faces,int*mVertex2Model,int*mEdgeVertex2Model,int*mBoundary2Model,int nMaxSegments);
57
58 //Functions used to transfer information between PUMI and proteus
59 int transferFieldToPUMI(const char* name, double const* inArray, int nVar, int nN);
60 int transferFieldToProteus(const char* name, double* outArray, int nVar, int nN);
61 int transferElementFieldToProteus(const char* name, double* outArray, int nVar, int nN);
62 int transferPropertiesToPUMI(double* rho_p, double* nu_p,double* g_p, double deltaT, double deltaT_next,double T_simulation,double interfaceBandSize);
63 //int setAdaptProperties(std::vector<std::string> sizeInputs,double hmax);
64 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);
65 //int transferBCtagsToProteus(int* tagArray, int idx, int* ebN, int* eN_global, double* fluxBC);
66 //int transferBCsToProteus();
67
68 //MeshAdapt functions
69 int willAdapt();
70 int willErrorAdapt();
73 int adaptPUMIMesh(const char* input);
75 int calculateSizeField(double L_band);
77
80 int getERMSizeField(double err_total);
81 int gradeMesh(double gradationFactor);
82
83 //analytic geometry
84 gmi_model* createSphereInBox(double* boxDim, double*sphereCenter,double radius);
85 void updateSphereCoordinates(double*sphereCenter);
86
87 //Quality Check Functions
88 double getMinimumQuality();
89 double getTotalMass();
90
91 //Functions that help facilitate computations
92 double getMPvalue(double field_val,double val_0, double val_1); //get the multiphase value of physical properties
93 apf::Field* getViscosityField(apf::Field* voff); //derive a field of viscosity based on VOF field
94
95 //needed for checkpointing/restart
96 void set_nAdapt(int numberAdapt);
97
98 //Public Variables
99 double hmax, hmin, hPhi; //bounds on mesh size
100 int numIter; //number of iterations for MeshAdapt
101 int nAdapt; //counter for number of adapt steps
102 int nTriggers; //counter for number of triggers
103 int nEstimate; //counter for number of error estimator calls
104 int nsd; //number of spatial dimensions
105 int maxAspect; //maximum aspect ratio
106 int adaptMesh; //is adaptivity turned on?
107 int numAdaptSteps; //Number adaptivity
108 double N_interface_band; //number of elements in half-band around interface
110 bool hasIBM;
112 bool hasVMS;
113 bool hasERM;
118
119
120
121 //User Inputs
122 std::string size_field_config; //What type of size field: interface, ERM, isotropic
123 std::string adapt_type_config; //What type of adapt for ERM: isotropic or anisotropic
124 std::string logging_config; // Logging on or off
125
126 //Element Residual Method
127 void get_local_error(double& total_error);
128 void computeDiffusiveFlux(apf::Mesh*m,apf::Field* voff, apf::Field* visc,apf::Field* pref, apf::Field* velf);
129 void getBoundaryFlux(apf::Mesh* m, apf::MeshEntity* ent, double * endflux);
130 int getSimmetrixBC();
131 void removeBCData();
133
134 //VMS
135 void get_VMS_error(double& total_error_out);
136
137 //tags used to identify types of BC
138 apf::MeshTag* BCtag;
139 apf::MeshTag* DBCtag[4];
140 apf::MeshTag* fluxtag[4];
141
143
144 //Approximation/Integration order
145 int approximation_order; //what order polynomial (hierarchic is 2nd order)
146 int integration_order; //determines number of integration points
152
153 //Mesh Reconstruction
161
162 private:
163 apf::Mesh2* m;
164 int comm_size, comm_rank;
165
166 // Owns the process's PCU state for the lifetime of this driver (SCOREC/core
167 // >= 3.0.0). Constructed from the pre-existing MPI_COMM_WORLD -- proteus's
168 // Python layer (mpi4py) already calls MPI_Init before this driver is ever
169 // constructed, so this wraps that communicator rather than calling
170 // pcu::Init(), which would attempt its own MPI bring-up. Must be a real
171 // member (not a local temporary): PCUObj below is a raw handle wrapping a
172 // pointer to pcuObj_, so pcuObj_ must outlive every PCU_* call.
173 pcu::PCU pcuObj_;
174 // Opaque C handle threaded as the first argument through every PCU_* call
175 // site below (pcu/PCU_C.h). Set once in the constructor via
176 // pcuObj_.GetCHandle().
177 PCU_t PCUObj;
178
179 //double rho[2];
180 //nu[2];
181 double* rho;
182 double* nu;
183
184 double g[3];
185 double delta_T;
186 double delta_T_next;
187 double T_current; //for error trigger
188 double T_reference; //for error trigger
189
190 apf::MeshTag* diffFlux;
191 apf::GlobalNumbering* global[4];
192 apf::Numbering* local[4];
193 apf::Field* err_reg; //error field from ERM
194 apf::Field* vmsErrH1; //error field for VMS
195 apf::Field* errRho_reg; //error-density field from ERM
196 apf::Field* errRel_reg; //relative error field from ERM
197 apf::Field* error_reference;
198
199 /* this field stores isotropic size */
200 apf::Field* size_iso;
201 /* these fields store anisotropic size and metric tensor */
202 apf::Field* size_scale;
203 apf::Field* size_frame;
204
205 //queue for size fields
206 std::queue<apf::Field*> sizeFieldList;
207 void isotropicIntersect();
208
209 int constructGlobalNumbering(Mesh& mesh);
210 int constructGlobalStructures(Mesh& mesh);
211
212 int constructElements(Mesh& mesh);
213 int constructNodes(Mesh& mesh);
214 int constructBoundaries(Mesh& mesh);
215 int constructEdges(Mesh& mesh);
216 int constructMaterialArrays(Mesh& mesh);
217
218 void freeField(apf::Field*& f);
219 void freeNumbering(apf::Numbering*& n);
220
221 static void averageToEntity(apf::Field* ef, apf::Field* vf,
222 apf::MeshEntity* ent);
223 void volumeAverageToEntity(apf::Field* ef, apf::Field* vf,
224 apf::MeshEntity* ent);
225 static void minToEntity(apf::Field* ef, apf::Field* vf,
226 apf::MeshEntity* ent);
227
228 bool has_gBC; //boolean for having global boundary conditions
229 double target_error; //computed from get_local_error()
230 int target_element_count; //How many elements in the mesh are desired?
231 double domainVolume; //Volume of the domain
232 double THRESHOLD; //threshold of error before adapt
233};
234
235
Int n
Definition Headers.h:28
Double f
Definition Headers.h:64
int updateMaterialArrays(Mesh &mesh, int dim, int bdryID, int GeomTag)
int loadMeshForAnalytic(const char *meshFile, double *boxDim, double *sphereCenter, double radius)
std::string size_field_config
int reconstructFromProteus(Mesh &mesh, Mesh &globalMesh, int hasModel)
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)
void removeBCData()
Function used to remove the BC tags that were created during the computeDiffusiveFlux() function.
int reconstructFromProteus2(Mesh &mesh, int *isModelVert, int *bFaces)
double getMinimumQuality()
Function used to get the worst element quality in the mesh.
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 ...
int transferFieldToProteus(const char *name, double *outArray, int nVar, int nN)
Convert PUMI fields to something Proteus can understand.
int loadModelAndMesh(const char *modelFile, const char *meshFile)
Load the mesh and model for SCOREC libraries.
int transferModelInfo(int *numGeomEntities, int *edges, int *faces, int *mVertex2Model, int *mEdgeVertex2Model, int *mBoundary2Model, int nMaxSegments)
int transferElementFieldToProteus(const char *name, double *outArray, int nVar, int nN)
Convert PUMI fields to something Proteus can understand.
int updateMaterialArrays2(Mesh &mesh)
int * exteriorGlobaltoLocalElementBoundariesArray
int getERMSizeField(double err_total)
int localNumber(apf::MeshEntity *e)
int gradeMesh(double gradationFactor)
int constructFromParallelPUMIMesh(Mesh &mesh, Mesh &subdomain_mesh)
int willErrorAdapt()
Looks at the estimated error and determines if mesh adaptation is necessary.
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.
int calculateAnisoSizeField()
apf::Field * getViscosityField(apf::Field *voff)
Function used to derive a viscosity field from a VOF field.
void predictiveInterfacePropagation()
void get_VMS_error(double &total_error_out)
Definition VMS.cpp:70
void writeMesh(const char *meshFile)
std::string logging_config
int calculateSizeField(double L_band)
Definition SizeField.cpp:84
int adaptPUMIMesh(const char *input)
Function used to trigger adaptation.
int constructFromSerialPUMIMesh(Mesh &mesh)
void set_nAdapt(int numberAdapt)
int transferFieldToPUMI(const char *name, double const *inArray, int nVar, int nN)
Convert Proteus fields to something PUMI can understand.
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...
apf::MeshTag * DBCtag[4]
double getTotalMass()
Function to track total mass of the domain.
gmi_model * createSphereInBox(double *boxDim, double *sphereCenter, double radius)
apf::MeshTag * fluxtag[4]
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.
void get_local_error(double &total_error)
This function aims to compute error at each element via an Element Residual Method.
std::string adapt_type_config
void updateSphereCoordinates(double *sphereCenter)
apf::MeshTag * BCtag
int getSimmetrixBC()
Function used to read in diffusive flux BC from Simmetrix Model.
Definition mesh.h:30