User-defined Plugin: Pure Solidification
user_pfm_pure_solidification.h
Go to the documentation of this file.
1
10// //
11// P A N P H A S E F I E L D //
12// //
13// Version 2020 //
14// CompuTherm, LLC //
15// Copyright, 2000-2020 //
16// //
17// www.computherm.com //
18// //
20
21#pragma once
22
24#include "ppf_APP_interface.h"
25
26// The following ifdef block is the standard way of creating macros which make exporting
27// from a DLL simpler. All files within this DLL are compiled with the USER_PFM_PURE_SOLIDIFICATION_EXPORTS
28// symbol defined on the command line. This symbol should not be defined on any project
29// that uses this DLL. This way any other project whose source files include this file see
30// USER_PFM_PURE_SOLIDIFICATION_API functions as being imported from a DLL, whereas this DLL sees symbols
31// defined with this macro as being exported.
32#ifdef __GNUC__
33#define USER_PFM_PURE_SOLIDIFICATION_API
34#else
35#define USER_PFM_PURE_SOLIDIFICATION_API __declspec(dllexport)
36#endif // __GNUC__
37
38using namespace std;
39
40#ifndef EXTEND_PFM_SDK_OUTPUT
41#define EXTEND_PFM_SDK_OUTPUT
42#endif // EXTEND_PFM_SDK_OUTPUT
43
106class user_pfm_solidification : public I_PFM_APP_Interface
107{
108
109public:
115
121
122public:
133 void load_arguments(PF_ARGS* m_args, char* msg_char);
134
142 void run_pfm_calculation(char *msg);
143
144public:
154 bool sdk_update_prop(string &msg, int ip);
155
162
169 void sdk_get_chemical_mobility(double(*chemical_mobility)[PDN_BSZ][PDN_BSZ], double(*atomic_mobility), double(*composition));
170
171public:
179
189 bool model_initial_condition(string input_path, string irun="circle");
190
198
199
200
208
218 void model_update_laplace_operation(VectorMesh<double>& field, VectorMesh<double>& lap_field, int index);
219
227 void model_update_rate(int index);
228
237 bool model_update_field(double dt);
238
239private:
240 // ------------------------ //
241 // PanPhaseField SDK object //
242 // ------------------------ //
243 PFM_SDK* m_pfm_sdk;
244 PFM_SDK_Variables svar; // For storing the SDK variables.
245 double Random_parameter; // Random parameter to demonstrate dynamic parameters.
246
247 // -------------------------------------------//
248 // Model parameters loaded from PanPhaseField //
249 // ------------------------------------------ //
250 string calc_name;
252 int num_thread;
254 map<string, double> homogen_condition;
256 int L;
257 int M;
258 int N;
259 vector<int> dim_order_map;
261 TempCalculator m_thermal_stack;
262 double duration;
264 vector<double> plot_time_stack;
265 size_t N_profiles;
267 string imode;
268 string input_vtk_path;
270 double Cijkla, Cijklb, Cijklc;
272 double Gnormal;
273 double Bnormal;
275 double Namp;
276 double lo;
277 double kappa_l;
278 double molar_vol;
280 double tao;
282 double Meta;
283 double sigma_dimensional;
284 double Width_dimensional;
286 double kappa_eta;
287 double omega_eta;
289 vector<string> comp_names;
290 string ref_comp;
291 size_t ncomp;
293 vector<string> phase_names;
294 size_t nphase;
297 // ------------------- //
298 // Model selection tag //
299 // ------------------- //
300 bool cutoff_eta;
301
302 // --------------------------------------------------- //
303 // VTK I/O related varialbes loaded from PanPhaseField //
304 // --------------------------------------------------- //
305 string VTK_dir;
306 vtk_stream_utility::VTK_Stream vtk_stream;
308 // ------------------------------------------------ //
309 // PanPhaseField SDK related input/output variables //
310 // ------------------------------------------------ //
311 vector<PFM_SDK_Input_Condition> sdk_input;
312 vector<PFM_SDK_Output_Data> sdk_output;
314 // --------------------- //
315 // phase-field mesh grid //
316 // --------------------- //
317 VectorMesh<double> conc;
318 VectorMesh<double> detadt;
319 VectorMesh<double> lap_eta;
320 VectorMesh<double> dfdeta;
321 VectorMesh<double> etar;
322 int matrix_index;
323 double dG_max;
324 vector<double> Gibbs_energy_shift; // J/mol; Shifting the Gibbs energy of each precipitate
325
326 // --------------------- //
327 // time-integral related //
328 // --------------------- //
329 double TK_cur;
330 double dt;
331 double tt;
332 bool was_dt_limited;
333 double dt_before_limited;
334 int iter_step_cnt;
336#ifdef ENABLE_PANDAT_PROGRESS_MESSAGE
337 // --------------------------------------------- //
338 // (Optional) Pandat GUI progress window message //
339 // --------------------------------------------- //
340 CALCULATION_PROGRESS m_progress_ptr;
341#endif
342
343#ifdef ENABLE_PANDAT_RESULT_TABLE
344 // ------------------------------------------------------------------------------ //
345 // (Optional) Pandat Result Table I/O related varialbes loaded from PanPhaseField //
346 // ------------------------------------------------------------------------------ //
347 vector<pair<string, string>> dbs;
348 int ppf_calc_id;
349 string pandat_table_dir;
350 map<string, double> custom_property;
351
352 // ------------------------------ //
353 // (Optional) Pandat Result Table //
354 // ------------------------------ //
355 P_Result_Dict m_result;
356#endif
357
358#ifdef ENABLE_PERFORMANCE_LOG
359 // -------------------------- //
360 // (Optional) Performance log //
361 // -------------------------- //
362 vector<double> sdk_api_call_cnt;
363 double thermodynamic_time;
364#endif
365
366
367
368};//end of user_pfm_solidification
369
370
390class SOLIDIFICATION_app_Creator : public I_PFM_APP_Creator
391{
392public:
393
397 I_PFM_APP_Interface * Create()
398 {
399 return new user_pfm_solidification();
400 }
401
406 void Delete(I_PFM_APP_Interface* user_app) {
407 if (user_app != NULL)
408 {
409 delete user_app;
410 }
411 }
412
417 {
418 return 1.0;
419 }
420
424 const char* getName()
425 {
426 return "USER_PFM_PURE_SOLIDIFICATION";
427 }
428
429
433 const char* getDescription()
434 {
435 return "A template plugin for solidification simulation";
436 }
437};
Creator of this user-defined solidification model.
Definition: user_pfm_pure_solidification.h:391
void Delete(I_PFM_APP_Interface *user_app)
Definition: user_pfm_pure_solidification.h:406
const char * getDescription()
Definition: user_pfm_pure_solidification.h:433
float getVersion()
Definition: user_pfm_pure_solidification.h:416
I_PFM_APP_Interface * Create()
Definition: user_pfm_pure_solidification.h:397
const char * getName()
Definition: user_pfm_pure_solidification.h:424
An example phase-field model of solidification.
Definition: user_pfm_pure_solidification.h:107
bool model_update_field(double dt)
Definition: pfm_solidification_model.cpp:467
void sdk_get_chemical_mobility(double(*chemical_mobility)[PDN_BSZ][PDN_BSZ], double(*atomic_mobility), double(*composition))
Definition: pfm_solidification_property.cpp:44
~user_pfm_solidification()
Definition: pfm_solidification.cpp:410
void model_update_rate(int index)
Definition: pfm_solidification_model.cpp:450
void model_allocate_memory()
Definition: pfm_solidification_model.cpp:12
user_pfm_solidification()
Definition: pfm_solidification.cpp:392
bool sdk_update_prop(string &msg, int ip)
Definition: pfm_solidification_property.cpp:59
void model_update_laplace_operation(VectorMesh< double > &field, VectorMesh< double > &lap_field, int index)
Definition: pfm_solidification_model.cpp:415
void update_phase_equilibrium()
Definition: pfm_solidification_model.cpp:196
void load_arguments(PF_ARGS *m_args, char *msg_char)
Definition: pfm_solidification.cpp:148
bool model_initial_condition(string input_path, string irun="circle")
Definition: pfm_solidification_model.cpp:38
double model_get_driving_force()
Definition: pfm_solidification_model.cpp:376
bool model_update_PFDB_parameters()
This method updates the dynamic parameters of the plugin which can evolve with time.
Definition: pfm_solidification_model.cpp:492
void run_pfm_calculation(char *msg)
Definition: pfm_solidification_calculation.cpp:5
Configuration of user-defined plugin: pure solidification.
#define PDN_BSZ
Definition: pfm_solidification_config.h:65