Memosa-FVM  0.2
FractureModel< T >::Impl Class Reference

#include <FractureModel_impl.h>

Collaboration diagram for FractureModel< T >::Impl:

Public Types

typedef Array< T > TArray
 
typedef Vector< T, 3 > VectorT3
 
typedef Array< VectorT3VectorT3Array
 
typedef Gradient< T > TGradType
 
typedef Array< Gradient< T > > TGradArray
 
typedef CRMatrix< T, T, T > T_Matrix
 
typedef SquareTensor< T, 3 > DiagTensorT3
 

Public Member Functions

 Impl (const GeomFields &geomFields, FractureFields &fractureFields, const MeshList &meshes)
 
void init ()
 
FractureBCMapgetBCMap ()
 
FractureVCMapgetVCMap ()
 
FractureBC< T > & getBC (const int id)
 
FractureModelOptions< T > & getOptions ()
 
void initLinearization (LinearSystem &ls)
 
void linearize (LinearSystem &ls)
 
void advance (const int niter)
 
void printBCs ()
 
void updateTime ()
 

Private Attributes

const MeshList _meshes
 
const GeomFields_geomFields
 
FractureFields_fractureFields
 
FractureBCMap _bcMap
 
FractureVCMap _vcMap
 
FractureModelOptions< T > _options
 
GradientModel< T > _phasefieldGradientModel
 
MFRPtr _initialNorm
 
int _niters
 

Detailed Description

template<class T>
class FractureModel< T >::Impl

Definition at line 32 of file FractureModel_impl.h.

Member Typedef Documentation

template<class T>
typedef SquareTensor<T,3> FractureModel< T >::Impl::DiagTensorT3

Definition at line 41 of file FractureModel_impl.h.

template<class T>
typedef CRMatrix<T,T,T> FractureModel< T >::Impl::T_Matrix

Definition at line 40 of file FractureModel_impl.h.

template<class T>
typedef Array<T> FractureModel< T >::Impl::TArray

Definition at line 35 of file FractureModel_impl.h.

template<class T>
typedef Array<Gradient<T> > FractureModel< T >::Impl::TGradArray

Definition at line 39 of file FractureModel_impl.h.

template<class T>
typedef Gradient<T> FractureModel< T >::Impl::TGradType

Definition at line 38 of file FractureModel_impl.h.

template<class T>
typedef Vector<T,3> FractureModel< T >::Impl::VectorT3

Definition at line 36 of file FractureModel_impl.h.

template<class T>
typedef Array<VectorT3> FractureModel< T >::Impl::VectorT3Array

Definition at line 37 of file FractureModel_impl.h.

Constructor & Destructor Documentation

template<class T>
FractureModel< T >::Impl::Impl ( const GeomFields geomFields,
FractureFields fractureFields,
const MeshList meshes 
)
inline

Definition at line 43 of file FractureModel_impl.h.

References Model::_meshes, FractureBC< T >::bcType, Mesh::getBoundaryFaceGroups(), Mesh::getID(), FaceGroup::groupType, FaceGroup::id, and FractureVC< T >::vcType.

