-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSIMExplPhaseField.C
92 lines (73 loc) · 2.08 KB
/
SIMExplPhaseField.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// $Id$
//==============================================================================
//!
//! \file SIMExplPhaseField.C
//!
//! \date May 27 2016
//!
//! \author Knut Morten Okstad / SINTEF
//!
//! \brief Solution driver representing an explicit phase-field.
//!
//==============================================================================
#include "SIMExplPhaseField.h"
#include "SIMoutput.h"
#include "TimeStep.h"
#include "DataExporter.h"
#include "Functions.h"
#include "Utilities.h"
#include "IFEM.h"
#include "tinyxml2.h"
SIMExplPhaseField::SIMExplPhaseField (SIMoutput* gridOwner)
{
myHeading = "Explicit phase field";
myOwner = gridOwner;
phaseFunc = nullptr;
myStep = 0;
}
SIMExplPhaseField::~SIMExplPhaseField ()
{
delete phaseFunc;
}
void SIMExplPhaseField::registerFields (DataExporter& exporter)
{
exporter.registerField("c","phase field",DataExporter::SIM,
DataExporter::PRIMARY);
exporter.setFieldValue("c",this,&phaseField);
}
bool SIMExplPhaseField::init (const TimeStep&)
{
this->registerField("phasefield",phaseField);
return true;
}
bool SIMExplPhaseField::parse (const tinyxml2::XMLElement* elem)
{
const char* value = utl::getValue(elem,"phasefield");
if (!value)
return this->SIMbase::parse(elem);
std::string type;
utl::getAttribute(elem,"type",type);
IFEM::cout <<"\tPhase-field function";
phaseFunc = utl::parseRealFunc(value,type);
IFEM::cout << std::endl;
return true;
}
bool SIMExplPhaseField::solveStep (TimeStep& tp, bool)
{
if (!phaseFunc)
{
std::cerr <<" *** SIMExplPhaseField::solveStep: No phase field function."
<< std::endl;
return false;
}
phaseField.resize(myOwner->getNoNodes(1));
return myOwner->project(phaseField,phaseFunc,1,0,1,
SIMoptions::GLOBAL,tp.time.t);
}
bool SIMExplPhaseField::saveStep (const TimeStep& tp, int& nBlock)
{
if (tp.step%opt.saveInc == 0 && opt.format >= 0)
if (myOwner->writeGlvS1(phaseField,++myStep,nBlock,tp.time.t,
"phase",6,1,true) < 0) return false;
return true;
}