00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "SimpleNonlinearEllipticAssembler.hpp"
00031
00032
00033 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00034 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::SimpleNonlinearEllipticAssembler(
00035 AbstractMesh<ELEMENT_DIM, SPACE_DIM>* pMesh,
00036 AbstractNonlinearEllipticPde<SPACE_DIM>* pPde,
00037 BoundaryConditionsContainer<ELEMENT_DIM, SPACE_DIM, 1>* pBoundaryConditions,
00038 unsigned numQuadPoints)
00039 : AbstractAssembler<ELEMENT_DIM,SPACE_DIM,1>(),
00040 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::BaseClassType(numQuadPoints)
00041 {
00042 assert(pMesh!=NULL);
00043 assert(pPde!=NULL);
00044 assert(pBoundaryConditions!=NULL);
00045
00046
00047 this->SetMesh(pMesh);
00048 mpNonlinearEllipticPde = pPde;
00049 this->SetBoundaryConditionsContainer(pBoundaryConditions);
00050 }
00051
00052 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00053 c_matrix<double,1*(ELEMENT_DIM+1),1*(ELEMENT_DIM+1)>
00054 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::ComputeMatrixTerm(
00055 c_vector<double, ELEMENT_DIM+1> &rPhi,
00056 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM+1> &rGradPhi,
00057 ChastePoint<SPACE_DIM> &rX,
00058 c_vector<double,1> &u,
00059 c_matrix<double,1,SPACE_DIM> &rGradU,
00060 Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00061 {
00062 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> ret;
00063
00064 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM> f_of_u = mpNonlinearEllipticPde->ComputeDiffusionTerm(rX,u(0));
00065 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM> f_of_u_prime = mpNonlinearEllipticPde->ComputeDiffusionTermPrime(rX,u(0));
00066
00067
00068 double forcing_term_prime = mpNonlinearEllipticPde->ComputeNonlinearSourceTermPrime(rX, u(0));
00069
00070
00071
00072 matrix_row< c_matrix<double, 1, SPACE_DIM> > rGradU0( rGradU, 0);
00073 c_vector<double, ELEMENT_DIM> temp1 = prod(f_of_u_prime,rGradU0);
00074 c_vector<double, ELEMENT_DIM+1> temp1a = prod(temp1, rGradPhi);
00075
00076 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> integrand_values1 = outer_prod(temp1a, rPhi);
00077 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM+1> temp2 = prod(f_of_u, rGradPhi);
00078 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> integrand_values2 = prod(trans(rGradPhi), temp2);
00079 c_vector<double, ELEMENT_DIM+1> integrand_values3 = forcing_term_prime * rPhi;
00080
00081 ret = integrand_values1 + integrand_values2 - outer_prod( scalar_vector<double>(ELEMENT_DIM+1), integrand_values3);
00082
00083 return ret;
00084 }
00085
00086 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00087 c_vector<double,1*(ELEMENT_DIM+1)>
00088 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::ComputeVectorTerm(
00089 c_vector<double, ELEMENT_DIM+1> &rPhi,
00090 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM+1> &rGradPhi,
00091 ChastePoint<SPACE_DIM> &rX,
00092 c_vector<double,1> &u,
00093 c_matrix<double,1,SPACE_DIM> &rGradU,
00094 Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00095 {
00096 c_vector<double, 1*(ELEMENT_DIM+1)> ret;
00097
00098
00099
00100
00101
00102
00103
00104 double ForcingTerm = mpNonlinearEllipticPde->ComputeLinearSourceTerm(rX);
00105 ForcingTerm += mpNonlinearEllipticPde->ComputeNonlinearSourceTerm(rX, u(0));
00106
00107
00108 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM> FOfU = mpNonlinearEllipticPde->ComputeDiffusionTerm(rX,u(0));
00109
00110
00111
00112 matrix_row< c_matrix<double, 1, SPACE_DIM> > rGradU0( rGradU, 0);
00113 c_vector<double, ELEMENT_DIM+1> integrand_values1 =
00114 prod(c_vector<double, ELEMENT_DIM>(prod(rGradU0, FOfU)), rGradPhi);
00115
00116 ret = integrand_values1 - (ForcingTerm * rPhi);
00117 return ret;
00118 }
00119
00120 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00121 c_vector<double, 1*ELEMENT_DIM>
00122 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::ComputeVectorSurfaceTerm(
00123 const BoundaryElement<ELEMENT_DIM-1,SPACE_DIM> &rSurfaceElement,
00124 c_vector<double, ELEMENT_DIM> &rPhi,
00125 ChastePoint<SPACE_DIM> &rX)
00126 {
00127 double Dgradu_dot_n = this->mpBoundaryConditions->GetNeumannBCValue(&rSurfaceElement, rX);
00128
00129
00130 return (-Dgradu_dot_n)* rPhi;
00131 }
00132
00133
00134
00136
00138
00139 template class SimpleNonlinearEllipticAssembler<1,1>;
00140 template class SimpleNonlinearEllipticAssembler<2,2>;
00141 template class SimpleNonlinearEllipticAssembler<3,3>;