45  :
46  _meshes(meshes),
47  _geomFields(geomFields),
48  _fractureFields(fractureFields),
51  _initialNorm(),
52  _niters(0)
53  {
54  const int numMeshes = _meshes.size();
55  for (int n=0; n<numMeshes; n++)
56  {
57  const Mesh& mesh = *_meshes[n];
58  FractureVC<T> *vc(new FractureVC<T>());
59  vc->vcType = "flow";
60  _vcMap[mesh.getID()] = vc;
61 
62  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
63  {
64  const FaceGroup& fg = *fgPtr;
65  FractureBC<T> *bc(new FractureBC<T>());
66 
67  _bcMap[fg.id] = bc;
68 
69  if ((fg.groupType == "wall") ||
70  (fg.groupType == "symmetry"))
71  {
72  bc->bcType = "SpecifiedPhaseFieldFlux";
73  }
74  else if ((fg.groupType == "velocity-inlet") ||
75  (fg.groupType == "pressure-outlet"))
76  {
77  bc->bcType = "SpecifiedPhaseFieldValue";
78  }
79  else
80  throw CException("FractureModel: unknown face group type "
81  + fg.groupType);
82  }
83  }
84  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
FractureFields & _fractureFields
Definition: Mesh.h:28
const GeomFields & _geomFields
Definition: Mesh.h:49
string groupType
Definition: Mesh.h:42
GradientModel< T > _phasefieldGradientModel
const int id
Definition: Mesh.h:41
Field phasefieldGradient
int getID() const
Definition: Mesh.h:106

Member Function Documentation

template<class T>
void FractureModel< T >::Impl::advance ( const int  niter)
inline

Definition at line 387 of file FractureModel_impl.h.

References LinearSystem::initAssembly(), LinearSystem::initSolve(), LinearSystem::postSolve(), and LinearSystem::updateSolution().

388  {
389  for(int n=0; n<niter; n++)
390  {
391  LinearSystem ls;
392  initLinearization(ls);
393 
394  ls.initAssembly();
395 
396  linearize(ls);
397 
398  ls.initSolve();
399 
400  MFRPtr rNorm(_options.getLinearSolver().solve(ls));
401 
402  if (!_initialNorm) _initialNorm = rNorm;
403 
404  MFRPtr normRatio((*rNorm)/(*_initialNorm));
405 
406  cout << _niters << ": " << *rNorm << endl;
407 
408 
409  _options.getLinearSolver().cleanup();
410 
411  ls.postSolve();
412  ls.updateSolution();
413 
414  _niters++;
415  if (*rNorm < _options.absoluteTolerance ||
416  *normRatio < _options.relativeTolerance)
417  break;
418  }
419  }
void linearize(LinearSystem &ls)
void initAssembly()
FractureModelOptions< T > _options
void updateSolution()
void initSolve()
void initLinearization(LinearSystem &ls)
shared_ptr< MultiFieldReduction > MFRPtr
template<class T>
FractureBC<T>& FractureModel< T >::Impl::getBC ( const int  id)
inline

Definition at line 186 of file FractureModel_impl.h.

186 {return *_bcMap[id];}
template<class T>
FractureBCMap& FractureModel< T >::Impl::getBCMap ( )
inline

Definition at line 183 of file FractureModel_impl.h.

183 {return _bcMap;}
template<class T>
FractureModelOptions<T>& FractureModel< T >::Impl::getOptions ( )
inline

Definition at line 188 of file FractureModel_impl.h.

188 {return _options;}
FractureModelOptions< T > _options
template<class T>
FractureVCMap& FractureModel< T >::Impl::getVCMap ( )
inline

Definition at line 184 of file FractureModel_impl.h.

184 {return _vcMap;}
template<class T>
void FractureModel< T >::Impl::init ( )
inline

Definition at line 86 of file FractureModel_impl.h.

References Model::_meshes, Mesh::getBoundaryFaceGroups(), Mesh::getCells(), StorageSite::getCount(), StorageSite::getCountLevel1(), Mesh::getID(), Mesh::getInterfaceGroups(), and FaceGroup::site.

87  {
88  const int numMeshes = _meshes.size();
89  for (int n=0; n<numMeshes; n++)
90  {
91  const Mesh& mesh = *_meshes[n];
92 
93  const StorageSite& cells = mesh.getCells();
94  const FractureVC<T>& vc = *_vcMap[mesh.getID()];
95 
96  //phasefieldvalue
97  shared_ptr<TArray> tCell(new TArray(cells.getCountLevel1()));
98  *tCell = _options["initialPhaseFieldValue"];
100 
101  if(_options.transient)
102  {
103  _fractureFields.phasefieldvalueN1.addArray(cells, dynamic_pointer_cast<ArrayBase>(tCell->newCopy()));
104  if (_options.timeDiscretizationOrder > 1)
105  _fractureFields.phasefieldvalueN2.addArray(cells, dynamic_pointer_cast<ArrayBase>(tCell->newCopy()));
106  }
107 
108  //conductivity
109  shared_ptr<TArray> condCell(new TArray(cells.getCountLevel1()));
110  *condCell = vc["fractureConductivity"];
111  _fractureFields.conductivity.addArray(cells,condCell);
112 
113  //source
114  shared_ptr<TArray> sCell(new TArray(cells.getCountLevel1()));
115  *sCell = vc["fractureSource"];
116  //*sCell =T(0.0);
117  _fractureFields.source.addArray(cells,sCell);
118 
119  //source coef
120  shared_ptr<TArray> scoefCell(new TArray(cells.getCountLevel1()));
121  *scoefCell = vc["fractureSourceCoef"];
122  //*scoefCell=T(0.0);
123  _fractureFields.sourcecoef.addArray(cells,scoefCell);
124 
125  //create a zero field
126  shared_ptr<TArray> zeroCell(new TArray(cells.getCountLevel1()));
127  *zeroCell = T(0.0);
128  _fractureFields.zero.addArray(cells,zeroCell);
129 
130  //create a one field
131  shared_ptr<TArray> oneCell(new TArray(cells.getCountLevel1()));
132  *oneCell = T(1.0);
133  _fractureFields.one.addArray(cells,oneCell);
134 
135  //create specific heat field rho*Cp
136  //shared_ptr<TArray> cp(new TArray(cells.getCount()));
137  //*cp = vc["density"] * vc["specificHeat"];
138  //_thermalFields.specificHeat.addArray(cells, cp);
139 
140  //initial phasefieldvalue gradient array
141  shared_ptr<TGradArray> gradT(new TGradArray(cells.getCountLevel1()));
142  gradT->zero();
144 
145  //inital convection flux at faces
146 
147  //const StorageSite& allFaces = mesh.getFaces();
148  //shared_ptr<TArray> convFlux(new TArray(allFaces.getCount()));
149  //convFlux->zero();
150  //_thermalFields.convectionFlux.addArray(allFaces,convFlux);
151 
152  //phasefield flux at faces
153  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
154  {
155  const FaceGroup& fg = *fgPtr;
156  const StorageSite& faces = fg.site;
157 
158  shared_ptr<TArray> fluxFace(new TArray(faces.getCount()));
159 
160  fluxFace->zero();
161  _fractureFields.phasefieldFlux.addArray(faces,fluxFace);
162 
163  }
164  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
165  {
166  const FaceGroup& fg = *fgPtr;
167  const StorageSite& faces = fg.site;
168 
169  shared_ptr<TArray> fluxFace(new TArray(faces.getCount()));
170 
171  fluxFace->zero();
172  _fractureFields.phasefieldFlux.addArray(faces,fluxFace);
173 
174  }
175 
176 
177  }
179  _niters =0;
180  _initialNorm = MFRPtr();
181  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
FractureFields & _fractureFields
Definition: Mesh.h:28
Field phasefieldvalueN2
Definition: Mesh.h:49
FractureModelOptions< T > _options
Field phasefieldGradient
const StorageSite & getCells() const
Definition: Mesh.h:109
Field phasefieldvalueN1
int getCountLevel1() const
Definition: StorageSite.h:72
Array< Gradient< T > > TGradArray
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
Definition: Field.cpp:72
int getCount() const
Definition: StorageSite.h:39
shared_ptr< MultiFieldReduction > MFRPtr
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
void syncLocal()
Definition: Field.cpp:334
int getID() const
Definition: Mesh.h:106
StorageSite site
Definition: Mesh.h:40
template<class T>
void FractureModel< T >::Impl::initLinearization ( LinearSystem ls)
inline

Definition at line 190 of file FractureModel_impl.h.

References Model::_meshes, MultiField::addArray(), MultiFieldMatrix::addMatrix(), Mesh::getBoundaryFaceGroups(), Mesh::getCellCells(), Mesh::getCells(), StorageSite::getCount(), Mesh::getFaceCells(), Mesh::getInterfaceGroups(), LinearSystem::getMatrix(), LinearSystem::getX(), and FaceGroup::site.

191  {
192  const int numMeshes = _meshes.size();
193  for (int n=0; n<numMeshes; n++)
194  {
195  const Mesh& mesh = *_meshes[n];
196 
197  const StorageSite& cells = mesh.getCells();
199 
201 
202  const CRConnectivity& cellCells = mesh.getCellCells();
203 
204  shared_ptr<Matrix> m(new CRMatrix<T,T,T>(cellCells));
205 
206  ls.getMatrix().addMatrix(tIndex,tIndex,m);
207 
208  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
209  {
210  const FaceGroup& fg = *fgPtr;
211  const StorageSite& faces = fg.site;
212 
215 
216  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
217 
218  shared_ptr<Matrix> mft(new FluxJacobianMatrix<T,T>(faceCells));
219  ls.getMatrix().addMatrix(fIndex,tIndex,mft);
220 
221  shared_ptr<Matrix> mff(new DiagonalMatrix<T,T>(faces.getCount()));
222  ls.getMatrix().addMatrix(fIndex,fIndex,mff);
223  }
224 
225  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
226  {
227  const FaceGroup& fg = *fgPtr;
228  const StorageSite& faces = fg.site;
229 
232 
233  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
234 
235  shared_ptr<Matrix> mft(new FluxJacobianMatrix<T,T>(faceCells));
236  ls.getMatrix().addMatrix(fIndex,tIndex,mft);
237 
238  shared_ptr<Matrix> mff(new DiagonalMatrix<T,T>(faces.getCount()));
239  ls.getMatrix().addMatrix(fIndex,fIndex,mff);
240  }
241 
242  }
243  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
FractureFields & _fractureFields
Definition: Mesh.h:28
Definition: Mesh.h:49
pair< const Field *, const StorageSite * > ArrayIndex
Definition: MultiField.h:21
const CRConnectivity & getCellCells() const
Definition: Mesh.cpp:480
const StorageSite & getCells() const
Definition: Mesh.h:109
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
void addMatrix(const Index &rowI, const Index &colI, shared_ptr< Matrix > m)
int getCount() const
Definition: StorageSite.h:39
void addArray(const ArrayIndex &aIndex, shared_ptr< ArrayBase > a)
Definition: MultiField.cpp:270
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
MultiField & getX()
Definition: LinearSystem.h:32
shared_ptr< ArrayBase > getArrayPtr(const StorageSite &)
Definition: Field.cpp:63
MultiFieldMatrix & getMatrix()
Definition: LinearSystem.h:37
StorageSite site
Definition: Mesh.h:40
template<class T>
void FractureModel< T >::Impl::linearize ( LinearSystem ls)
inline

Definition at line 245 of file FractureModel_impl.h.

References Model::_meshes, BaseGenericBCS< X, Diag, OffDiag >::applyInterfaceBC(), FractureBC< T >::bcType, LinearSystem::getB(), Mesh::getBoundaryFaceGroups(), StorageSite::getCount(), Mesh::getInterfaceGroups(), LinearSystem::getMatrix(), FloatVarDict< T >::getVal(), LinearSystem::getX(), FaceGroup::id, Linearizer::linearize(), and FaceGroup::site.

246  {
248 
249  DiscrList discretizations;
250 
251  shared_ptr<Discretization>
257  discretizations.push_back(dd);
258 
259  //shared_ptr<Discretization>
260  // cd(new ConvectionDiscretization<T,T,T>
261  //(_meshes,_geomFields,
262  // _fractureFields.phasefieldvalue,
263  // _fractureFields.phasefieldFlux,
264  // _fractureFields.zero,
265  // _fractureFields.phasefieldGradient,
266  // _options.useCentralDifference));
267  //discretizations.push_back(cd);
268 
269  shared_ptr<Discretization>
271  (_meshes,
272  _geomFields,
276  discretizations.push_back(scfd);
277 
278  if (_options.transient)
279  {
280  shared_ptr<Discretization>
282  (_meshes, _geomFields,
287  _options["timeStep"]));
288  discretizations.push_back(td);
289  }
290 
291  //shared_ptr<Discretization>
292  // ibm(new GenericIBDiscretization<T,T,T>
293  // (_meshes,_geomFields,_thermalFields.temperature));
294  //discretizations.push_back(ibm);
295 
296 
297  Linearizer linearizer;
298 
299  linearizer.linearize(discretizations,_meshes,ls.getMatrix(),
300  ls.getX(), ls.getB());
301 
302  const int numMeshes = _meshes.size();
303  for (int n=0; n<numMeshes; n++)
304  {
305  const Mesh& mesh = *_meshes[n];
306 
307  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
308  {
309  const FaceGroup& fg = *fgPtr;
310  const StorageSite& faces = fg.site;
311 
312  const FractureBC<T>& bc = *_bcMap[fg.id];
313 
314 
315  GenericBCS<T,T,T> gbc(faces,mesh,
316  _geomFields,
319  ls.getMatrix(), ls.getX(), ls.getB());
320 
321  if (bc.bcType == "SpecifiedPhaseFieldValue")
322  {
324  bT(bc.getVal("specifiedPhaseFieldValue"),faces);
325  gbc.applyDirichletBC(bT);
326  }
327  else if (bc.bcType == "SpecifiedPhaseFieldFlux")
328  {
330  bPhaseFieldFlux(bc.getVal("specifiedPhaseFieldFlux"),faces);
331 
332  const int nFaces = faces.getCount();
333 
334  for(int f=0; f<nFaces; f++)
335  {
336  gbc.applyNeumannBC(f, bPhaseFieldFlux[f]);
337  }
338  }
339  else if (bc.bcType == "Symmetry")
340  {
341  T zeroFlux(NumTypeTraits<T>::getZero());
342  gbc.applyNeumannBC(zeroFlux);
343  }
344  else
345  throw CException(bc.bcType + " not implemented for FractureModel");
346  }
347 
348  foreach(const FaceGroupPtr fgPtr, mesh.getInterfaceGroups())
349  {
350  const FaceGroup& fg = *fgPtr;
351  const StorageSite& faces = fg.site;
352  GenericBCS<T,T,T> gbc(faces,mesh,
353  _geomFields,
356  ls.getMatrix(), ls.getX(), ls.getB());
357 
358  gbc.applyInterfaceBC();
359  }
360  }
361  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
FractureFields & _fractureFields
Definition: Mesh.h:28
Field phasefieldvalueN2
const GeomFields & _geomFields
Definition: Mesh.h:49
FractureModelOptions< T > _options
FloatVal< T > getVal(const string varName) const
Definition: FloatVarDict.h:85
GradientModel< T > _phasefieldGradientModel
const int id
Definition: Mesh.h:41
Field phasefieldGradient
vector< shared_ptr< Discretization > > DiscrList
void applyInterfaceBC(const int f) const
Definition: GenericBCS.h:325
string bcType
Definition: FractureBC.h:18
Field phasefieldvalueN1
int getCount() const
Definition: StorageSite.h:39
MultiField & getB()
Definition: LinearSystem.h:33
const FaceGroupList & getInterfaceGroups() const
Definition: Mesh.h:190
MultiField & getX()
Definition: LinearSystem.h:32
virtual void linearize(DiscrList &discretizations, const MeshList &meshes, MultiFieldMatrix &matrix, MultiField &x, MultiField &b)
Definition: Linearizer.cpp:17
MultiFieldMatrix & getMatrix()
Definition: LinearSystem.h:37
StorageSite site
Definition: Mesh.h:40
template<class T>
void FractureModel< T >::Impl::printBCs ( )
inline

Definition at line 421 of file FractureModel_impl.h.

422  {
423  foreach(typename FractureBCMap::value_type& pos, _bcMap)
424  {
425  cout << "Face Group " << pos.first << ":" << endl;
426  cout << " bc type " << pos.second->bcType << endl;
427  foreach(typename FractureBC<T>::value_type& vp, *pos.second)
428  {
429  cout << " " << vp.first << " " << vp.second.constant << endl;
430  }
431  }
432  }
template<class T>
void FractureModel< T >::Impl::updateTime ( )
inline

Definition at line 435 of file FractureModel_impl.h.

References Model::_meshes, Mesh::getCells(), and StorageSite::getCountLevel1().

436  {
437  const int numMeshes = _meshes.size();
438  for (int n=0; n<numMeshes; n++) {
439 
440  const Mesh& mesh = *_meshes[n];
441  const StorageSite& cells = mesh.getCells();
442  const int nCells = cells.getCountLevel1();
443 
444  TArray& phasefieldvalue =
445  dynamic_cast<TArray&>(_fractureFields.phasefieldvalue[cells]);
446  TArray& phasefieldvalueN1 =
447  dynamic_cast<TArray&>(_fractureFields.phasefieldvalueN1[cells]);
448 
449  if (_options.timeDiscretizationOrder > 1)
450  {
451  TArray& phasefieldvalueN2 =
452  dynamic_cast<TArray&>(_fractureFields.phasefieldvalueN2[cells]);
453  phasefieldvalueN2 = phasefieldvalueN1;
454  }
455  phasefieldvalueN1 = phasefieldvalue;
456  }
457  }
FractureFields & _fractureFields
Field phasefieldvalueN2
Definition: Mesh.h:49
FractureModelOptions< T > _options
const StorageSite & getCells() const
Definition: Mesh.h:109
Field phasefieldvalueN1
int getCountLevel1() const
Definition: StorageSite.h:72

Member Data Documentation

template<class T>
FractureBCMap FractureModel< T >::Impl::_bcMap
private

Definition at line 584 of file FractureModel_impl.h.

template<class T>
FractureFields& FractureModel< T >::Impl::_fractureFields
private

Definition at line 582 of file FractureModel_impl.h.

template<class T>
const GeomFields& FractureModel< T >::Impl::_geomFields
private

Definition at line 581 of file FractureModel_impl.h.

template<class T>
MFRPtr FractureModel< T >::Impl::_initialNorm
private

Definition at line 589 of file FractureModel_impl.h.

template<class T>
const MeshList FractureModel< T >::Impl::_meshes
private

Definition at line 580 of file FractureModel_impl.h.

template<class T>
int FractureModel< T >::Impl::_niters
private

Definition at line 590 of file FractureModel_impl.h.

template<class T>
FractureModelOptions<T> FractureModel< T >::Impl::_options
private

Definition at line 586 of file FractureModel_impl.h.

template<class T>
GradientModel<T> FractureModel< T >::Impl::_phasefieldGradientModel
private

Definition at line 587 of file FractureModel_impl.h.

template<class T>
FractureVCMap FractureModel< T >::Impl::_vcMap
private

Definition at line 585 of file FractureModel_impl.h.


The documentation for this class was generated from the following file: