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 #include "SimpleNonlinearEllipticSolver.hpp" 00037 00038 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM> 00039 c_matrix<double,1*(ELEMENT_DIM+1),1*(ELEMENT_DIM+1)> SimpleNonlinearEllipticSolver<ELEMENT_DIM,SPACE_DIM>::ComputeMatrixTerm( 00040 c_vector<double, ELEMENT_DIM+1>& rPhi, 00041 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>& rGradPhi, 00042 ChastePoint<SPACE_DIM>& rX, 00043 c_vector<double,1>& rU, 00044 c_matrix<double,1,SPACE_DIM>& rGradU, 00045 Element<ELEMENT_DIM,SPACE_DIM>* pElement) 00046 { 00047 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> ret; 00048 00049 c_matrix<double, SPACE_DIM, SPACE_DIM> f_of_u = mpNonlinearEllipticPde->ComputeDiffusionTerm(rX, rU(0)); 00050 c_matrix<double, SPACE_DIM, SPACE_DIM> f_of_u_prime = mpNonlinearEllipticPde->ComputeDiffusionTermPrime(rX, rU(0)); 00051 00052 // LinearSourceTerm(x) not needed as it is a constant wrt u 00053 double forcing_term_prime = mpNonlinearEllipticPde->ComputeNonlinearSourceTermPrime(rX, rU(0)); 00054 00055 // Note rGradU is a 1 by SPACE_DIM matrix, the 1 representing the dimension of 00056 // u (ie in this problem the unknown is a scalar). r_gradu_0 is rGradU as a vector 00057 matrix_row< c_matrix<double, 1, SPACE_DIM> > r_gradu_0(rGradU, 0); 00058 c_vector<double, SPACE_DIM> temp1 = prod(f_of_u_prime, r_gradu_0); 00059 c_vector<double, ELEMENT_DIM+1> temp1a = prod(temp1, rGradPhi); 00060 00061 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> integrand_values1 = outer_prod(temp1a, rPhi); 00062 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp2 = prod(f_of_u, rGradPhi); 00063 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> integrand_values2 = prod(trans(rGradPhi), temp2); 00064 c_vector<double, ELEMENT_DIM+1> integrand_values3 = forcing_term_prime * rPhi; 00065 00066 ret = integrand_values1 + integrand_values2 - outer_prod( scalar_vector<double>(ELEMENT_DIM+1), integrand_values3); 00067 00068 return ret; 00069 } 00070 00071 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM> 00072 c_vector<double,1*(ELEMENT_DIM+1)> SimpleNonlinearEllipticSolver<ELEMENT_DIM,SPACE_DIM>::ComputeVectorTerm( 00073 c_vector<double, ELEMENT_DIM+1>& rPhi, 00074 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>& rGradPhi, 00075 ChastePoint<SPACE_DIM>& rX, 00076 c_vector<double,1>& rU, 00077 c_matrix<double,1,SPACE_DIM>& rGradU, 00078 Element<ELEMENT_DIM,SPACE_DIM>* pElement) 00079 { 00080 c_vector<double, 1*(ELEMENT_DIM+1)> ret; 00081 00082 // For solving an AbstractNonlinearEllipticEquation 00083 // d/dx [f(U,x) du/dx ] = -g 00084 // where g(x,U) is the forcing term 00085 double forcing_term = mpNonlinearEllipticPde->ComputeLinearSourceTerm(rX); 00086 forcing_term += mpNonlinearEllipticPde->ComputeNonlinearSourceTerm(rX, rU(0)); 00087 00088 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM> FOfU = mpNonlinearEllipticPde->ComputeDiffusionTerm(rX, rU(0)); 00089 00090 // Note rGradU is a 1 by SPACE_DIM matrix, the 1 representing the dimension of 00091 // u (ie in this problem the unknown is a scalar). rGradU0 is rGradU as a vector. 00092 matrix_row< c_matrix<double, 1, SPACE_DIM> > rGradU0(rGradU, 0); 00093 c_vector<double, ELEMENT_DIM+1> integrand_values1 = 00094 prod(c_vector<double, ELEMENT_DIM>(prod(rGradU0, FOfU)), rGradPhi); 00095 00096 ret = integrand_values1 - (forcing_term * rPhi); 00097 return ret; 00098 } 00099 00100 00101 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM> 00102 SimpleNonlinearEllipticSolver<ELEMENT_DIM,SPACE_DIM>::SimpleNonlinearEllipticSolver( 00103 AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>* pMesh, 00104 AbstractNonlinearEllipticPde<SPACE_DIM>* pPde, 00105 BoundaryConditionsContainer<ELEMENT_DIM, SPACE_DIM, 1>* pBoundaryConditions, 00106 unsigned numQuadPoints) 00107 : AbstractNonlinearAssemblerSolverHybrid<ELEMENT_DIM,SPACE_DIM,1>(pMesh,pBoundaryConditions,numQuadPoints), 00108 mpNonlinearEllipticPde(pPde) 00109 { 00110 assert(pPde!=NULL); 00111 } 00112 00114 // Explicit instantiation 00116 00117 template class SimpleNonlinearEllipticSolver<1,1>; 00118 template class SimpleNonlinearEllipticSolver<2,2>; 00119 template class SimpleNonlinearEllipticSolver<3,3>;