Chaste  Release::2017.1
ContinuumMechanicsProblemDefinition.hpp
1 /*
2 
3 Copyright (c) 2005-2017, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #ifndef CONTINUUMMECHANICSPROBLEMDEFINITION_HPP_
37 #define CONTINUUMMECHANICSPROBLEMDEFINITION_HPP_
38 
39 #include "AbstractTetrahedralMesh.hpp"
40 #include "UblasCustomFunctions.hpp"
41 #include "AbstractIncompressibleMaterialLaw.hpp"
42 #include "AbstractCompressibleMaterialLaw.hpp"
43 #include "CompressibilityType.hpp"
44 
45 
49 typedef enum BodyForceType_
50 {
51  CONSTANT_BODY_FORCE,
52  FUNCTIONAL_BODY_FORCE
53 } BodyForceType;
54 
58 typedef enum TractionBoundaryConditionType_
59 {
60  NO_TRACTIONS,
61  ELEMENTWISE_TRACTION,
62  FUNCTIONAL_TRACTION,
63  PRESSURE_ON_DEFORMED,
64  FUNCTIONAL_PRESSURE_ON_DEFORMED
65 } TractionBoundaryConditionType;
66 
67 
73 template<unsigned DIM>
75 {
76 public:
79  static const double FREE; // set to DBL_MAX
80 
81 protected:
84 
86  double mDensity;
87 
89  // body force
91 
93  BodyForceType mBodyForceType;
94 
96  c_vector<double,DIM> mConstantBodyForce;
97 
99  c_vector<double,DIM> (*mpBodyForceFunction)(c_vector<double,DIM>& rX, double t);
100 
102  // tractions
104 
106  TractionBoundaryConditionType mTractionBoundaryConditionType;
107 
109  std::vector<BoundaryElement<DIM-1,DIM>*> mTractionBoundaryElements;
110 
112  std::vector<c_vector<double,DIM> > mElementwiseTractions;
113 
117 
122 
124  c_vector<double,DIM> (*mpTractionBoundaryConditionFunction)(c_vector<double,DIM>& rX, double t);
125 
128 
129 
131  // Dirichlet boundary conditions
133 
137  std::vector<unsigned> mDirichletNodes;
138 
140  std::vector<c_vector<double,DIM> > mDirichletNodeValues;
141 
144 
145 public:
151 
154  {
155  }
156 
161  void SetDensity(double density);
162 
166  double GetDensity();
167 
172  void SetZeroDirichletNodes(std::vector<unsigned>& rZeroDirichletNodes);
173 
174  // No method here for setting non-zero Dirichlet BCs - these are in the subclasses..
175 
179  std::vector<unsigned>& rGetDirichletNodes();
180 
184  std::vector<c_vector<double,DIM> >& rGetDirichletNodeValues();
185 
186 
191  void SetBodyForce(c_vector<double,DIM> bodyForce);
192 
197  void SetBodyForce(c_vector<double,DIM> (*pFunction)(c_vector<double,DIM>& rX, double t));
198 
207  c_vector<double,DIM> GetBodyForce(c_vector<double,DIM>& rX, double t = 0.0);
208 
212  BodyForceType GetBodyForceType();
213 
217  c_vector<double,DIM> GetConstantBodyForce();
218 
225  c_vector<double,DIM> EvaluateBodyForceFunction(c_vector<double,DIM>& rX, double t);
226 
230  TractionBoundaryConditionType GetTractionBoundaryConditionType();
231 
238  void SetTractionBoundaryConditions(std::vector<BoundaryElement<DIM-1,DIM>*>& rTractionBoundaryElements,
239  std::vector<c_vector<double,DIM> >& rElementwiseTractions);
240 
248  void SetTractionBoundaryConditions(std::vector<BoundaryElement<DIM-1,DIM>*>& rTractionBoundaryElements,
249  c_vector<double,DIM> (*pFunction)(c_vector<double,DIM>& rX, double t));
250 
258  void SetApplyNormalPressureOnDeformedSurface(std::vector<BoundaryElement<DIM-1,DIM>*>& rTractionBoundaryElements,
259  double normalPressure);
260 
269  void SetApplyNormalPressureOnDeformedSurface(std::vector<BoundaryElement<DIM-1,DIM>*>& rTractionBoundaryElements,
270  double (*pFunction)(double t));
271 
275  std::vector<BoundaryElement<DIM-1,DIM>*>& rGetTractionBoundaryElements();
276 
282  std::vector<c_vector<double,DIM> >& rGetElementwiseTractions();
283 
289  double GetNormalPressure();
290 
304  void SetPressureScaling(double scaleFactor);
305 
312  c_vector<double,DIM> EvaluateTractionFunction(c_vector<double,DIM>& rX, double t);
313 
319  double EvaluateNormalPressureFunction(double t);
320 
321 
326  virtual void Validate();
327 
332  void SetVerboseDuringSolve(bool verboseDuringSolve = true)
333  {
334  mVerboseDuringSolve = verboseDuringSolve;
335  }
336 
341  {
342  return mVerboseDuringSolve;
343  }
344 };
345 
346 #endif // CONTINUUMMECHANICSPROBLEMDEFINITION_HPP_
std::vector< BoundaryElement< DIM-1, DIM > * > & rGetTractionBoundaryElements()
ContinuumMechanicsProblemDefinition(AbstractTetrahedralMesh< DIM, DIM > &rMesh)
void SetTractionBoundaryConditions(std::vector< BoundaryElement< DIM-1, DIM > * > &rTractionBoundaryElements, std::vector< c_vector< double, DIM > > &rElementwiseTractions)
c_vector< double, DIM > EvaluateTractionFunction(c_vector< double, DIM > &rX, double t)
TractionBoundaryConditionType GetTractionBoundaryConditionType()
void SetZeroDirichletNodes(std::vector< unsigned > &rZeroDirichletNodes)
std::vector< c_vector< double, DIM > > & rGetElementwiseTractions()
std::vector< c_vector< double, DIM > > mDirichletNodeValues
std::vector< c_vector< double, DIM > > mElementwiseTractions
c_vector< double, DIM > GetBodyForce(c_vector< double, DIM > &rX, double t=0.0)
void SetVerboseDuringSolve(bool verboseDuringSolve=true)
void SetBodyForce(c_vector< double, DIM > bodyForce)
std::vector< c_vector< double, DIM > > & rGetDirichletNodeValues()
std::vector< BoundaryElement< DIM-1, DIM > * > mTractionBoundaryElements
void SetApplyNormalPressureOnDeformedSurface(std::vector< BoundaryElement< DIM-1, DIM > * > &rTractionBoundaryElements, double normalPressure)
c_vector< double, DIM > EvaluateBodyForceFunction(c_vector< double, DIM > &rX, double t)