Chaste Release::3.1
|
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 00037 #include "SolidMechanicsProblemDefinition.hpp" 00038 #include "AbstractIncompressibleMaterialLaw.hpp" 00039 #include "AbstractCompressibleMaterialLaw.hpp" 00040 00041 00042 template<unsigned DIM> 00043 SolidMechanicsProblemDefinition<DIM>::SolidMechanicsProblemDefinition(QuadraticMesh<DIM>& rMesh) 00044 : ContinuumMechanicsProblemDefinition<DIM>(rMesh), 00045 mSolveUsingSnes(false) 00046 { 00047 } 00048 00049 00050 00051 template<unsigned DIM> 00052 void SolidMechanicsProblemDefinition<DIM>::SetFixedNodes(std::vector<unsigned>& rFixedNodes, std::vector<c_vector<double,DIM> >& rFixedNodeLocations) 00053 { 00054 assert(rFixedNodes.size()==rFixedNodeLocations.size()); 00055 this->mDirichletNodes = rFixedNodes; 00056 00057 this->mDirichletNodeValues.clear(); 00058 for (unsigned i=0; i<this->mDirichletNodes.size(); i++) 00059 { 00060 unsigned index = this->mDirichletNodes[i]; 00061 c_vector<double,DIM> displacement; 00062 for(unsigned j=0; j<DIM; j++) 00063 { 00064 double location = rFixedNodeLocations[i](j); 00065 00066 // compute the displacement, assuming the node 00067 // is not free in this direction 00068 if(location != this->FREE) 00069 { 00070 displacement(j) = location - this->mrMesh.GetNode(index)->rGetLocation()[j]; 00071 } 00072 else 00073 { 00074 displacement(j) = this->FREE; 00075 } 00076 } 00077 this->mDirichletNodeValues.push_back(displacement); 00078 } 00079 } 00080 00081 00082 template<unsigned DIM> 00083 void SolidMechanicsProblemDefinition<DIM>::SetMaterialLaw(CompressibilityType compressibilityType, 00084 AbstractMaterialLaw<DIM>* pMaterialLaw) 00085 { 00086 mIsHomogeneousMaterial = true; 00087 mCompressibilityType = compressibilityType; 00088 00089 mIncompressibleMaterialLaws.clear(); 00090 mCompressibleMaterialLaws.clear(); 00091 00092 assert(pMaterialLaw); 00093 00094 if(compressibilityType==INCOMPRESSIBLE) 00095 { 00096 AbstractIncompressibleMaterialLaw<DIM>* p_law = dynamic_cast<AbstractIncompressibleMaterialLaw<DIM>*>(pMaterialLaw); 00097 CheckCastSuccess(compressibilityType, p_law); 00098 mIncompressibleMaterialLaws.push_back(p_law); 00099 } 00100 else 00101 { 00102 AbstractCompressibleMaterialLaw<DIM>* p_law = dynamic_cast<AbstractCompressibleMaterialLaw<DIM>*>(pMaterialLaw); 00103 CheckCastSuccess(compressibilityType, p_law); 00104 mCompressibleMaterialLaws.push_back(p_law); 00105 } 00106 } 00107 00108 00109 template<unsigned DIM> 00110 void SolidMechanicsProblemDefinition<DIM>::SetMaterialLaw(CompressibilityType compressibilityType, 00111 std::vector<AbstractMaterialLaw<DIM>*>& rMaterialLaws) 00112 { 00113 mIsHomogeneousMaterial = false; 00114 mCompressibilityType = compressibilityType; 00115 00116 mIncompressibleMaterialLaws.clear(); 00117 mCompressibleMaterialLaws.clear(); 00118 00119 assert(this->mrMesh.GetNumElements()==rMaterialLaws.size()); 00120 00121 if(compressibilityType==INCOMPRESSIBLE) 00122 { 00123 for(unsigned i=0; i<rMaterialLaws.size(); i++) 00124 { 00125 assert(rMaterialLaws[i]); 00126 AbstractIncompressibleMaterialLaw<DIM>* p_law = dynamic_cast<AbstractIncompressibleMaterialLaw<DIM>*>(rMaterialLaws[i]); 00127 CheckCastSuccess(compressibilityType, p_law); 00128 mIncompressibleMaterialLaws.push_back(p_law); 00129 } 00130 } 00131 else 00132 { 00133 for(unsigned i=0; i<rMaterialLaws.size(); i++) 00134 { 00135 assert(rMaterialLaws[i]); 00136 AbstractCompressibleMaterialLaw<DIM>* p_law = dynamic_cast<AbstractCompressibleMaterialLaw<DIM>*>(rMaterialLaws[i]); 00137 CheckCastSuccess(compressibilityType, p_law); 00138 mCompressibleMaterialLaws.push_back(p_law); 00139 } 00140 } 00141 } 00142 00143 00144 00145 00146 template<unsigned DIM> 00147 bool SolidMechanicsProblemDefinition<DIM>::IsHomogeneousMaterial() 00148 { 00149 // if this fails, SetMaterialLaw() hasn't been called 00150 assert(mIncompressibleMaterialLaws.size()!=0 || mCompressibleMaterialLaws.size()!=0 ); 00151 return mIsHomogeneousMaterial; 00152 } 00153 00154 template<unsigned DIM> 00155 CompressibilityType SolidMechanicsProblemDefinition<DIM>::GetCompressibilityType() 00156 { 00157 // if this fails, SetMaterialLaw() hasn't been called 00158 assert(mIncompressibleMaterialLaws.size()!=0 || mCompressibleMaterialLaws.size()!=0 ); 00159 return mCompressibilityType; 00160 } 00161 00162 00163 00164 00165 template<unsigned DIM> 00166 AbstractIncompressibleMaterialLaw<DIM>* SolidMechanicsProblemDefinition<DIM>::GetIncompressibleMaterialLaw(unsigned elementIndex) 00167 { 00168 assert(mCompressibilityType==INCOMPRESSIBLE); 00169 assert(mIncompressibleMaterialLaws.size()>0); 00170 assert(mCompressibleMaterialLaws.size()==0); 00171 00172 if(mIsHomogeneousMaterial) 00173 { 00174 return mIncompressibleMaterialLaws[0]; 00175 } 00176 else 00177 { 00178 assert(elementIndex < this->mrMesh.GetNumNodes()); 00179 return mIncompressibleMaterialLaws[elementIndex]; 00180 } 00181 } 00182 00183 template<unsigned DIM> 00184 AbstractCompressibleMaterialLaw<DIM>* SolidMechanicsProblemDefinition<DIM>::GetCompressibleMaterialLaw(unsigned elementIndex) 00185 { 00186 assert(mCompressibilityType==COMPRESSIBLE); 00187 assert(mIncompressibleMaterialLaws.size()==0); 00188 assert(mCompressibleMaterialLaws.size()>0); 00189 00190 if(mIsHomogeneousMaterial) 00191 { 00192 return mCompressibleMaterialLaws[0]; 00193 } 00194 else 00195 { 00196 assert(elementIndex < this->mrMesh.GetNumNodes()); 00197 return mCompressibleMaterialLaws[elementIndex]; 00198 } 00199 } 00200 00201 template<unsigned DIM> 00202 void SolidMechanicsProblemDefinition<DIM>::CheckCastSuccess(CompressibilityType compressibilityType, 00203 AbstractMaterialLaw<DIM>* pMaterialLaw) 00204 { 00205 if(compressibilityType==INCOMPRESSIBLE && pMaterialLaw==NULL) 00206 { 00207 // then dynamic_cast to AbstractIncompressibleMaterialLaw failed 00208 EXCEPTION("Compressibility type was declared as INCOMPRESSIBLE but a compressible material law was given"); 00209 } 00210 00211 if(compressibilityType==COMPRESSIBLE && pMaterialLaw==NULL) 00212 { 00213 // then dynamic_cast to AbstractCompressibleMaterialLaw failed 00214 EXCEPTION("Incompressibility type was declared as COMPRESSIBLE but an incompressible material law was given"); 00215 } 00216 } 00217 00218 00219 template<unsigned DIM> 00220 void SolidMechanicsProblemDefinition<DIM>::Validate() 00221 { 00222 ContinuumMechanicsProblemDefinition<DIM>::Validate(); 00223 00224 if((mIncompressibleMaterialLaws.size()==0) && (mCompressibleMaterialLaws.size()==0)) 00225 { 00226 EXCEPTION("No material law has been set"); 00227 } 00228 } 00230 // Explicit instantiation 00232 00233 template class SolidMechanicsProblemDefinition<2>; 00234 template class SolidMechanicsProblemDefinition<3>; 00235