Chaste Release::3.1
ContinuumMechanicsProblemDefinition.hpp
00001 /*
00002 
00003 Copyright (c) 2005-2012, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 #ifndef CONTINUUMMECHANICSPROBLEMDEFINITION_HPP_
00037 #define CONTINUUMMECHANICSPROBLEMDEFINITION_HPP_
00038 
00039 #include "QuadraticMesh.hpp"
00040 #include "UblasCustomFunctions.hpp"
00041 #include "AbstractIncompressibleMaterialLaw.hpp"
00042 #include "AbstractCompressibleMaterialLaw.hpp"
00043 #include "CompressibilityType.hpp"
00044 
00045 
00049 typedef enum BodyForceType_
00050 {
00051     CONSTANT_BODY_FORCE,
00052     FUNCTIONAL_BODY_FORCE
00053 } BodyForceType;
00054 
00058 typedef enum TractionBoundaryConditionType_
00059 {
00060     NO_TRACTIONS,
00061     ELEMENTWISE_TRACTION,
00062     FUNCTIONAL_TRACTION,
00063     PRESSURE_ON_DEFORMED,
00064     FUNCTIONAL_PRESSURE_ON_DEFORMED
00065 } TractionBoundaryConditionType;
00066 
00067 
00073 template<unsigned DIM>
00074 class ContinuumMechanicsProblemDefinition
00075 {
00076 public:
00079     static const double FREE; // set to DBL_MAX
00080 
00081 protected:
00083     QuadraticMesh<DIM>& mrMesh;
00084 
00086     double mDensity;
00087 
00089     // body force
00091 
00093     BodyForceType mBodyForceType;
00094 
00096     c_vector<double,DIM> mConstantBodyForce;
00097 
00099     c_vector<double,DIM> (*mpBodyForceFunction)(c_vector<double,DIM>& rX, double t);
00100 
00102     // tractions
00104 
00106     TractionBoundaryConditionType mTractionBoundaryConditionType;
00107 
00109     std::vector<BoundaryElement<DIM-1,DIM>*> mTractionBoundaryElements;
00110 
00112     std::vector<c_vector<double,DIM> > mElementwiseTractions;
00113 
00116     double mNormalPressure;
00117 
00121     double mOriginalNormalPressure;
00122 
00124     c_vector<double,DIM> (*mpTractionBoundaryConditionFunction)(c_vector<double,DIM>& rX, double t);
00125 
00127     double (*mpNormalPressureFunction)(double t);
00128 
00129 
00131     // Dirichlet boundary conditions
00133 
00137     std::vector<unsigned> mDirichletNodes;
00138 
00140     std::vector<c_vector<double,DIM> > mDirichletNodeValues;
00141 
00143     bool mVerboseDuringSolve;
00144 
00145 public:
00150     ContinuumMechanicsProblemDefinition(QuadraticMesh<DIM>& rMesh);
00151 
00153     virtual ~ContinuumMechanicsProblemDefinition()
00154     {
00155     }
00156 
00161     void SetDensity(double density);
00162 
00166     double GetDensity();
00167 
00172     void SetZeroDirichletNodes(std::vector<unsigned>& rZeroDirichletNodes);
00173 
00174     // No method here for setting non-zero Dirichlet BCs - these are in the subclasses..
00175 
00179     std::vector<unsigned>& rGetDirichletNodes();
00180 
00184     std::vector<c_vector<double,DIM> >& rGetDirichletNodeValues();
00185 
00186 
00191     void SetBodyForce(c_vector<double,DIM> bodyForce);
00192 
00197     void SetBodyForce(c_vector<double,DIM> (*pFunction)(c_vector<double,DIM>& rX, double t));
00198 
00207     c_vector<double,DIM> GetBodyForce(c_vector<double,DIM>& rX, double t = 0.0);
00208 
00212     BodyForceType GetBodyForceType();
00213 
00217     c_vector<double,DIM> GetConstantBodyForce();
00218 
00225     c_vector<double,DIM> EvaluateBodyForceFunction(c_vector<double,DIM>& rX, double t);
00226 
00230     TractionBoundaryConditionType GetTractionBoundaryConditionType();
00231 
00238     void SetTractionBoundaryConditions(std::vector<BoundaryElement<DIM-1,DIM>*>& rTractionBoundaryElements,
00239                                        std::vector<c_vector<double,DIM> >& rElementwiseTractions);
00240 
00248     void SetTractionBoundaryConditions(std::vector<BoundaryElement<DIM-1,DIM>*>& rTractionBoundaryElements,
00249                                        c_vector<double,DIM> (*pFunction)(c_vector<double,DIM>& rX, double t));
00250 
00258     void SetApplyNormalPressureOnDeformedSurface(std::vector<BoundaryElement<DIM-1,DIM>*>& rTractionBoundaryElements,
00259                                                  double normalPressure);
00260 
00261 
00262 
00271     void SetApplyNormalPressureOnDeformedSurface(std::vector<BoundaryElement<DIM-1,DIM>*>& rTractionBoundaryElements,
00272                                                  double (*pFunction)(double t));
00273 
00277     std::vector<BoundaryElement<DIM-1,DIM>*>& rGetTractionBoundaryElements();
00278 
00284     std::vector<c_vector<double,DIM> >& rGetElementwiseTractions();
00285 
00291     double GetNormalPressure();
00292 
00306     void SetPressureScaling(double scaleFactor);
00307 
00314     c_vector<double,DIM> EvaluateTractionFunction(c_vector<double,DIM>& rX, double t);
00315 
00321     double EvaluateNormalPressureFunction(double t);
00322 
00323 
00328     virtual void Validate();
00329 
00334     void SetVerboseDuringSolve(bool verboseDuringSolve = true)
00335     {
00336         mVerboseDuringSolve = verboseDuringSolve;
00337     }
00338 
00342     bool GetVerboseDuringSolve()
00343     {
00344         return mVerboseDuringSolve;
00345     }
00346 
00347 };
00348 
00349 
00350 #endif // CONTINUUMMECHANICSPROBLEMDEFINITION_HPP_